Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


Inline style parsing #49

wants to merge 235 commits into from

3 participants


added inline-style parsing for elements - property validation is in, value validation isn't (so, same as for CSS in style blocks)

toolness and others added some commits
@toolness toolness Origination. 9ef5873
@toolness toolness minor wording change 1cfb4bc
@toolness toolness Made tests pass, albeit very poorly. Also brought in CodeMirror2's HT…
…ML lexer.
@toolness toolness Minor refactorings to test suite. d18bf92
@toolness toolness Changed the spec so an element node's parseInfo has openTag and close…
…Tag property intervals, rather than just start/end for the whole element and its contents.
@toolness toolness added more tests 87d7b62
@toolness toolness more refactorings to test suite d600e39
@toolness toolness added another test and fixed it e017429
@toolness toolness Added demo. e0b45d6
@toolness toolness CSS tweaks to demo 43450de
@toolness toolness more CSS tweaks fe161c0
@toolness toolness can now parse text w/ newlines 0df6fbd
@toolness toolness added another test and fixed it. 6c662b5
@toolness toolness minor refactoring for readability 46f3506
@toolness toolness tokenizer no longer exposes internal state of codemirror tokenizer. 5bc4ba2
@toolness toolness fixed minor bug in newline tokenization 8568791
@toolness toolness added INVALID_TAG_NAME error type ecbaeec
@toolness toolness started work on new tokenizer 5b53b81
@toolness toolness using a CodeMirror-inspired stream object to simplify code. 35d763f
@toolness toolness added and stream.eatWhile(). dcad3ee
@toolness toolness attribute parsing works now caa29ef
@toolness toolness swapped-in the new tokenizer 412efca
@toolness toolness removed codemirror dependency from slowparse c098301
@toolness toolness moved codemirror2 into demo dir 62d1ca2
@toolness toolness turned the tokenizer into a parser; the lexing+parsing stages are now…
… unified to (hopefully) provide better error feedback, and possibly easier to understand code.
@toolness toolness replaced a commented TODO with an error-throwing TODO. b4716b1
@toolness toolness minor rewording of exception 77f0317
@toolness toolness more TODOs 2ff4de5
@toolness toolness another TODO 0cde162
@toolness toolness TODO rewordings d4dabda
@toolness toolness refactored parseHTML into an HTMLParser class. d95d8d4
@toolness toolness Changed the way parsing errors are reported a bit. Also added MISMATC…
…HED_CLOSE_TAG error type.
@toolness toolness fixed a ParseError bug and added decent feedback for the MISMATCHED_C…
…LOSE_TAG error in the demo.
@toolness toolness in demo, focus editor when selection interval is set cf0afc9
@toolness toolness Added error reporting specification document. 9686312
@toolness toolness spec has smaller text and is less wide 5667f56
@toolness toolness Added Slowparse.findError() to make spec document shorter, and API ea…
…sier to use for just error reporting.
@toolness toolness changed ParseError format yet again. It's now decoupled from any gene…
…rated DOM nodes, and is pure JSON... not sure if that's a good idea or not, but it seems like we might want to use this in situations where we're not generating a DOM.
@toolness toolness tag name of ParseErrors is retrieved via e.g. inst…
…ead of error.openTagName.
@toolness toolness added link to spec from demo/index.html. 7bbdc90
@toolness toolness removed a line of unused code 4f9038d
@toolness toolness use underscore.js templates for human-readable parse error messages o…
…n demo.
@toolness toolness better error messages for INVALID_TAG_NAME and UNCLOSED_TAG. 9fb1ec2
@toolness toolness spec now shows human-friendly error messages. 3d7cc70
@toolness toolness different sections of the spec can now be referenced by URL hash. 2621b6b
@toolness toolness added a helpful second paragraph to the INVALID_TAG_NAME error message. ec6d6b9
@toolness toolness added an intro to the spec. ec58433
@toolness toolness added links to spec and demo in readme, and a link to the demo in the…
… spec.
@toolness toolness test suite now tests specification against expected results. 9eddc9d
@toolness toolness added notes to beginning of specification frame. f8a1d1d
@toolness toolness minor capitalization change e9b6d3f
@toolness toolness moved spec JS into a separate file. 42b48f9
@toolness toolness added UNTERMINATED_ATTR_VALUE error. f589b8b
@toolness toolness made the UNTERMINATED_ATTR_VALUE example better. 261adf6
@toolness toolness Factored out all the verbose ParseError.parseInfo-generating code int…
…o a separate object, ParseErrorBuilders.
@toolness toolness better display of failed spec tests abbeea1
@toolness toolness added UNQUOTED_ATTR_VALUE error. Less information is reported in this…
… one, but hopefully that's ok for now.
@toolness toolness added a 'notes' section for the UNQUOTED_ATTR_VALUE error. 85bcd95
@toolness toolness reworded UNQUOTED_ATTR_VALUE message text. 2dde1f6
@toolness toolness added UNTERMINATED_CLOSE_TAG error type. 19f1200
@toolness toolness UNTERMINATED_CLOSE_TAG now applies regardless of whether the close ta…
…g is at the end of the stream or not.
@toolness toolness fixed JSON serialization issue for better code readability. 8cbf799
@toolness toolness added UNTERMINATED_OPEN_TAG error type. 1c43b9a
@toolness toolness refactored tests a bit 9016b9b
@toolness toolness added support for basic named character entity references lt, gt, quo…
…t, and amp. no support for numeric character entity references yet. the parsing, like .innerHTML, is quite forgiving, b/c if it wasn't, lots of technically invalid HTML would fail--e.g. URLs with multiple querystring args in text or attribute values.
Mike Kamermans updated slowparse with CSS parsing 36f62e3
@toolness toolness Refactored more errors into ParseErrorBuilders object. 11e8acf
@toolness toolness Documented the internal Stream class and the replaceEntityRefs() func…
@toolness toolness added UNEXPECTED_CLOSE_TAG error type. c783232
@Pomax Pomax minor update, plus some 'fuller' html pages 5562fa3
Mike Kamermans finished up preliminary CSS parsing f6f3e26
@toolness toolness Merge remote branch 'pomax/gh-pages' into pomax-css-parsing. However,…
… I simply reverted demo/index.html to its state in commit 3d7cc70 rather than merging pomax's changes from 5562fa3 because merging the two revisions was very complicated and pomax's changes to the file were minor. They can be re-merged in a separate pull request.

