Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to commonmark spec 0.29 #156

Merged
merged 22 commits into from
Jul 12, 2019
Merged

Update to commonmark spec 0.29 #156

merged 22 commits into from
Jul 12, 2019

Conversation

robinst
Copy link
Collaborator

@robinst robinst commented Jul 12, 2019

This was a larger one because of the change in link reference definitions, see commonmark/commonmark-spec#395. I also cleaned up parsing of definitions to avoid parsing them twice. We can now also add them as nodes to the document, which is nice.

Fixes #152.

robinst added 22 commits April 12, 2019 17:59
* Allow spaces inside link destinations in pointy brackets
* Disallow link destination beginning with `<` unless it is inside `<..>`
The spec was updated to clarify that they can also be part of setext
headings. The way we make these work in our parser is to be able to
"replace" the active paragraph block. In that case, we still need to
collect link reference definitions from it.

In order to implement this, I had to separate it from InlineParser. The
new way is cleaner, and allows us to add a Node to the document as well
(for #98).

I think there's still room for improvement: We could parse the
definition as we go in ParagraphParser and collect them earlier. That
might eliminate the current "double parsing" that we do in some cases.
Hopefully this will allow us to reuse it for parsing link reference
definitions in an incremental way.

Also speeds up parsing a bit:

-SpecBenchmark.parseExamples            thrpt   50  453.493 ± 4.647  ops/s
+SpecBenchmark.parseExamples            thrpt   50  483.467 ± 3.418  ops/s
The old code would parse link reference definitions twice in the worst
case. The new one parses it as part of paragraph parsing.

Looks like this is faster too:

-SpecBenchmark.parseExamples            thrpt   50  485.743 ± 1.864  ops/s
+SpecBenchmark.parseExamples            thrpt   50  550.071 ± 8.638  ops/s

-SpecBenchmark.parseWholeSpec           thrpt   50  284.494 ± 2.641  ops/s
+SpecBenchmark.parseWholeSpec           thrpt   50  297.277 ± 3.272  ops/s
See commonmark/commonmark.js@c89b35c

Also replaced the regex for escaping with a loop, which speeds up HTML
rendering:

-SpecBenchmark.parseAndRenderExamples   thrpt   50  344.820 ± 1.215  ops/s
+SpecBenchmark.parseAndRenderExamples   thrpt   50  374.342 ± 2.445  ops/s

-SpecBenchmark.parseAndRenderWholeSpec  thrpt   50  151.209 ± 1.148  ops/s
+SpecBenchmark.parseAndRenderWholeSpec  thrpt   50  198.357 ± 2.601  ops/s

(Note that these benchmarks include parsing, so rendering itself saw a
very nice improvement.)
@robinst robinst merged commit 813dae3 into master Jul 12, 2019
/**
* Parser for inline references
*/
public interface ReferenceParser {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI @lalunamel this has been removed (to be released). It shouldn't really impact you, but just a heads up.

@robinst robinst deleted the issue-152-commonmark-0.29 branch July 16, 2019 01:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update to CommonMark spec 0.29
1 participant