Giter Site home page Giter Site logo

gorilla / css Goto Github PK

View Code? Open in Web Editor NEW
86.0 11.0 37.0 30 KB

Package gorilla/css is a CSS3 tokenizer.

Home Page: https://gorilla.github.io

License: BSD 3-Clause "New" or "Revised" License

Go 94.34% Makefile 5.66%
gorilla golang css css3-tokenizer go gorilla-web-toolkit

css's People

Contributors

alin04 avatar coreydaley avatar daohoangson avatar elithrar avatar ewtroan avatar kisielk avatar moraes avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

css's Issues

_double_quote vs _single_quote

Double quotes are more common and idiomatic in both CSS and HTML, single quotes are more common and idiomatic in JS. This is the same reason that JSX has double quotes, despite JS having single quotes: the similarity to HTML implies using similar quote styles. CSS โ†’ SASS is no different.

Am I correct at this?? @garyburd

Tokenizer works incorrectly when parsing CSS without line breaks

The tokenizer seems to work for pretty printed CSS, but it has trouble picking up closing brackets for CSS without line breaks. Because it does not identify the line breaks, it produces a string token with lots of CSS insider of it. All that CSS is inaccessible.

Implications of this bug

Much of the CSS found in the wild has removed line breaks to save space. This bug prevents much of the CSS found on the web from being parsed properly.

Steps to reproduce

the following valid CSS parses correctly when pretty printed, and incorrectly when it is not pretty printed. Inspect the tokens produced for the pretty printed version and the non- pretty printed version.

#sw_tfbb,#id_d{display:none}.sw_pref{border-style:solid;border-width:7px 0 7px 10px;vertical-align:bottom}#b_tween{margin-top:-28px}#b_tween>span{line-height:30px}#b_tween .ftrH{line-height:30px;height:30px}input{font:inherit;font-size:100%}.b_searchboxForm{font:18px/normal 'Segoe UI',Arial,Helvetica,Sans-Serif}.b_beta{font:11px/normal Arial,Helvetica,Sans-Serif}.b_scopebar,.id_button{line-height:30px}.sa_ec{font:13px Arial,Helvetica,Sans-Serif}#sa_ul .sa_hd{font-size:11px;line-height:16px}#sw_as strong{font-family:'Segoe UI Semibold',Arial,Helvetica,Sans-Serif}#id_h{background-color:transparent!important;position:relativ e!important;float:right;height:35px!important;width:280px!important}.sw_pref{margin:0 15px 3px 0}#id_d{left:auto;right:26px;top:35px!important}.id_avatar{vertical-align:middle;margin:10px 0 10px 10px}

Perform all preprocessing as per the spec.

The spec indicates there are more preprocessing rules to implement. Namely, in addition to replacing pairs of CRLF, also replace CR (by itself) and FF (by itself) with LF. As well as replace NULL code with the replacement char.

Parser does not properly emit bad-string tokens

The "consume an at-rule" algorithm says that the following should result in an at-rule with a prelude of title 56 56 Who's this d****e? and no block, but instead enters an "unclosed q" error state.

https://www.w3.org/TR/css-syntax-3/#consume-an-at-rule

Real world example: https://mspfa.com/?s=21504&p=2 (added to a <style> element dynamically, CSS is in the .y field obtained from POST mspfa.com do=story&s=21504)

@mspfa title 1 1 Fanventure START!!;
/*                   vvv Unmatched quote */
@mspfa title 56 56 Who's this d****e?; @mspfa title 62 64 ???;
@mspfa title 131 131 Troll time. @mspfa title 194 194 What is this, Rick and Morty eyes?;
/* ... custom at-rules continue ... */

.p436 #content div {
    background-color: #FFFFFF;
    border: 4px solid #009933;
    padding: 15px 25px;
    box-shadow: 4px 4px #005500;
}

/* ... normal CSS rules continue ... */

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.