Skip to content

Update Swift fork of cmark with upstream cmark repository #8

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

Merged
merged 458 commits into from
Dec 6, 2018

Conversation

nkcsgexi
Copy link

@nkcsgexi nkcsgexi commented Dec 5, 2018

No description provided.

jgm and others added 30 commits June 22, 2016 22:29
We reuse the parser for reference labels, instead
of just assuming that a slice of the link text
will be a valid reference label.  (It might contain
interior brackets, for example.)
See commonmark/commonmark.js#101

This uses a separate stack for brackets, instead of
putting them on the delimiter stack.  This avoids the
need for looking through the delimiter stack for the next
bracket.

It also avoids a shortcut reference lookup when the reference
text contains brackets.

The change dramatically improved performance on the nested links
pathological test for commonmark.js.  It has a smaller but measurable
effect here.
This is too strict, as it prevents the use of dynamically
loaded extensions: see
commonmark#123 (comment).

Documented in man page and public header that one should use the same
memory allocator for every node in a tree.
It is no longer needed; only the brackets struct needs it.
Thanks to @robinst.
This will need corresponding spec changes.

The change is this:  when considering matches between an interior
delimiter run (one that can open and can close) and another delimiter
run, we require that the sum of the lengths of the two delimiter
runs mod 3 is not 0.

Thus, for example, in

    *a**b*
    1 23 4

delimiter 1 cannot match 2, since the sum of the lengths of
the first delimiter run (1) and the second (1,2) == 3.
Thus we get `<em>a**b</em>` instead of `<em>a</em><em>b</em>`.

This gives better behavior on things like

    *a**b**c*

which previously got parsed as

    <em>a</em><em>b</em><em>c</em>

and now would be parsed as

    <em>a<strong>b</strong>c</em>

With this change we get four spec test failures, but in each
case the output seems more "intuitive":

```
Example 386 (lines 6490-6494) Emphasis and strong emphasis
*foo**bar**baz*

--- expected HTML
+++ actual HTML
@@ -1 +1 @@
-<p><em>foo</em><em>bar</em><em>baz</em></p>
+<p><em>foo<strong>bar</strong>baz</em></p>

Example 389 (lines 6518-6522) Emphasis and strong emphasis
*foo**bar***

--- expected HTML
+++ actual HTML
@@ -1 +1 @@
-<p><em>foo</em><em>bar</em>**</p>
+<p><em>foo<strong>bar</strong></em></p>

Example 401 (lines 6620-6624) Emphasis and strong emphasis
**foo*bar*baz**

--- expected HTML
+++ actual HTML
@@ -1 +1 @@
-<p><em><em>foo</em>bar</em>baz**</p>
+<p><strong>foo<em>bar</em>baz</strong></p>

Example 442 (lines 6944-6948) Emphasis and strong emphasis
**foo*bar**

--- expected HTML
+++ actual HTML
@@ -1 +1 @@
-<p><em><em>foo</em>bar</em>*</p>
+<p><strong>foo*bar</strong></p>
```
This allows using them in other cmake projects.
It's possible that cmark_chunk_set_cstr is called with a substring
(suffix) of the current string. Delay freeing of the chunk content
to handle this case correctly.

Fixes issue commonmark#139.
Fix chunk_set_cstr with suffix of current string
instead of going through all the formats and options
and probably getting the same output.
@nkcsgexi
Copy link
Author

nkcsgexi commented Dec 5, 2018

@swift-ci please test

@nkcsgexi
Copy link
Author

nkcsgexi commented Dec 5, 2018

CC: @compnerd and @akyrtzi

@compnerd
Copy link
Member

compnerd commented Dec 5, 2018

Nice! Thanks for doing this. Does this also have the local patches that were applied to CMark? Or did those get upstream'ed?

@akyrtzi
Copy link

akyrtzi commented Dec 5, 2018

Are there swift-side changes needed ? If yes, we should have a corresponding PR specific for adopting cmark changes.

@nkcsgexi
Copy link
Author

nkcsgexi commented Dec 5, 2018

local patches that were applied to CMark

I need to manually resolve some merge conflict due to our local cmake patches. Maybe there are some local changes still there.

Are there swift-side changes needed ?

It doesn't seem to be. I ran Swift CI test with this patch and found only unrelated failures:
https://ci.swift.org/job/swift-PR-osx/9408/
https://ci.swift.org/job/swift-PR-Linux/9450/

@nkcsgexi
Copy link
Author

nkcsgexi commented Dec 5, 2018

@tkremenek could we take this merge with upstream repo?

@tkremenek
Copy link
Member

@nkcsgexi yes. We should decide what we want to do about swift-5.0-branch, however, as 5.0 is in convergence. For 5.0 we probably should not update with upstream cmark, but apply local fixes to swift-cmark.

@akyrtzi
Copy link

akyrtzi commented Dec 5, 2018

For 5.0 we probably should not update with upstream cmark, but apply local fixes to swift-cmark.

SGTM 👍

@nkcsgexi
Copy link
Author

nkcsgexi commented Dec 5, 2018

@tkremenek I agree. We should keep swift-5.0-branch stable for now.

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.