Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Inline style parsing #49

Closed
wants to merge 235 commits into from

3 participants

@Pomax
Owner

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.
5994d70
@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.
66a2477
@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 stream.eat() 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.
d42edb8
@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.
c0b38a9
@toolness toolness fixed a ParseError bug and added decent feedback for the MISMATCHED_C…
…LOSE_TAG error in the demo.
2d29c0d
@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.
d96f4c6
@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.
28fc877
@toolness toolness tag name of ParseErrors is retrieved via e.g. error.openTag.name inst…
…ead of error.openTagName.
54beec1
@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.
3ab14c5
@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.
9b4b66b
@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.
08f506d
@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.
42ead14
@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.
1f12afc
@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.
2441347
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…
…tion.
de78632
@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.

Conflicts:
	demo/index.html
	slowparse.js
	test/index.html
33e0a36
Mike Kamermans added HTML element knowledge, changed the gobbling for tagnames to \w…
…\d rather than \w to accomodate h1...h6
399d02d
@toolness toolness Merge pull request #2 from Pomax/gh-pages
html updates
8ec8f29
Mike Kamermans turned CSS errors into nice errors 6a3f63c
@toolness toolness Merge branch 'gh-pages' of https://github.com/Pomax/slowparse into gh…
…-pages
81ec4ff
@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.
f291492
@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'.
3b0cb4d
@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.
ce8d84f
@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.
1532963
@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.
81684b7
@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.
bf56f43
@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.
7c0fc17
@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
9f33216
Mike Kamermans updated spec 6d251df
@toolness

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

@toolness

Minor typo, untill -> until

@toolness

Minor typo, HTLM -> HTML

@toolness

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?

@toolness
Owner

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

@toolness

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
03b9bfc
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
3695ce0
@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.
80131f8
@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.
5b3ccb0
@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 …
…comments.

Conflicts:
	slowparse.js
22419e2
@toolness toolness Merge branch 'pomax-gh-pages' into gh-pages 3adf705
@toolness toolness slightly better docs for CSSParser.stripComments() and Stream.eatCSSW…
…hile().
b17fdcd
@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.
a61d720
Mike Kamermans bugfix for incorrect error signal on an empty declaration block that …
…is not 'empty' due to comments only
c094366
@toolness toolness Inlined HTMLParser._parseQuotedAttributeValue(), since it was only us…
…ed once and just made the code harder to understand.
0962ff4
@toolness toolness Rearranged the ordering of HTMLParser function definitions to make th…
…e workings of the class easier to understand.
7df7ccb
@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.
f0bab7c
@toolness toolness Added docco's 'docs' directory to .gitignore. 815fef5
@toolness toolness added link to docco source code in README.md. fd1f2f4
@toolness toolness added link to test suite in README.md. cf84a15
@toolness toolness added very basic publish/remix functionality courtesy of webpagemaker…
…api.vcap.mozillalabs.com.
e68decd
@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
5ec7a4c
@Pomax Pomax added vendor prefix stripping for CSS 6974c70
@toolness
Owner

Can you bust a unit test for this?

Owner

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
c46a834
@toolness toolness Added .gitignore. 42e764a
@toolness toolness Merge branch 'gh-pages' of github.com:toolness/slowparse 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.
83034bf
@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.
6aa1184
@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 lovebomb.me 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.
a57cfae
@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.
01a2cef
@toolness toolness Parsing of HTML is now case-insensitive, and lowercased names of tags…
…/attrs are passed to DOMBuilder.
86dda42
@toolness toolness changed test-noscript.js to use assertParseInfo(). e42fadf
@toolness toolness renamed assertParseInfo() to assertParseIntervals(), which is hopeful…
…ly less misleading.
b8ac4fc
@toolness toolness split out all the utility functions from test-slowparse.js into a sep…
…arate file, testing-utils.js.
0b227c0
@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.
2b4f2c9
@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.)
42f09b6
@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
1d9f53e
@toolness toolness use wpm.toolness.org 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.
155cc6d
U-MICHIELKAMECC18\Pomax comment parsing fix due to firefox rejecting createComment('--') and …
…variations
e80f1af
@toolness toolness Merge pull request #31 from Pomax/gh-pages
fix for "--" parsing in comments
854f911
@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.
445761d
@toolness toolness separated error-msgs.html out into errors.base.html and errors.forbid…
…js.html.
2f585da
@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.…
…jquery.js.
97efb0b
@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.
60db7fb
@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).
a24f98c
@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.)
fde44c1
@toolness toolness added docco docs to spec/errors.jquery.js and pointed to them from re…
…adme.
d7bbb3f
@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.
90e4281
@toolness toolness Added jQuery.errorTemplates and removed jQuery.loadMany(). jQuery.fn.…
…fillError() now takes an optional second argument.
16a74c1
@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.
50c688c
@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.
4b4ab5d
@toolness toolness now linking errors.jquery.js to its test suite. Improved readability …
…of docs a bit.
379f892
@toolness toolness rearranged order of errors.jquery.js to enhance readability. cba1fed
@toolness toolness Removed demo/editor, as it's now moved to https://github.com/toolness… 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.
217cd76
@toolness toolness fixed a bug whereby Stream.eat() would raise an exception at EOF 2621082
@Pomax Pomax added apostrophe-quoted attribute parsing to slowparse. Also deleted …
…an obsolete spec.html
c1599e4
@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
27bf788
@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 { ...)
abd9cc1
@toolness toolness slowparse.js and tree-inspectors.js can now be loaded as RequireJS mo…
…dules.
538dbb4
@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_…
…CODE_IN_CSS_BLOCK error
e0a7fe1
@Pomax Pomax changed interval start/end marking in CSS context so that leading/tra…
…iling comments are not taken into account
415a8a6
@Pomax Pomax removed some commented dead code 81f3827
@Pomax

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.

@toolness
Owner

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.

@Pomax
Owner

closes #9 once landed

@toolness toolness was assigned
@Pomax
Owner

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].declarations.properties.length, 1);
Something went wrong with that request. Please try again.