Skip to content

Commit a6932ea

Browse files
committed
fix list + pre
1 parent 5056612 commit a6932ea

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Parser.js

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
},
88
"license": "BSD-4-Clause",
99
"author": "SegmentFault",
10-
"version": "2.4.14",
10+
"version": "2.4.15",
1111
"scripts": {
1212
"test": "mocha",
1313
"build": "cake build"

src/Parser.coffee

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,17 +417,18 @@ class Parser
417417

418418
if !!(matches = line.match /^(\s*)((?:[0-9]+\.)|\-|\+|\*)\s+/i)
419419
space = matches[1].length
420+
tab = matches[0].length - space
420421
state.empty = 0
421422
type = if 0 <= '+-*'.indexOf matches[2] then 'ul' else 'ol'
422423

423424
# opened
424425
if @isBlock 'list'
425426
if space < block[3][0] or (space == block[3][0] and type != block[3][1])
426-
@startBlock 'list', key, [space, type]
427+
@startBlock 'list', key, [space, type, tab]
427428
else
428429
@setBlock key
429430
else
430-
@startBlock 'list', key, [space, type]
431+
@startBlock 'list', key, [space, type, tab]
431432

432433
return no
433434

@@ -832,7 +833,7 @@ class Parser
832833

833834
parseList: (lines, value, start) ->
834835
html = ''
835-
[space, type] = value
836+
[space, type, tab] = value
836837
rows = []
837838
suffix = ''
838839
last = 0
@@ -847,7 +848,7 @@ class Parser
847848
rows.push [matches[4]]
848849
last = rows.length - 1
849850
else
850-
rows[last].push line.replace (new RegExp "^\\s{#{space}}"), ''
851+
rows[last].push line.replace (new RegExp "^\\s{#{tab + space}}"), ''
851852

852853
for row in rows
853854
html += '<li>' + (@parse (row.join "\n"), yes, start) + '</li>'

0 commit comments

Comments
 (0)