Skip to content

Commit 4f43f20

Browse files
committed
fix code in list
1 parent e478039 commit 4f43f20

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed

Parser.js

Lines changed: 6 additions & 4 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.13",
10+
"version": "2.4.14",
1111
"scripts": {
1212
"test": "mocha",
1313
"build": "cake build"

src/Parser.coffee

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ class Parser
403403
parseBlockList: (block, key, line, state) ->
404404
# list
405405
if (@isBlock 'list') and not line.match /^\s*\[((?:[^\]]|\\\]|\\\[)+?)\]:\s*(.+)$/
406-
if (state.empty <= 1) and !!(matches = line.match /^(\s*)\S+/) and matches[1].length >= (block[3][0] + state.empty)
406+
if !!(line.match /^(\s*)(~{3,}|`{3,})([^`~]*)$/i)
407+
# ignore code
408+
return yes
409+
else if (state.empty <= 1) and !!(matches = line.match /^(\s*)\S+/) and matches[1].length >= (block[3][0] + state.empty)
407410
state.empty = 0
408411
@setBlock key
409412
return no
@@ -431,7 +434,7 @@ class Parser
431434
yes
432435

433436

434-
parseBlockCode: (block, key, line) ->
437+
parseBlockCode: (block, key, line, state) ->
435438
if !!(matches = line.match /^(\s*)(~{3,}|`{3,})([^`~]*)$/i)
436439
if @isBlock 'code'
437440
isAfterList = block[3][2]
@@ -444,9 +447,9 @@ class Parser
444447
isAfterList = no
445448

446449
if @isBlock 'list'
447-
space = block[3]
450+
space = block[3][0]
448451

449-
isAfterList = (space > 0 && matches[1].length >= space) || matches[1].length > space
452+
isAfterList = matches[1].length >= space + state.empty
450453

451454
@startBlock 'code', key, [matches[1], matches[3], isAfterList]
452455

0 commit comments

Comments
 (0)