From 4d4d8cfc4cf08ba80105763c313ab00f1afeb0b2 Mon Sep 17 00:00:00 2001 From: Yessiest Date: Thu, 13 Mar 2025 10:57:52 +0400 Subject: [PATCH] more compatibility fixes --- lib/mmmd/blankshell.rb | 32 +++++++++++++++++--------------- mmmd.gemspec | 2 +- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/mmmd/blankshell.rb b/lib/mmmd/blankshell.rb index 550c2a4..358efbf 100644 --- a/lib/mmmd/blankshell.rb +++ b/lib/mmmd/blankshell.rb @@ -1016,7 +1016,7 @@ module PointBlank # @param before [String, ::PointBlank::DOM::DOMObject] # @param after [String, ::PointBlank::DOM::DOMObject] # @return [Array] - def self.tokenize(string, before, after) + def self.tokenize(string, _before, _after) [string] end @@ -1145,17 +1145,10 @@ module PointBlank class CodeInline < NullInline # (see ::PointBlank::Parsing::NullInline#tokenize) def self.tokenize(string, *_lookaround) - open = {} iterate_tokens(string, "`") do |_before, current_text, matched| if matched match = current_text.match(/^`+/)[0] - if open[match] - open[match] = nil - [match, self, :close] - else - open[match] = true - [match, self, :open] - end + [match, self, :open] else current_text[0] end @@ -1172,9 +1165,9 @@ module PointBlank text = (part.is_a?(Array) ? part.first : part) buffer += text next unless part.is_a? Array + next if idx.zero? - break (cutoff = idx) if part.first == opening && - part.last == :close + break (cutoff = idx) if part.first == opening end buffer = construct_literal(buffer[opening.length..(-1 - opening.length)]) [cutoff.positive? ? build([buffer]) : opening, parts[(cutoff + 1)..]] @@ -1345,7 +1338,11 @@ module PointBlank when String bfr[-1] when ::PointBlank::DOM::DOMObject - "." + if bfr.is_a?(::PointBlank::DOM::Text) + bfr.content[-1] + else + extract_left(bfr.children.last) + end when Array bfr.first[-1] end @@ -1359,7 +1356,11 @@ module PointBlank when String afr[0] when ::PointBlank::DOM::DOMObject - "." + if afr.is_a?(::PointBlank::DOM::Text) + afr.content[0] + else + extract_left(afr.children.first) + end when Array afr.first[0] end @@ -1428,8 +1429,9 @@ module PointBlank ((blk.first.length % 3).zero? && (closer.first.length % 3).zero?)) (open ? capture : before).prepend(blk) - next unless blk.is_a?(Array) - return backlog unless blk[1].check_contents(capture) + next unless blk.is_a?(Array) && !open + + return backlog unless closer[1].check_contents(capture) end return backlog if open diff --git a/mmmd.gemspec b/mmmd.gemspec index a9d651e..af7d835 100644 --- a/mmmd.gemspec +++ b/mmmd.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |spec| spec.name = "mmmd" - spec.version = "0.1.1" + spec.version = "0.1.2" spec.summary = "Modular, compliant Markdown processor" spec.description = <<~DESC MMMD (short for Mark My Manuscript Down) is a Markdown processor