summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdmin <admin@marx.cafe>2022-12-04 23:39:26 -0500
committerAdmin <admin@marx.cafe>2022-12-04 23:39:26 -0500
commitacbf341e84898bff72d51ee861d968f3c7868afd (patch)
tree674e5adab854a0fd2031a7413df052ae22cc95b9
parent3be759d8b01ee055db794d0a146057e409ea844b (diff)
Fix trailing whitespace in tags
-rwxr-xr-xhtml2md.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/html2md.rb b/html2md.rb
index a5aca09..7b89309 100755
--- a/html2md.rb
+++ b/html2md.rb
@@ -98,4 +98,7 @@ body_text = if body.at_css('blockquote > div.border')
body.children.to_html
end
+# Fix cases where <em> or <i> tags contain trailing whitespace
+body_text.gsub!(/(\*\b[^*]+) +(\*+)/, '\1\2 ')
+
puts body_text.lines.map(&:strip).join("\n").gsub(/\n\n\n+/, "\n\n")