8000 fix: empty list line · segmentfault/HyperDown.js@56121c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 56121c9

Browse files
author
Ren Yubin
committed
fix: empty list line
1 parent deec412 commit 56121c9

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Parser.js

Lines changed: 7 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Parser.coffee

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ class Parser
406406
parseBlockList: (block, key, line, state) ->
407407
# list
408408
if (@isBlock 'list') and not line.match /^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/
409-
if (state.empty <= 1) and !!(matches = line.match /^(\s+)/) and matches[1].length > block[3]
409+
if (state.empty <= 1) and !!(matches = line.match /^(\s*)\S+/) and matches[1].length >= (block[3] + state.empty)
410410
state.empty = 0
411411
@setBlock key
412412
return no
@@ -972,7 +972,7 @@ class Parser
972972
if @line then '<hr class="line" data-start="' + start + '" data-end="' + start + '">' else '<hr>'
973973

974974

975-
parseNormal: (lines, inline = no, start) ->
975+
parseNormal: (lines, inline, start) ->
976976
key = 0
977977
lines = lines.map (line) =>
978978
line = @parseInline line
@@ -984,7 +984,9 @@ class Parser
984984
line
985985

986986
str = trim lines.join "\n"
987-
str = str.replace /(\n\s*){2,}/g, '</p><p>'
987+
str = str.replace /(\n\s*){2,}/g, () =>
988+
inline = false
989+
'</p><p>'
988990
str = str.replace /\n/g, '<br>'
989991

990992
if str.match /^\s*$/ then '' else (if inline then str else "<p>#{str}</p>")

0 commit comments

Comments
 (0)
0