Hide Equations From WikiChunk Processing
WikiWord (and the like) could wreak havoc in equations. Protect them (the way <a>, <pre> and <code> blocks are protected). For some reason, this doesn't seem to work in inline equations. Maruku is doing something funny there ... => one failing Unit Test.
This commit is contained in:
parent
4936bea13f
commit
074711d4c5
3 changed files with 55 additions and 3 deletions
|
@ -17,7 +17,7 @@ module Literal
|
|||
|
||||
# A literal chunk that protects 'code' and 'pre' tags from wiki rendering.
|
||||
class Pre < AbstractLiteral
|
||||
PRE_BLOCKS = "a|pre|code"
|
||||
PRE_BLOCKS = "a|pre|code|math"
|
||||
PRE_PATTERN = Regexp.new('<('+PRE_BLOCKS+')\b[^>]*?>.*?</\1>', Regexp::MULTILINE)
|
||||
def self.pattern() PRE_PATTERN end
|
||||
end
|
||||
|
@ -27,4 +27,13 @@ module Literal
|
|||
TAGS_PATTERN = Regexp.new('<[-a-zA-Z]+[^>]*?>', Regexp::MULTILINE)
|
||||
def self.pattern() TAGS_PATTERN end
|
||||
end
|
||||
|
||||
# A literal chunk that protects equations from wiki rendering.
|
||||
class Math < AbstractLiteral
|
||||
MATH_START = '(\${1,2}|' + Regexp.escape('\[') + '|\\begin\{equation\})'
|
||||
MATH_END = '(\${1,2}|' + Regexp.escape('\]') + '|\\end\{equation\})'
|
||||
MATH_PATTERN = Regexp.new(MATH_START + '([^$]|\\\$)+?' + MATH_END, Regexp::MULTILINE)
|
||||
def self.pattern() MATH_PATTERN end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue