pandoc icon indicating copy to clipboard operation
pandoc copied to clipboard

New markdown to asciidoc tests

Open mb21 opened this issue 6 years ago • 8 comments

I've written a script (not included) and transformed the tests from https://github.com/bodiam/markdown-to-asciidoc/tree/master/src/test/resources/nl/jworks/markdown_to_asciidoc to our test format.

There are also another two files in that repo we could look at named testsuite.[adoc|md]: https://github.com/bodiam/markdown-to-asciidoc/tree/master/src/test/resources

To execute only the new tests:

stack test  --test-arguments='-p markdown-to-asciidoc'

After fixing quite a few tests manually (insignificant changes like word-wrapping), we are at:

23 out of 61 tests failed (2.45s)

Those are somewhat interesting cases where I'm not sure whether pandoc is wrong or the test is wrong.

Also a few places where it should be possible to improve pandoc to output nicer asciidoc. I'll see whether I get to that as well...

mb21 avatar Aug 29 '19 14:08 mb21

Hm.. asciidoc lists are interesting...

btw. what's the difference between OrderedList (1,Decimal,Period) and OrderedList (1,DefaultStyle,DefaultDelim) in the AST?

mb21 avatar Aug 29 '19 16:08 mb21

what's the difference between OrderedList (1,Decimal,Period) and OrderedList (1,DefaultStyle,DefaultDelim) in the AST?

Decimal says "I definitely want a decimal list number." DefaultStyle says "use whatever is the default for this list level in this output format" (e.g. in LaTeX, just give me an unadorned \begin{enumerate}). Similarly for Period vs DefaultDelim.

jgm avatar Aug 29 '19 21:08 jgm

About the heading levels... I think I let myself be confused by #5615 (which seems more about how we should handle heading levels in the markdown input).

From asciidoctor docs:

= Document Title (Level 0)

== Level 1 Section Title

=== Level 2 Section Title

When using the article doctype (the default), you can only have one level-0 section title (i.e., the document title) and it must be in the document header.

@cagix I guess you were right and I assume that's how it's always worked in asciidoc (not just asciidoctor) and these test by @bodiam are just not correct? The correct equivalences would be:

  • HTML: <h1>foo</h1>
  • Markdown: # foo
  • AsciiDoc: == foo

mb21 avatar Sep 09 '19 07:09 mb21

@mb21 following the discussion in #5615, it seems to me, that the new --shift-heading-level-by option should be included in the above tests somehow. if i'm not mistaken, without this option pandoc should translate # header 1 to = header 1 (missing the asciidoc semantics, but seems to me to be the expected behaviour). using --shift-heading-level-by=-1 in the tests would establish the asciidoc semantics ...

cagix avatar Sep 12 '19 10:09 cagix

@cagix yes, --shift-heading-level-by=-1 would certainly make the tests pass... but from if == foo is a level 1 header in asciidoc, then the tests are just wrong. correct?

mb21 avatar Sep 12 '19 11:09 mb21

Pandoc renders level-1 headers into asciidoc as ==. No heading shift is required for that.

jgm avatar Sep 12 '19 14:09 jgm

then all tests regarding headings are currently wrong and this is the intended behaviour:

$ pandoc -t asciidoc
# Level 1
## Level 2
### Level 3
^D
== Level 1

=== Level 2

==== Level 3

and

$ pandoc -t asciidoc --shift-heading-level-by=-1
# Level 1
## Level 2
### Level 3
^D
= Level 1

== Level 2

=== Level 3

?

cagix avatar Sep 12 '19 16:09 cagix

I would like to contribute to this code

tremain74 avatar Dec 17 '19 14:12 tremain74