more compatibility fixes

This commit is contained in:
Yessiest 2025-03-13 10:57:52 +04:00
parent 0c7be01e11
commit 4d4d8cfc4c
2 changed files with 18 additions and 16 deletions

View File

@ -1016,7 +1016,7 @@ module PointBlank
# @param before [String, ::PointBlank::DOM::DOMObject] # @param before [String, ::PointBlank::DOM::DOMObject]
# @param after [String, ::PointBlank::DOM::DOMObject] # @param after [String, ::PointBlank::DOM::DOMObject]
# @return [Array<Array(String, Class, Symbol), String>] # @return [Array<Array(String, Class, Symbol), String>]
def self.tokenize(string, before, after) def self.tokenize(string, _before, _after)
[string] [string]
end end
@ -1145,17 +1145,10 @@ module PointBlank
class CodeInline < NullInline class CodeInline < NullInline
# (see ::PointBlank::Parsing::NullInline#tokenize) # (see ::PointBlank::Parsing::NullInline#tokenize)
def self.tokenize(string, *_lookaround) def self.tokenize(string, *_lookaround)
open = {}
iterate_tokens(string, "`") do |_before, current_text, matched| iterate_tokens(string, "`") do |_before, current_text, matched|
if matched if matched
match = current_text.match(/^`+/)[0] match = current_text.match(/^`+/)[0]
if open[match]
open[match] = nil
[match, self, :close]
else
open[match] = true
[match, self, :open] [match, self, :open]
end
else else
current_text[0] current_text[0]
end end
@ -1172,9 +1165,9 @@ module PointBlank
text = (part.is_a?(Array) ? part.first : part) text = (part.is_a?(Array) ? part.first : part)
buffer += text buffer += text
next unless part.is_a? Array next unless part.is_a? Array
next if idx.zero?
break (cutoff = idx) if part.first == opening && break (cutoff = idx) if part.first == opening
part.last == :close
end end
buffer = construct_literal(buffer[opening.length..(-1 - opening.length)]) buffer = construct_literal(buffer[opening.length..(-1 - opening.length)])
[cutoff.positive? ? build([buffer]) : opening, parts[(cutoff + 1)..]] [cutoff.positive? ? build([buffer]) : opening, parts[(cutoff + 1)..]]
@ -1345,7 +1338,11 @@ module PointBlank
when String when String
bfr[-1] bfr[-1]
when ::PointBlank::DOM::DOMObject when ::PointBlank::DOM::DOMObject
"." if bfr.is_a?(::PointBlank::DOM::Text)
bfr.content[-1]
else
extract_left(bfr.children.last)
end
when Array when Array
bfr.first[-1] bfr.first[-1]
end end
@ -1359,7 +1356,11 @@ module PointBlank
when String when String
afr[0] afr[0]
when ::PointBlank::DOM::DOMObject when ::PointBlank::DOM::DOMObject
"." if afr.is_a?(::PointBlank::DOM::Text)
afr.content[0]
else
extract_left(afr.children.first)
end
when Array when Array
afr.first[0] afr.first[0]
end end
@ -1428,8 +1429,9 @@ module PointBlank
((blk.first.length % 3).zero? && ((blk.first.length % 3).zero? &&
(closer.first.length % 3).zero?)) (closer.first.length % 3).zero?))
(open ? capture : before).prepend(blk) (open ? capture : before).prepend(blk)
next unless blk.is_a?(Array) next unless blk.is_a?(Array) && !open
return backlog unless blk[1].check_contents(capture)
return backlog unless closer[1].check_contents(capture)
end end
return backlog if open return backlog if open

View File

@ -2,7 +2,7 @@
Gem::Specification.new do |spec| Gem::Specification.new do |spec|
spec.name = "mmmd" spec.name = "mmmd"
spec.version = "0.1.1" spec.version = "0.1.2"
spec.summary = "Modular, compliant Markdown processor" spec.summary = "Modular, compliant Markdown processor"
spec.description = <<~DESC spec.description = <<~DESC
MMMD (short for Mark My Manuscript Down) is a Markdown processor MMMD (short for Mark My Manuscript Down) is a Markdown processor