Mike Kamermans added HTML element knowledge, changed the gobbling for tagnames to \w…
…\d rather than \w to accomodate h1...h6
@toolness toolness Merge pull request #2 from Pomax/gh-pages
html updates
Mike Kamermans turned CSS errors into nice errors 6a3f63c
@toolness toolness Merge branch 'gh-pages' of into gh…
@toolness toolness fixed broken INVALID_CSS_RULE test. 5824548
@toolness toolness Fixed #3, 'slowparse needs to understand void elements'. 497e44e
@toolness toolness Fixed a bug with UNTERMINATED_CLOSE_TAG when it is encountered at the…
… end of a stream.
@toolness toolness added a really basic two-pane editor. c2b7118
@toolness toolness division between editor's two panes is now visible. b775511
@toolness toolness in editor, offending text in malformed HTML/CSS is now highlighted by…
… default; user does not have to mouseover 'here'.
@toolness toolness expose internal list of HTML element and CSS properties. 0074291
@toolness toolness like INVALID_TAG_NAME, INVALID_CSS_PROPERTY_NAME now reports the name…
… of the CSS property.
@toolness toolness Added suggestions for tags/properties when unrecognized ones are found. 246b83d
@toolness toolness added hacktionary data, though it doesn't yet contain docs on attribu…
…tes. in editor, html/css suggestions now show blurbs from hacktionary.
@toolness toolness added pointer to hacktionary repo in a JS comment 0dcd5de
@toolness toolness Added more extensive parseInfo structure to a <style> element's text …
…node. Right now the implementation isn't great, but I'm mostly going for correctness in the tests--once we have a good test suite, we can start refactoring the implementation to be cleaner.
@toolness toolness added another CSS test. c07f870
@toolness toolness more CSS tests, one fix. cdf542b
@toolness toolness more CSS tests, another off-by-one fix. 88c4999
@toolness toolness added TODO to CSSParser. feaaea2
@toolness toolness added a TODO to editor. f92768f
@toolness toolness added context-sensitive help for tags and css props. 5466b1e
@toolness toolness tweaked styling for 'learn more' button in editor. b9b97ce
@toolness toolness modified TODO in editor. 5a3394e
@toolness toolness highlight relevant parts of code that we're giving help on as the use…
…r moves cursor through text.
@toolness toolness added more vendor-prefixed CSS properties. a296755
@toolness toolness minor CSS tweak to editor 09b92d4
@toolness toolness in editor, fixed a bug w/ context-sensitive help on document change. 83accc5
@toolness toolness added basic context-sensitive help on CSS selectors to editor. ae712d3
@toolness toolness moved JS code from editor/index.html to a new file. edb479c
@toolness toolness add support for parsing basic HTML5 doctype (but not generalized doct…
…ypes). Also added stream.match() for strings.
@toolness toolness Fixed #7, 'HTML comments are unsupported'. 98d8926
@toolness toolness fixed another end-of-stream error bug. 50cffff
@toolness toolness added support for boolean attributes. 5912f65
@toolness toolness Regression test for #6. 3488d44
@toolness toolness only show help on things that we have help strings on. 1e34c19
Mike Kamermans updated slowparse with much better CSS error reporting, and source do…
…cumentation. still need to update the spec/unit tests
Mike Kamermans updated spec 6d251df

