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
|
||||
class InlinePre < DOMObject
|
||||
self.begin = /`(?!`)/
|
||||
self.begin = /(?<!\\)`(?!`)/
|
||||
self.end = /`.+?`/
|
||||
|
||||
# Stub parser for inline text element
|
||||
|
@ -250,7 +250,7 @@ module RBMark
|
|||
|
||||
# Bold text
|
||||
class InlineBold < InlineFormattable
|
||||
self.begin = /\*\*(?!\*\*)/
|
||||
self.begin = /(?<!\\)\*\*(?!\*\*)/
|
||||
self.end = /\*\*.+?\*\*/
|
||||
|
||||
# (see ::RBMark::DOM::DOMObject.parse)
|
||||
|
@ -261,7 +261,7 @@ module RBMark
|
|||
|
||||
# Italics text
|
||||
class InlineItalics < InlineFormattable
|
||||
self.begin = /\*(?!\*)/
|
||||
self.begin = /(?<!\\)\*(?!\*)/
|
||||
self.end = /\*.+?\*/
|
||||
|
||||
# (see ::RBMark::DOM::DOMObject.parse)
|
||||
|
@ -270,9 +270,21 @@ module RBMark
|
|||
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
|
||||
class InlineUnder < InlineFormattable
|
||||
self.begin = /__(?!__)/
|
||||
self.begin = /(?<!\\)__(?!__)/
|
||||
self.end = /__.+?__/
|
||||
|
||||
# (see ::RBMark::DOM::DOMObject.parse)
|
||||
|
@ -283,7 +295,7 @@ module RBMark
|
|||
|
||||
# Strikethrough text
|
||||
class InlineStrike < InlineFormattable
|
||||
self.begin = /~~(?!~~)/
|
||||
self.begin = /(?<!\\)~~(?!~~)/
|
||||
self.end = /~~.+?~~/
|
||||
|
||||
# (see ::RBMark::DOM::DOMObject.parse)
|
||||
|
@ -294,7 +306,7 @@ module RBMark
|
|||
|
||||
# Hyperreferenced text
|
||||
class InlineLink < InlineFormattable
|
||||
self.begin = /(?<!!)\[[^\]]+?\]\([^)]+?\)/
|
||||
self.begin = /(?<![!\\])\[[^\]]+?\]\([^)]+?\)/
|
||||
self.end = self.begin
|
||||
|
||||
# (see ::RBMark::DOM::DOMObject.parse)
|
||||
|
@ -308,7 +320,7 @@ module RBMark
|
|||
|
||||
# Image
|
||||
class InlineImage < InlinePre
|
||||
self.begin = /!\[[^\]]+?\]\([^)]+?\)/
|
||||
self.begin = /(?<!\\)!\[[^\]]+?\]\([^)]+?\)/
|
||||
self.end = self.begin
|
||||
|
||||
# (see ::RBMark::DOM::DOMObject.parse)
|
||||
|
|
Loading…
Reference in New Issue