Skip to content

Branch 0.11 - #887

Merged
Martin1887 merged 49 commits into
masterfrom
branch_0.11
May 15, 2024
Merged

Martin1887 merged 49 commits into
masterfrom
branch_0.11

Conversation

@Martin1887

Copy link
Copy Markdown
Collaborator

The development has been slowed down, so let's release the 0.11 version and leave description lists and #881 for the 0.12 version.

ollpu and others added 30 commits March 11, 2024 15:43
This feature is loosely based on what 63a29a1
described, but copies [commonmark-hs] more closely (the balanced braces
feature is added).

[commonmark-hs]: https://github.com/nschloe/github-math-bugs

It largely ignores GitHub, because its math parsing [is very buggy].

[is very buggy]: https://github.com/nschloe/github-math-bugs
This approach, based on @ollpu's suggestion, tracks single `$`s
in the inline tree, and merges them later. It avoids having
to merge and unmerge them in some corner cases.
The essential problem is: every time you write `$$x$}`, you get another
entry added to a hash table. Even if it's not [theoretically] *quadratic*,
it's still slow. Hard limiting it to 255 entries makes this not a problem.

Interestingly enough, when I tried to write an analogous torture test
for code spans, I couldn't find a way to do it because code spans are
keyed by their *length* instead of their *position*. In order to get
N entries in the hash table, I basically had to write N `` ` `` in a
row, forcing me to write quadratic amounts of input text.

Comparison:

```
michaelhowell@Michael-Howells-Macbook-Pro pulldown-cmark % python3 -c 'print("$$x$}"*5000)' | time target/release/pulldown-cmark.old -M > /dev/null
target/release/pulldown-cmark.old -M > /dev/null  2.63s user 0.02s system 99% cpu 2.673 total
michaelhowell@Michael-Howells-Macbook-Pro pulldown-cmark % python3 -c 'print("$$x$}"*5000)' | time target/release/pulldown-cmark.new -M > /dev/null
target/release/pulldown-cmark.new -M > /dev/null  0.01s user 0.00s system 6% cpu 0.109 total
```

[theoretically]: http://www.ilikebigbits.com/2014_04_21_myth_of_ram_1.html
Yet another Math implementation
- Disallow $$ matching a closing $ and then marching delimiters in
  `make_math_span`. Instead, retry scanning at the second position.

- Remove the `seen_first` optimization from `MathDelims`. It doesn't
  work with the retry strategy.
Co-authored-by: Michael Howell <[email protected]>
That would be ambiguous, because it can't easily be distinguished
between the block quote `>` and the end of an HTML tag `>`.
If this function bails out because it can't find an `=`, it should
point at the spot immedatiely after the attribute name instead.
@Martin1887
Martin1887 merged commit 57b6b3f into master May 15, 2024
@notriddle
notriddle deleted the branch_0.11 branch May 15, 2024 20:44
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.

5 participants