Should we mention something about the DOMBuilder and parseInfo property here, or just point them to the README?


Minor typo, untill -> until


Minor typo, HTLM -> HTML


Client code generally won't need the Stream class, but we do want to unit test it, which is why this was exposed... maybe we should expose a Slowparse._testing object off of which these kinds of things should be exposed?


Awesome. I wonder if we should use docco for these docs?


Hmm, the fact that you're not removing anything from token.interval.end suggests that this interval might contain extra whitespace...

Mike Kamermans and others added some commits
Mike Kamermans fixed up slowparse so that it passes unit tests, fixes in error messa…
…ges and spec to match
Mike Kamermans typo fixes 662ec47
@toolness toolness added some comments/docs to editor.js. fef7a7f
@toolness toolness Merge pull request #16 from Pomax/gh-pages
early pull request for updated slowparse/errors
@toolness toolness More documentation to slowparse.js. fbf5b8d
@toolness toolness ParseError now only takes a string, rather than a string or a parseIn…
…fo object.
@toolness toolness fix some errant 4-space indentation to be 2-space indentation. 73b2317
@toolness toolness Changed the comment docs up to (but not including) the Stream class t…
…o be more docco/literate-programming-friendly.
@toolness toolness docco-ified the Stream class. ca9621f
@toolness toolness docco-ified CSSParser. 363defa
@toolness toolness Removed unused CSSParser.currentRuleSet variable. 43881ca
Mike Kamermans css comment parsing, with comment block recording in the css parseInfo 6ff7150
Mike Kamermans rogue semi-color ba48425
@toolness toolness finished docco-ifying slowparse.js. 2e3b005
Mike Kamermans added css comment unit test db72f46
Mike Kamermans css comments unit test d9f137d
@toolness toolness Merge branch 'pomax-gh-pages' into gh-pages, docco-ified some of the …

@toolness toolness Merge branch 'pomax-gh-pages' into gh-pages 3adf705
@toolness toolness slightly better docs for CSSParser.stripComments() and Stream.eatCSSW…
@toolness toolness added two failing tests for CSS comments 0ef31d3
@toolness toolness removed one of the failing tests from my last commit, as it's not tru…
…ly a valid test.
Mike Kamermans bugfix for incorrect error signal on an empty declaration block that …
…is not 'empty' due to comments only
@toolness toolness Inlined HTMLParser._parseQuotedAttributeValue(), since it was only us…
…ed once and just made the code harder to understand.
@toolness toolness Rearranged the ordering of HTMLParser function definitions to make th…
…e workings of the class easier to understand.
@toolness toolness Merge branch 'pomax-gh-pages' into gh-pages e374617
@toolness toolness Enforced maximum column length of 79 characters. 1ae2c16
@toolness toolness added a failing test for an empty CSS sheet w/ a comment. 20f37d5
@toolness toolness Added an UNTERMINATED_CSS_COMMENT error type. a3e38db
@toolness toolness fixed broken CSS unit test and added another 'MISSING_CSS_SELECTOR wo…
…rks after comment' test.
@toolness toolness Added docco's 'docs' directory to .gitignore. 815fef5
@toolness toolness added link to docco source code in fd1f2f4
@toolness toolness added link to test suite in cf84a15
@toolness toolness added very basic publish/remix functionality courtesy of webpagemaker…
@toolness toolness added very rudimentary error messaging when publishing in editor. 05aef68
Mike Kamermans restyled editor page 3cb9fb8
Mike Kamermans made things work on IE, Chrome and Firefox 42a716c
Mike Kamermans IE specific CSS filter 8c3ffcc
@Pomax Pomax some fonts (google webfonts) and the publish button a6a5e81
@Pomax Pomax upstream gh-page sync e83b69a
@Pomax Pomax had the modal dialog in the wrong place 08991f8
@toolness toolness Merge pull request #19 from Pomax/gh-pages
restyled editor page
@Pomax Pomax added vendor prefix stripping for CSS 6974c70

