Skip to content

Commit 8893346

Browse files
committed
🐛 FIX: Crash when file ends with empty blockquote line
1 parent 465b54d commit 8893346

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

markdown_it/rules_block/blockquote.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,21 @@ def blockquote(state: StateBlock, startLine: int, endLine: int, silent: bool):
154154
# set offset past spaces and ">"
155155
initial = offset = state.sCount[nextLine] + 1
156156

157+
try:
158+
next_char: Optional[int] = state.srcCharCode[pos]
159+
except IndexError:
160+
next_char = None
161+
157162
# skip one optional space after '>'
158-
if state.srcCharCode[pos] == 0x20: # /* space */
163+
if next_char == 0x20: # /* space */
159164
# ' > test '
160165
# ^ -- position start of line here:
161166
pos += 1
162167
initial += 1
163168
offset += 1
164169
adjustTab = False
165170
spaceAfterMarker = True
166-
elif state.srcCharCode[pos] == 0x09: # /* tab */
171+
elif next_char == 0x09: # /* tab */
167172
spaceAfterMarker = True
168173

169174
if (state.bsCount[nextLine] + offset) % 4 == 3:

tests/test_port/test_no_end_newline.py

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
("p", "<p>p</p>\n"),
1919
("[reference]: /url", ""),
2020
(" indented code block", "<pre><code>indented code block\n</code></pre>\n"),
21+
("> test\n>", "<blockquote>\n<p>test</p>\n</blockquote>\n"),
2122
],
2223
)
2324
def test_no_end_newline(input, expected):

0 commit comments

Comments
 (0)