nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
version 0.7.4
[nit.git]
/
src
/
docdown.nit
diff --git
a/src/docdown.nit
b/src/docdown.nit
index
7df46fe
..
08a776e
100644
(file)
--- 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
# 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")
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)
empty_lines = 0
# to allows 4 spaces including the one that follows the #
curblock.add(text)
+ fence_tag = ""
continue
end
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)
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
continue
end
@@
-187,7
+193,7
@@
private class Doc2Mdwn
# Code part
var n2 = new HTMLTag("code")
n.add(n2)
# 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
end
is_text = not is_text
end
@@
-222,13
+228,20
@@
private class Doc2Mdwn
# add the node
var n = new HTMLTag("pre")
root.add(n)
# 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
curblock.clear
end
end
- fun process_code(n: HTMLTag, text: String)
+ fun process_code(n: HTMLTag, text: String, tag: nullable String)
do
do
+ # Do not try to highlight non-nit code.
+ if tag != null and tag != "" and tag != "nit" and tag != "nitish" then
+ n.append text
+ n.add_class("rawcode")
+ return
+ end
+
# Try to parse it
var ast = toolcontext.parse_something(text)
# Try to parse it
var ast = toolcontext.parse_something(text)