Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Work around a bug in the Markdown specification...

  • Loading branch information...
commit 3b11454aa195c1cc60ab36aaa87e30b9580d5592 1 parent 2d8de91
@xolox authored
Showing with 16 additions and 12 deletions.
  1. +3 −2 autoload/xolox/notes/markdown.vim
  2. +13 −10 autoload/xolox/notes/parser.vim
View
5 autoload/xolox/notes/markdown.vim
@@ -37,8 +37,9 @@ function! xolox#notes#markdown#convert_block(block) " {{{1
elseif a:block.type == 'heading'
return printf("%s %s", repeat('#', 1 + a:block.level), a:block.text)
elseif a:block.type == 'code'
- let text = xolox#misc#str#dedent(a:block.text)
- return xolox#misc#str#indent(text, 4)
+ let comment = "<!-- An innocent comment to force Markdown out of list parsing mode. See also http://meta.stackoverflow.com/a/99637 -->"
+ let text = xolox#misc#str#indent(xolox#misc#str#dedent(a:block.text), 4)
+ return join([comment, text], "\n\n")
elseif a:block.type == 'divider'
return '* * *'
elseif a:block.type == 'list'
View
23 autoload/xolox/notes/parser.vim
@@ -21,6 +21,7 @@ function! xolox#notes#parser#parse_note(text) " {{{1
elseif chr == '{' && context.peek(3) == "\{\{\{"
let block = s:parse_code_block(context)
else
+ call xolox#misc#msg#debug("notes.vim %s: Disambiguating list item from paragraph ..", g:xolox#notes#version)
let lookahead = s:match_bullet_or_divider(context, 0)
if !empty(lookahead)
if lookahead.type =~ 'list'
@@ -37,6 +38,7 @@ function! xolox#notes#parser#parse_note(text) " {{{1
endif
" Don't include empty blocks in the output.
if !empty(block)
+ call xolox#misc#msg#debug("notes.vim %s: Parsed block %s", g:xolox#notes#version, string(block))
call add(blocks, block)
endif
endwhile
@@ -215,17 +217,18 @@ function! s:parse_list(context) " {{{1
endif
endif
let line = s:match_line(a:context)
- if line[-1:] == "\n"
- call add(lines, line)
- elseif !empty(line)
- call add(lines, line)
- else
- " FIXME What happens when we find an empty line? Here's what:
- " 1. If the line after that starts without indentation, we found
- " the end of the list.
- " 2. If the line starts with indentation, we are dealing with a
- " list item that contains multiple paragraphs...
+ call add(lines, line)
+ if line[-1:] != "\n"
+ " XXX When match_line() returns a line that doesn't end in a newline
+ " character, it means either we hit the end of the input or the current
+ " line continues in a code block (which is not ours to parse :-).
+ break
endif
+ " FIXME What happens when we find an empty line? Here's what:
+ " 1. If the line after that starts without indentation, we found
+ " the end of the list.
+ " 2. If the line starts with indentation, we are dealing with a
+ " list item that contains multiple paragraphs...
endwhile
call s:save_item(items, lines, indent)
return {'type': 'list', 'ordered': (list_type == 'ordered-list'), 'items': items}
Please sign in to comment.
Something went wrong with that request. Please try again.