From: Jean Privat Date: Wed, 19 Nov 2014 04:43:11 +0000 (-0500) Subject: docdown: read simple fence tag (type) X-Git-Tag: v0.6.11~5^2~9 X-Git-Url: http://nitlanguage.org docdown: read simple fence tag (type) Signed-off-by: Jean Privat --- diff --git a/src/docdown.nit b/src/docdown.nit index 7df46fe..42c48c3 100644 --- a/src/docdown.nit +++ b/src/docdown.nit @@ -30,6 +30,9 @@ private class Doc2Mdwn # Count empty lines between code blocks var empty_lines = 0 + # Optional tag for a fence + var fence_tag = "" + fun work(mdoc: MDoc): HTMLTag do var root = new HTMLTag("div") @@ -77,6 +80,7 @@ private class Doc2Mdwn empty_lines = 0 # to allows 4 spaces including the one that follows the # curblock.add(text) + fence_tag = "" continue end @@ -88,6 +92,8 @@ private class Doc2Mdwn var l = 3 while l < text.length and text.chars[l] == '~' do l += 1 in_fence = text.substring(0, l) + while l < text.length and (text.chars[l] == '.' or text.chars[l] == ' ') do l += 1 + fence_tag = text.substring_from(l) continue end @@ -187,7 +193,7 @@ private class Doc2Mdwn # Code part var n2 = new HTMLTag("code") n.add(n2) - process_code(n2, part) + process_code(n2, part, null) end is_text = not is_text end @@ -222,12 +228,12 @@ private class Doc2Mdwn # add the node var n = new HTMLTag("pre") root.add(n) - process_code(n, btext.to_s) + process_code(n, btext.to_s, fence_tag) curblock.clear end end - fun process_code(n: HTMLTag, text: String) + fun process_code(n: HTMLTag, text: String, tag: nullable String) do # Try to parse it var ast = toolcontext.parse_something(text) diff --git a/src/testing/testing_doc.nit b/src/testing/testing_doc.nit index e612902..86466bf 100644 --- a/src/testing/testing_doc.nit +++ b/src/testing/testing_doc.nit @@ -34,7 +34,7 @@ class NitUnitExecutor # All blocks of code from a same `ADoc` var blocks = new Array[Array[String]] - redef fun process_code(n: HTMLTag, text: String) + redef fun process_code(n: HTMLTag, text: String, tag: nullable String) do # Skip non-blocks if n.tag != "pre" then return