fixes #1006
This commit is contained in:
@@ -35,6 +35,13 @@ div.prose {
|
|||||||
li {
|
li {
|
||||||
list-style-type: disc;
|
list-style-type: disc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pre {
|
||||||
|
font-family: monospace;
|
||||||
|
margin: 1em 0;
|
||||||
|
padding: 1em 2em;
|
||||||
|
background: #eee;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
div.dtext-preview {
|
div.dtext-preview {
|
||||||
|
|||||||
@@ -132,6 +132,7 @@ class DText
|
|||||||
str.strip!
|
str.strip!
|
||||||
blocks = str.split(/(?:\r?\n){2}/)
|
blocks = str.split(/(?:\r?\n){2}/)
|
||||||
stack = []
|
stack = []
|
||||||
|
flags = {}
|
||||||
|
|
||||||
html = blocks.map do |block|
|
html = blocks.map do |block|
|
||||||
case block
|
case block
|
||||||
@@ -167,9 +168,11 @@ class DText
|
|||||||
end
|
end
|
||||||
|
|
||||||
when /\[code\](?!\])/
|
when /\[code\](?!\])/
|
||||||
|
flags[:code] = true
|
||||||
'<pre>'
|
'<pre>'
|
||||||
|
|
||||||
when /\[\/code\](?!\])/
|
when /\[\/code\](?!\])/
|
||||||
|
flags[:code] = false
|
||||||
'</pre>'
|
'</pre>'
|
||||||
|
|
||||||
when /\[spoilers?\](?!\])/
|
when /\[spoilers?\](?!\])/
|
||||||
@@ -183,7 +186,11 @@ class DText
|
|||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
'<p>' + parse_inline(block) + "</p>"
|
if flags[:code]
|
||||||
|
block
|
||||||
|
else
|
||||||
|
'<p>' + parse_inline(block) + '</p>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -192,6 +199,8 @@ class DText
|
|||||||
html << "</blockquote>"
|
html << "</blockquote>"
|
||||||
elsif tag == "div"
|
elsif tag == "div"
|
||||||
html << "</div>"
|
html << "</div>"
|
||||||
|
elsif tag == "pre"
|
||||||
|
html << "</pre>"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user