sometimes i dream about parsing markdown according to guidelines

This commit is contained in:
Yessiest 2024-02-26 04:57:10 +04:00
parent 765680f2d8
commit 4245e18192
2 changed files with 22 additions and 7 deletions

View File

@ -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)

View File

@ -280,6 +280,9 @@ module MDPP
},
"RBMark::DOM::HorizontalRule" => {
"extra_newlines" => true
},
"RBMark::DOM::IndentBlock" => {
"indent" => true
}
}.freeze