all repos — grayfriday @ 924064f3f74abc6c42e8e7a5fb49e6cc90102109

blackfriday fork with a few changes

Also support header IDs in ## headers ##
Dave Johnston johnsto@gmail.com
Sun, 06 Apr 2014 10:30:40 +0100
commit

924064f3f74abc6c42e8e7a5fb49e6cc90102109

parent

7ad5f9c1197c54c0be24fb0b0b1d75eb7ef19d89

2 files changed, 12 insertions(+), 1 deletions(-)

jump to
M block.goblock.go

@@ -189,14 +189,19 @@ skip := end

id := "" if p.flags&EXTENSION_HEADER_IDS != 0 { j, k := 0, 0 - for j = i; j < end - 1 && data[j] != '{' && data[j+1] != '#'; j++ { + // find start/end of header id + for j = i; j < end - 1 && (data[j] != '{' || data[j+1] != '#'); j++ { } for k = j + 1; k < end && data[k] != '}'; k++ { } + // extract header id iff found if j < end && k < end { id = string(data[j+2:k]) end = j skip = k + 1 + for end > 0 && data[end-1] == ' ' { + end-- + } } } for end > 0 && data[end-1] == '#' {
M block_test.goblock_test.go

@@ -215,6 +215,12 @@

"####### Header 7 {#someid}\n", "<h6 id=\"someid\"># Header 7</h6>\n", + "# Header 1 # {#someid}\n", + "<h1 id=\"someid\">Header 1</h1>\n", + + "## Header 2 ## {#someid}\n", + "<h2 id=\"someid\">Header 2</h2>\n", + "Hello\n# Header 1\nGoodbye\n", "<p>Hello</p>\n\n<h1>Header 1</h1>\n\n<p>Goodbye</p>\n",