Skip to content

Commit

Permalink
⬆️ Update: Sync with markdown-it v12.1.0 and CommonMark v0.30 (#168)
Browse files Browse the repository at this point in the history
A port of markdown-it/markdown-it@df4607f...13cdeb9:

- Update CommonMark spec to 0.30
- Fix emphasis algorithm as per 0.30 spec
- Update HMTL_SEQUENCES regexes as per CM 0.30 spec
  • Loading branch information
hukkin authored Aug 17, 2021
1 parent 1d27af1 commit 42e5732
Show file tree
Hide file tree
Showing 11 changed files with 7,054 additions and 6,890 deletions.
6 changes: 3 additions & 3 deletions markdown_it/port.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- package: markdown-it/markdown-it
version: 12.0.6
commit: df4607f1d4d4be7fdc32e71c04109aea8cc373fa
date: Apr 16, 2021
version: 12.1.0
commit: 13cdeb95abccc78a5ce17acf9f6e8cf5b9ce713b
date: Jul 1, 2021
notes:
- Rename variables that use python built-in names, e.g.
- `max` -> `maximum`
Expand Down
4 changes: 2 additions & 2 deletions markdown_it/rules_block/html_block.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# last argument defines whether it can terminate a paragraph or not
HTML_SEQUENCES: List[Tuple[Pattern, Pattern, bool]] = [
(
re.compile(r"^<(script|pre|style)(?=(\s|>|$))", re.IGNORECASE),
re.compile(r"<\/(script|pre|style)>", re.IGNORECASE),
re.compile(r"^<(script|pre|style|textarea)(?=(\s|>|$))", re.IGNORECASE),
re.compile(r"<\/(script|pre|style|textarea)>", re.IGNORECASE),
True,
),
(re.compile(r"^<!--"), re.compile(r"-->"), True),
Expand Down
14 changes: 10 additions & 4 deletions markdown_it/rules_inline/balance_pairs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,15 @@ def processDelimiters(state: StateInline, delimiters, *args):
continue

# Previously calculated lower bounds (previous fails)
# for each marker and each delimiter length modulo 3.
# for each marker, each delimiter length modulo 3,
# and for whether this closer can be an opener;
# https://github.com/commonmark/cmark/commit/34250e12ccebdc6372b8b49c44fab57c72443460
if closer.marker not in openersBottom:
openersBottom[closer.marker] = [-1, -1, -1]
openersBottom[closer.marker] = [-1, -1, -1, -1, -1, -1]

minOpenerIdx = openersBottom[closer.marker][closer.length % 3]
minOpenerIdx = openersBottom[closer.marker][
(3 if closer.open else 0) + (closer.length % 3)
]

openerIdx = closerIdx - closer.jump - 1

Expand Down Expand Up @@ -89,7 +93,9 @@ def processDelimiters(state: StateInline, delimiters, *args):
# See details here:
# https:#github.com/commonmark/cmark/issues/178#issuecomment-270417442
#
openersBottom[closer.marker][(closer.length or 0) % 3] = newMinOpenerIdx
openersBottom[closer.marker][
(3 if closer.open else 0) + ((closer.length or 0) % 3)
] = newMinOpenerIdx

closerIdx += 1

Expand Down
Loading

0 comments on commit 42e5732

Please sign in to comment.