Can you bust a unit test for this?


can do.

Pomax and others added some commits
@Pomax Pomax added unit test for vendor-prefix CSS 2f46919
@toolness toolness Merge pull request #22 from Pomax/gh-pages
fixed vendor prefix CSS being rejected
@toolness toolness Added .gitignore. 42e764a
@toolness toolness Merge branch 'gh-pages' of into gh-pages 4d702d8
@toolness toolness Added CLOSE_TAG_FOR_VOID_ELEMENT error type, which fixes #20. b703ad0
@toolness toolness Parsing of self-closing tags for void elements now works. Added SELF_…
…CLOSING_NON_VOID_ELEMENT error for the other tags. This fixes #23.
@toolness toolness changed comment to read nicer, especially in docco. 619e0f0
@toolness toolness added a link to my new blog post 'Learning and Grammatical Forgivenes…
…s' in the readme.
@toolness toolness The editor now only checks for HTML errors and refreshes the preview …
…300 milliseconds after the most recent user keypress. This is how etc. work and it's particularly helpful for making the app feel responsive. For our error reporting, it's also nice because it means that "errors" the user doesn't need to see won't be shown if they type fast enough, as the user is "correcting" their errors before Slowparse is called upon to evaluate the HTML.
@toolness toolness Added a plugin/extension called `noscript.slowparse.js` which adds a …
…`NoscriptDOMBuilder` class that can be used to pre-emptively warn the user that their JS won't be honored. It's not intended as a sanitizer--merely as a way to provide real-time feedback to users that their JS will be stripped.
@toolness toolness Parsing of HTML is now case-insensitive, and lowercased names of tags…
…/attrs are passed to DOMBuilder.
@toolness toolness changed test-noscript.js to use assertParseInfo(). e42fadf
@toolness toolness renamed assertParseInfo() to assertParseIntervals(), which is hopeful…
…ly less misleading.
@toolness toolness split out all the utility functions from test-slowparse.js into a sep…
…arate file, testing-utils.js.
@toolness toolness The editor now provides instant feedback to users when they try addin…
…g the most common forms of JavaScript to their page, and directs them to jsbin/jsfiddle if they really need JS support.
@toolness toolness Added a test to make sure that code in <script> tags isn't accidental…
…ly executed during parsing. (It's only executed if the generated document fragment is appended to the document.)
@Pomax Pomax added css 'src' property so that things like font-face don't break f12458c
@toolness toolness Merge pull request #26 from Pomax/gh-pages
this should fix @font-face failures
@toolness toolness use as the dev wpm backend. ea30180
@toolness toolness Replaced noscript.slowparse.js with tree-inspectors.js. The new libra…
…ry just contains utility functions for inspecting the DOM tree generated by slowparse, and has no hard dependencies on slowparse--clients of it, like the editor, can trivially use the .parseInfo property of nodes returned by an inspector to map back to the original source code if necessary.

This is nice because it means that Slowparse doesn't need to expose DOMBuilder; instead, the TreeWalkers use the DOM API to do everything they need.
U-MICHIELKAMECC18\Pomax comment parsing fix due to firefox rejecting createComment('--') and …
@toolness toolness Merge pull request #31 from Pomax/gh-pages
fix for "--" parsing in comments
@toolness toolness add regression test for #32. 7d61803
@toolness toolness Added a simple optional 'error detectors' argument to Slowparse.HTML …
…which allows some kinds of error detection to be optional.

Added TreeInspectors.forbidJS, which is	an error detector that reports when forbidden JS policies are violated.
@toolness toolness separated error-msgs.html out into errors.base.html and errors.forbid…
@toolness toolness changed /demo/ and /demo/spec.html to use errors.base.html. 32a23cd
@toolness toolness FORBIDJS errors are now in the spec. c4da82c
@toolness toolness replaced duplicate error loading/filling logic w/ a new file, errors.…
@toolness toolness more refactoring to reduce DRY violations in error highlighting code. 32f9e84
@toolness toolness pass templateSettings to _.template() instead of defining it globally. 111409e
@toolness toolness fixed minor cosmetic bugs in spec.html. ee7817d
@toolness toolness added a note about tree-inspectors.js to spec.html. ae0a243
@toolness toolness error name title in spec.html is now set to the expected error type r…
…ather than the real one.
@toolness toolness Removed demo, spec, and editor's dependency on underscore.js by embed…
…ding its template functionality in errors.jquery.js (as our error message logic is the only thing that requires templating).
@toolness toolness Moved the specification and its dependencies to the 'spec' directory.…
… Among other things, this makes the specification "production" code whose utility libraries, particularly errors.jquery.js, can be used by clients. (Everything in 'demo' is still experimental hacked-together stuff.)
@toolness toolness added docco docs to spec/errors.jquery.js and pointed to them from re…
@toolness toolness fixed broken link in spec, added links to annotated source code. 57c3bbe
@toolness toolness fixed old links to old location of spec. d2d40fe
@toolness toolness added better exception messages to jQuery.fn.fillError() and a test s…
…uite for errors.jquery.js.
@toolness toolness Added jQuery.errorTemplates and removed jQuery.loadMany(). jQuery.fn.…
…fillError() now takes an optional second argument.
@toolness toolness better error feedback for specification tests. They now also test to …
…make sure that each error spec has a friendly error message that executes properly.
@toolness toolness added more tests for errors.jquery.js. bcddab5
@toolness toolness test-spec.js now delegates all testing to the specification iframe on…
…ce it's done loading. Putting the test logic closer to the spec-generating code should help ensure that the two don't go out of sync, since the spec-generating code doesn't really have a public API that's expected to be maintained.
@toolness toolness now linking errors.jquery.js to its test suite. Improved readability …
…of docs a bit.
@toolness toolness rearranged order of errors.jquery.js to enhance readability. cba1fed
@toolness toolness Removed demo/editor, as it's now moved to… 891e479
@toolness toolness Added redirect page for editor. 5aba90f
@toolness toolness For unknown html tag/css property error messages, include a link to l…
…ists of HTML5 tags/CSS3 properties so users aren't left hanging.
@toolness toolness fixed a bug whereby would raise an exception at EOF 2621082
@Pomax Pomax added apostrophe-quoted attribute parsing to slowparse. Also deleted …
…an obsolete spec.html
@toolness toolness Use ES5 strict mode, which actually found two bugs that I fixed. a46b2bd
@Pomax Pomax Merge pull request #34 from Pomax/gh-pages
added ' parsing for attributes
@Pomax Pomax made a { li { ... fail correctly 75e4336
@Pomax Pomax changed px to em in test grouping CSS ceeb0b1
@Pomax Pomax typo O_O 1c4cdbe
@toolness toolness Merge pull request #35 from Pomax/gh-pages
made accidental css nesting detectable (a { p { ...)
@toolness toolness slowparse.js and tree-inspectors.js can now be loaded as RequireJS mo…
@toolness toolness Fixed #39. All tests now pass on IE9. 7f9e303
@davidascher davidascher adding MPL2 license 4d02181
@davidascher davidascher forgotten CSS files for MPL f3a0d8e
@Pomax Pomax made slowparse take note of HTML in CSS context, throwing a new HTML_…
@Pomax Pomax changed interval start/end marking in CSS context so that leading/tra…
…iling comments are not taken into account
@Pomax Pomax removed some commented dead code 81f3827

Note that this is a rare circumstance, but will need an issue filed for it if this is merged. I'm okay with incremental improvement here.


We might want to add a test that ensures that mixed SVG+HTML works ok, i.e. that the transition between HTML mode and SVG mode and back works.

We may also want to add a test that ensures that the DOM nodes created while in SVG mode have the SVG namespace.


closes #9 once landed

@toolness toolness was assigned

closing as out-of-date

@Pomax Pomax closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  test/test-slowparse.js
2  test/test-slowparse.js
@@ -262,7 +262,7 @@ test("testing inline CSS - ", function() {
testStyleSheet("parsing of CSS rule w/ one decl, no semicolon",
"body { color: pink }",
- function(html, css, styleContents) {
+ function(html, css, styleContents) {
equal(styleContents.parseInfo.rules.length, 1);
equal(styleContents.parseInfo.rules[0], 1);
Something went wrong with that request. Please try again.