README.adoc in reverse_asciidoctor-0.2.0 vs README.adoc in reverse_asciidoctor-0.2.1
- old
+ new
@@ -23,16 +23,70 @@
[source,ruby]
----
gem 'reverse_asciidoctor'
----
+== Usage
+
+=== Ruby
+
+You can convert html content as string or Nokogiri document:
+
+[source,ruby]
+----
+input = '<strong>feelings</strong>'
+result = ReverseAsciidoctor.convert input
+result.inspect # " *feelings* "
+----
+
+=== Commandline
+
+It's also possible to convert html files to markdown using the binary:
+
+[source,console]
+----
+$ bin/reverse_asciidoctor file.html > file.adoc
+$ cat file.html | bin/reverse_asciidoctor > file.adoc
+----
+
+In addition, the `bin/w2a` script (adapted from the `bin/w2m` script in
+https://github.com/benbalter/word-to-markdown[Ben Balter's word-to-markdown])
+extracts HTML from Word docx documents, and converts it to Asciidoc.
+
+[source,console]
+----
+$ bundle exec bin/w2a document.docx > document.adoc
+----
+
+The script presumes that LibreOffice has already been installed: it uses LibreOffice's
+export to XHTML. LibreOffice's export of XHTML is superior to the native Microsoft Word export
+to HTML: it exports lists (which Word keeps as paragraphs), and it exports OOMML into MathML.
+On the other hand, the LibreOffice export relies on default styling being used in the
+document, and it may not cope with ordered lists or headings with customised appearance.
+For best results, reset the styles in the document you're converting to those in
+the default Normal.dot template.
+
+If you wish to convert the MathML in the document to AsciiMath, run the script with the
+`--mathml2asciimath` option:
+
+[source,console]
+----
+$ bundle exec bin/w2a --mathml2asciimath document.docx > document.adoc
+----
+
+Note that some information in OOMML is not preserved in the export to MathML from LibreOffice;
+in particular, font shifts such as double-struck fonts.
+
+Note that the LibreOffice exporter does seem to drop some text (possibly associated with
+MathML); use with caution.
+
== Features
As a port of reverse_markdown, reverse_asciidoctor shares its features:
* Module based - if you miss a tag, just add it
-* Can deal with nested lists
+* Can deal with nested lists
* Inline and block code is supported
* Supports blockquote
It supports the following html tags supported by reverse_markdown:
@@ -41,11 +95,11 @@
* `br`
* `code`, `tt` (added: `kbd`, `samp`, `var`)
* `div`, `article`
* `em`, `i` (added: `cite`)
* `h1`, `h2`, `h3`, `h4`, `h5`, `h6`, `hr`
-* `img`
+* `img`
* `li`, `ol`, `ul` (added: `dir`)
* `p`, `pre`
* `strong`, `b`
* `table`, `td`, `th`, `tr`
@@ -58,11 +112,11 @@
In addition, it supports:
* `aside`
* `audio`, `video` (with `@src` attributes)
-* `figure`, `figcaption`
+* `figure`, `figcaption`
* `mark`
* `q`
* `sub`, `sup`
* `@id` anchors
* `blockquote@cite`
@@ -75,23 +129,19 @@
It also supports MathML... sort of.
* Asciidoctor supports AsciiMath and LaTeX for stem expressions. HTML uses MathML.
The gem will recognise MathML expressions in HTML, and will wrap them in Asciidoctor
-`stem:[ ]` macros. The result of this gem is not actually legal Asciidoctor for stem:
+`stem:[ ]` macros. The result of this gem is not actually legal Asciidoctor for stem:
Asciidoctor will presumably
think this is AsciiMath in the `stem:[ ]` macro, try to pass it into MathJax as
AsciiMath, and fail. But of course, MathJax has no problem with MathML, and some postprocessing
on the Asciidoctor output can ensure that the MathML is treated by MathJax (or whatever else
uses the output) as such; so this is still much better than nothing for stem processing.
-* An alternative would be to attempt to map MathML to either LaTeX or AsciiMath.
-** The self-description of https://github.com/learningobjectsinc/mathml-to-asciimath
-("subset"... "this module is not: comprehensive, performant") does not recommend it,
-when MathJax is entirely happy with MathML anyway.
-** https://github.com/transpect/mml2tex looks rather more robust, and is also used
-to export Word documents and their OOMML to LaTeX via MathML. But we'd still rather
-keep the MathML in place.
+** The gem will optionally invoke the https://github.com/riboseinc/mathml2asciimath
+gem, to convert MathML to AsciiMath. The conversion is not perfect, and will need to be
+post-edited; but it's a lot better than nothing.
The gem does not support:
* `col`, `colgroup`
* `source`, `picture`
@@ -103,80 +153,43 @@
* `center`
* `data`, `meter`
* `del`, `ins`
* `footer`, `header`, `main`, `nav`, `details`, `section`, `summary`, `template`
-== Usage
-=== Ruby
+== Configuration
-You can convert html content as string or Nokogiri document:
-
-[source,ruby]
-----
-input = '<strong>feelings</strong>'
-result = ReverseAsciidoctor.convert input
-result.inspect # " *feelings* "
-----
-
-=== Commandline
-
-It's also possible to convert html files to markdown using the binary:
-
-[source,console]
-----
-$ bin/reverse_asciidoctor file.html > file.adoc
-$ cat file.html | bin/reverse_asciidoctor > file.adoc
-----
-
-In addition, the `bin/w2a` script (adapted from the `bin/w2m` script in
-https://github.com/benbalter/word-to-markdown[Ben Balter's word-to-markdown])
-extracts HTML from Word docx documents, and converts it to Asciidoc.
-
-[source,console]
-----
-$ bundle exec bin/w2a document.docx > document.adoc
-----
-
-The script presumes that LibreOffice has already been installed: it uses LibreOffice's
-export to XHTML. LibreOffice's export of XHTML is superior to the native Microsoft Word export
-to HTML: it exports lists (which Word keeps as paragraphs), and it exports OOMML into MathML.
-On the other hand, the LibreOffice export relies on default styling being used in the
-document, and it may not cope with ordered lists or headings with customised appearance.
-For best results, reset the styles in the document you're converting to those in
-the default Normal.dot template.
-
-=== Configuration
-
The following options are available:
* `unknown_tags` (default `pass_through`) - how to handle unknown tags. Valid options are:
** `pass_through` - Include the unknown tag completely into the result
** `drop` - Drop the unknown tag and its content
** `bypass` - Ignore the unknown tag but try to convert its content
** `raise` - Raise an error to let you know
* `tag_border` (default `' '`) - how to handle tag borders. valid options are:
** `' '` - Add whitespace if there is none at tag borders.
** `''` - Do not not add whitespace.
+* `mathml2asciimath` - if `true`, will use the https://github.com/riboseinc/mathml2asciimath gem
+to convert MathML to AsciiMath
-==== As options
+=== As options
Just pass your chosen configuration options in after the input. The given options will last for this operation only.
[source,ruby]
----
-ReverseAsciidoctor.convert(input, unknown_tags: :raise)
+ReverseAsciidoctor.convert(input, unknown_tags: :raise, mathml2asciimath: true)
----
-==== Preconfigure
+=== Preconfigure
Or configure it block style on a initializer level. These configurations will last for all conversions until they are set to something different.
[source,ruby]
----
ReverseAsciidoctor.config do |config|
config.unknown_tags = :bypass
- config.github_flavored = true
+ config.mathml2asciimath = true
config.tag_border = ''
end
----