summaryrefslogtreecommitdiff
path: root/js/lib/inlines.js
AgeCommit message (Collapse)Author
2015-01-20Fixed escaping error in CDATA regex.John MacFarlane
Caught by sjs! This also improves performance measurably.
2015-01-18Changed rule for `_` emphasis and strong emphasis.John MacFarlane
To prevent intra-word emphasis, we used to check to see if the delimiter was followed/preceded by an ASCII alphanumeric. We now do something more elegant: whereas an opening `*` must be left-flanking, an opening `_` must be left-flanking *and not right-flanking*. And so on for the other cases. All the original tests passed except some tests with Russian text with internal `_`, which formerly created emphasis but no longer do with the new rule. These tests have been adjusted. A few new test cases have been added to illustrate the rule. The C and JS implementations have both been updated.
2015-01-15Provide getters and setters for public properties of Node.John MacFarlane
Everything else gets a name starting with an underscore and will be considered private. This will allow us to keep the API stable while changing the underlying data structure. And it will avoid exposing properties that have only an instrumental value in parsing.
2015-01-15Removed setType(), replaced getType() with type().John MacFarlane
2015-01-15Added getType(), setType() to node.js.John MacFarlane
Use these instead of direct property access. This is the first step in a general move towards an API like the one libcmark has. This will allow us to have a stable API that is independent of details of the AST.
2015-01-15Added normalize-reference.js.John MacFarlane
This does a proper unicode case fold instead of just using toUpperCase. It is also faster, partly because we can do one pass for space and case normalization. Modified from the NPM package fold-case; proper credit given in source and COPYING.
2015-01-12Moved "use strict" to top of modules.John MacFarlane
2015-01-11Factored out normalizeURI into a single function in common.js.John MacFarlane
This way we can change it without changing four separate places in the code.
2015-01-11Factored out unescapeString into new module, js/common.js.John MacFarlane
This is used in both blocks.js and inlines.js.
2015-01-11A few changes to JS so its xml matches cmark's.John MacFarlane
Always add '' as title property if title is not defined.
2015-01-10Another "test before replace" optimization.John MacFarlane
2015-01-10Removed unnec. comment.John MacFarlane
2015-01-10Regex optimizations in inlines.js.John MacFarlane
2015-01-09Moved more regexes into variables.John MacFarlane
2015-01-09Put backtick regexes in variables.John MacFarlane
2015-01-09JS linter improvements.John MacFarlane
2015-01-09Improved unescapeString performance.John MacFarlane
2015-01-09Improved newline parsing efficiency.John MacFarlane
Don't check for `\n` when we know we have one. Gobble spaces after line break.
2015-01-09JS: Renamed 'c' property to 'literal' to match libcmark.John MacFarlane
2015-01-09Comment fix.John MacFarlane
2015-01-09Simplified reMain for more performance gains.John MacFarlane
2015-01-09Simplified reMain, with AST manipulation for 2-space hardbreak.John MacFarlane
Small performance improvement.
2015-01-09More JS linter fixes.John MacFarlane
2015-01-09Use linked list instead of arrays for AST.John MacFarlane
Use the same doubly linked node structure that cmark uses. The primary advantages of this change are (a) simplified code, especially in the renderers, and (b) elimination of the need for recursion, so we can render deeply-nested structures without a stack overflow. A node walker has also been added, for easy AST traversal. * Added js/lib/node.js for nodes. Includes a node walker. * All modules updated to use node structures. * Regularized position information into pos property. * Performance is slightly worse than before, but only marginally, and no doubt there are more optimizations that can be done.
2015-01-07js: Use children rather than 'c' for Emph and Strong contents.John MacFarlane
Now we use 'children' uniformly, in both inlines and blocks, for child nodes.
2015-01-07js: Changed 'label' in Link, Image to 'children'.John MacFarlane
This matches the C impl. Also removed an unused property.
2015-01-03Fixed CDATA regex in js.John MacFarlane
Closes #267.
2015-01-03Improved js regex for html comments.John MacFarlane
Closes #263. Note, this only affects inline comments. With block comments we parse differently, and don't guarantee that only valid HTML5 comments will pass. This all needs to be made more explicit in the spec. However, this fix addresses the cpu problem.
2014-12-27Minor whitespace fixes.John MacFarlane
2014-12-27Fixed shadowing error.John MacFarlane
2014-12-25JS: fixed parsing of link-in-link-in-image.John MacFarlane
Partially addresses #252. Still need to: - update C parser. - put an example in the spec.
2014-12-25Fixed infinite loop in JS parser for link-in-link-in-image.John MacFarlane
Partially addresses #252. This fixes the infinite loop, and brings the JS parser into agreement with cmark, but both still have bad output in this case, so more work is needed.
2014-12-25Improved rules for emphasis and strong emphasis.John MacFarlane
This improves parsing of emphasis around punctuation. Background: http://talk.commonmark.org/t/emphasis-inside-strong-broken-in-js-implementation-when-parenthesis-involved/903/6 The basic idea of the change is that if the delimiter is part of a delimiter clump that has punctuation to the left and a normal character (non-space, non-punctuation) to the right, it can only be an opener. If it has punctuation to the right and a normal character (non-space, non-punctuation) to the left, it can only be a closer. This handles cases like **Gomphocarpus (*Gomphocarpus physocarpus*, syn. *Asclepias physocarpa*)** and **foo "*bar*" foo** better than before. The spec section on Emphasis and Strong Emphasis has been extensively revised. The C and JS implementations have been brought up to date, and all tests pass.
2014-12-10Further delinting efforts.John MacFarlane
2014-12-10More js delinting.John MacFarlane
2014-12-10More js delinting.John MacFarlane
2014-11-25Rename NODE_STRING -> NODE_TEXT.John MacFarlane
In JS, use 'Text' instead of 'Str'. In spec, use "plain textual content" instead of "strings."
2014-11-22Fixed #214 C and JS implementations.John MacFarlane
They were gobbling whitespace after shortcut reference links, e.g. [foo] bar [foo]: url Closes #214.
2014-11-10Allow images to contain images.John MacFarlane
2014-11-10jshint improvements.John MacFarlane
2014-11-10Stack-based link handling in js. All tests pass.John MacFarlane
2014-11-09Rewrote parseLink in js consistent with the C and spec.John MacFarlane
2014-11-09Added processEmphasis, run at end of parseInlines.John MacFarlane
2014-11-09Changed parseEmphasis to just put things on stack.John MacFarlane
2014-11-03Removed artificial rule for emph/strong markers.John MacFarlane
Previously there was a rule that nothing in a string of more than 3 `*` or `_` characters could close or start emphasis. This was artifical and led to strange asymmetries, e.g. you could have `*a *b**` emph within emph but not `**a **b****` strong within strong. The new parsing strategy makes it easy to remove this limitation. Spec, js, and c implementations have been updated. Spec might need some further grooming.
2014-10-24js: Removed memoization.John MacFarlane
It is no longer needed with the new stack-based emphasis parsing.
2014-10-24js: Use linked list instead of array for emphasis_openers stack.John MacFarlane
2014-10-24js: renamed emph_stack -> emphasis_openers.John MacFarlane
2014-10-23inlines.js: Implemented stack-based emph parsing.John MacFarlane
2014-10-18Add unescapeString as method of InlineParser.John MacFarlane