bin/w2a in reverse_asciidoctor-0.2.0 vs bin/w2a in reverse_asciidoctor-0.2.1

- old
+ new

@@ -10,22 +10,31 @@ string.sub!(/\A[[:space:]]+/, '') # document leading whitespace string.sub!(/[[:space:]]+\z/, '') # document trailing whitespace string.gsub!(/([ ]+)$/, '') # line trailing whitespace string.gsub!(/\n\n\n\n/, "\n\n") # Quadruple line breaks string.delete!(' ') # Unicode non-breaking spaces, injected as tabs + # following added by me + string.gsub!(%r{<h[1-9][^>]*></h1>}, " ") # I don't know why Libre Office is inserting them, but they need to go + string.gsub!(%r{<h1[^>]* style="vertical-align: super;[^>]*>([^<]+)</h1>}, + "<sup>\\1</sup>") # I absolutely don't know why Libre Office is rendering superscripts as h1 string end -if ARGV.size != 1 || ARGV[0] == '--help' +if ARGV.size != 1 && ARGV[0] != "--mathml2asciimath" || ARGV[0] == '--help' puts 'Usage: bundle exec w2m path/to/document.docx' exit 1 end +if ARGV[0] == "--mathml2asciimath" && ARGV[1] + ReverseAsciidoctor.config.mathml2asciimath = true + ARGV[0] = ARGV[1] +end + if ARGV[0] == '--version' puts "WordToMarkdown v#{WordToMarkdown::VERSION}" puts "LibreOffice v#{WordToMarkdown.soffice.version}" unless Gem.win_platform? else doc = WordToMarkdown.new ARGV[0] - # puts doc.to_s + # puts scrub_whitespace(doc.document.html) puts ReverseAsciidoctor.convert(scrub_whitespace(doc.document.html), WordToMarkdown::REVERSE_MARKDOWN_OPTIONS) end