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

🐛 FIX: port markdown-it v11.0.1 #109

Merged
merged 3 commits into from Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion markdown_it/main.py
Expand Up @@ -225,7 +225,7 @@ def parse(self, src: str, env: Optional[AttrDict] = None) -> List[Token]:
:param src: source string
:param env: environment sandbox

Parse input string and returns list of block tokens (special token type
Parse input string and return list of block tokens (special token type
"inline" will contain list of inline tokens).

`env` is used to pass data between "distributed" rules and return additional
Expand Down
4 changes: 2 additions & 2 deletions markdown_it/port.yaml
@@ -1,6 +1,6 @@
- package: markdown-it/markdown-it
commit: f798bea9623277bbf89b9621cf7fb283c693fcab
date: Mar 12, 2020
commit: 331ae117e09115366db12b517ca526b1b7fee1e8
date: Sep 14, 2020
notes:
- Rename variables that use python built-in names, e.g.
- `max` -> `maximum`
Expand Down
22 changes: 6 additions & 16 deletions markdown_it/rules_block/blockquote.py
Expand Up @@ -32,12 +32,8 @@ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool):
if silent:
return True

# skip spaces after ">" and re-calculate offset
initial = offset = (
state.sCount[startLine]
+ pos
- (state.bMarks[startLine] + state.tShift[startLine])
)
# set offset past spaces and ">"
initial = offset = state.sCount[startLine] + 1

try:
second_char_code: Optional[int] = state.srcCharCode[pos]
Expand Down Expand Up @@ -109,7 +105,6 @@ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool):

oldParentType = state.parentType
state.parentType = "blockquote"
wasOutdented = False

# Search the end of the block
#
Expand Down Expand Up @@ -142,8 +137,7 @@ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool):
# > current blockquote
# 2. checking this line
# ```
if state.sCount[nextLine] < state.blkIndent:
wasOutdented = True
isOutdented = state.sCount[nextLine] < state.blkIndent

pos = state.bMarks[nextLine] + state.tShift[nextLine]
max = state.eMarks[nextLine]
Expand All @@ -152,17 +146,13 @@ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool):
# Case 1: line is not inside the blockquote, and this line is empty.
break

evaluatesTrue = state.srcCharCode[pos] == 0x3E and not wasOutdented # /* > */
evaluatesTrue = state.srcCharCode[pos] == 0x3E and not isOutdented # /* > */
pos += 1
if evaluatesTrue:
# This line is inside the blockquote.

# skip spaces after ">" and re-calculate offset
initial = offset = (
state.sCount[nextLine]
+ pos
- (state.bMarks[nextLine] + state.tShift[nextLine])
)
# set offset past spaces and ">"
initial = offset = state.sCount[nextLine] + 1

# skip one optional space after '>'
if state.srcCharCode[pos] == 0x20: # /* space */
Expand Down
2 changes: 2 additions & 0 deletions markdown_it/rules_block/table.py
Expand Up @@ -183,10 +183,12 @@ def table(state: StateBlock, startLine: int, endLine: int, silent: bool):
token = state.push("tr_open", "tr", 1)
for i in range(columnCount):
token = state.push("td_open", "td", 1)
token.map = [nextLine, nextLine + 1]
if aligns[i]:
token.attrs = [["style", "text-align:" + aligns[i]]]

token = state.push("inline", "", 0)
token.map = [nextLine, nextLine + 1]
try:
token.content = columns[i].strip() if columns[i] else ""
except IndexError:
Expand Down
2 changes: 1 addition & 1 deletion markdown_it/rules_inline/balance_pairs.py
Expand Up @@ -42,7 +42,7 @@ def processDelimiters(state: StateInline, delimiters, *args):
if newMinOpenerIdx == -1:
newMinOpenerIdx = openerIdx

if opener.open and opener.end < 0 and opener.level == closer.level:
if opener.open and opener.end < 0:

isOddMatch = False

Expand Down
50 changes: 50 additions & 0 deletions tests/test_port/fixtures/commonmark_extras.md
Expand Up @@ -522,3 +522,53 @@ Coverage, entities with code > 10FFFF. Made this way for compatibility with comm
<p>�</p>
<p>&amp;#x1100000;</p>
.

Issue #696. Blockquotes should remember their level.
.
>>> foo
bar
>>> baz
.
<blockquote>
<blockquote>
<blockquote>
<p>foo
bar
baz</p>
</blockquote>
</blockquote>
</blockquote>
.

Issue #696. Blockquotes should stop when outdented from a list.
.
1. >>> foo
bar
baz
>>> foo
>>> bar
>>> baz
.
<ol>
<li>
<blockquote>
<blockquote>
<blockquote>
<p>foo
bar
baz
foo</p>
</blockquote>
</blockquote>
</blockquote>
</li>
</ol>
<blockquote>
<blockquote>
<blockquote>
<p>bar
baz</p>
</blockquote>
</blockquote>
</blockquote>
.