sometimes i dream about parsing markdown according to guidelines
This commit is contained in:
parent
765680f2d8
commit
4245e18192
26
document.rb
26
document.rb
|
@ -200,7 +200,7 @@ module RBMark
|
||||||
|
|
||||||
# Inline preformatted text
|
# Inline preformatted text
|
||||||
class InlinePre < DOMObject
|
class InlinePre < DOMObject
|
||||||
self.begin = /`(?!`)/
|
self.begin = /(?<!\\)`(?!`)/
|
||||||
self.end = /`.+?`/
|
self.end = /`.+?`/
|
||||||
|
|
||||||
# Stub parser for inline text element
|
# Stub parser for inline text element
|
||||||
|
@ -250,7 +250,7 @@ module RBMark
|
||||||
|
|
||||||
# Bold text
|
# Bold text
|
||||||
class InlineBold < InlineFormattable
|
class InlineBold < InlineFormattable
|
||||||
self.begin = /\*\*(?!\*\*)/
|
self.begin = /(?<!\\)\*\*(?!\*\*)/
|
||||||
self.end = /\*\*.+?\*\*/
|
self.end = /\*\*.+?\*\*/
|
||||||
|
|
||||||
# (see ::RBMark::DOM::DOMObject.parse)
|
# (see ::RBMark::DOM::DOMObject.parse)
|
||||||
|
@ -261,7 +261,7 @@ module RBMark
|
||||||
|
|
||||||
# Italics text
|
# Italics text
|
||||||
class InlineItalics < InlineFormattable
|
class InlineItalics < InlineFormattable
|
||||||
self.begin = /\*(?!\*)/
|
self.begin = /(?<!\\)\*(?!\*)/
|
||||||
self.end = /\*.+?\*/
|
self.end = /\*.+?\*/
|
||||||
|
|
||||||
# (see ::RBMark::DOM::DOMObject.parse)
|
# (see ::RBMark::DOM::DOMObject.parse)
|
||||||
|
@ -270,9 +270,21 @@ module RBMark
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Inline italics text (alternative)
|
||||||
|
class InlineAltItalics < InlineFormattable
|
||||||
|
self.begin = /(?<!\\)_(?!_)/
|
||||||
|
self.end = /_.+?_/
|
||||||
|
self.alt_for = ::RBMark::DOM::InlineItalics
|
||||||
|
|
||||||
|
# (see ::RBMark::DOM::DOMObject.parse)
|
||||||
|
def self.parse(text)
|
||||||
|
super(text[1..-2])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Underline text
|
# Underline text
|
||||||
class InlineUnder < InlineFormattable
|
class InlineUnder < InlineFormattable
|
||||||
self.begin = /__(?!__)/
|
self.begin = /(?<!\\)__(?!__)/
|
||||||
self.end = /__.+?__/
|
self.end = /__.+?__/
|
||||||
|
|
||||||
# (see ::RBMark::DOM::DOMObject.parse)
|
# (see ::RBMark::DOM::DOMObject.parse)
|
||||||
|
@ -283,7 +295,7 @@ module RBMark
|
||||||
|
|
||||||
# Strikethrough text
|
# Strikethrough text
|
||||||
class InlineStrike < InlineFormattable
|
class InlineStrike < InlineFormattable
|
||||||
self.begin = /~~(?!~~)/
|
self.begin = /(?<!\\)~~(?!~~)/
|
||||||
self.end = /~~.+?~~/
|
self.end = /~~.+?~~/
|
||||||
|
|
||||||
# (see ::RBMark::DOM::DOMObject.parse)
|
# (see ::RBMark::DOM::DOMObject.parse)
|
||||||
|
@ -294,7 +306,7 @@ module RBMark
|
||||||
|
|
||||||
# Hyperreferenced text
|
# Hyperreferenced text
|
||||||
class InlineLink < InlineFormattable
|
class InlineLink < InlineFormattable
|
||||||
self.begin = /(?<!!)\[[^\]]+?\]\([^)]+?\)/
|
self.begin = /(?<![!\\])\[[^\]]+?\]\([^)]+?\)/
|
||||||
self.end = self.begin
|
self.end = self.begin
|
||||||
|
|
||||||
# (see ::RBMark::DOM::DOMObject.parse)
|
# (see ::RBMark::DOM::DOMObject.parse)
|
||||||
|
@ -308,7 +320,7 @@ module RBMark
|
||||||
|
|
||||||
# Image
|
# Image
|
||||||
class InlineImage < InlinePre
|
class InlineImage < InlinePre
|
||||||
self.begin = /!\[[^\]]+?\]\([^)]+?\)/
|
self.begin = /(?<!\\)!\[[^\]]+?\]\([^)]+?\)/
|
||||||
self.end = self.begin
|
self.end = self.begin
|
||||||
|
|
||||||
# (see ::RBMark::DOM::DOMObject.parse)
|
# (see ::RBMark::DOM::DOMObject.parse)
|
||||||
|
|
Loading…
Reference in New Issue