Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New markdown to asciidoc tests #5716

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mb21
Copy link
Collaborator

@mb21 mb21 commented Aug 29, 2019

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
Copy link
Collaborator Author

mb21 commented Aug 29, 2019

Hm.. asciidoc lists are interesting...

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


```
% pandoc -t asciidoc
## Title
Copy link

@cagix cagix Aug 29, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this read "### Title" ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe :) We should probably implement #5615

Copy link

@cagix cagix Sep 12, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, beside the discussion in #5615, the comment for this test case (line 45 "Render a level 3 heading") does not match the actual test data in lines 49 to 51, as it is just a level 2 heading (which is tested also in lines 24 .. 31 above).

% pandoc -t asciidoc
## Title
^D
== Title
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and accordingly "=== Title" here?

@jgm
Copy link
Owner

jgm commented Aug 29, 2019

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.

@mb21
Copy link
Collaborator Author

mb21 commented Sep 9, 2019

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

@cagix
Copy link

cagix commented Sep 12, 2019

@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 ...

@mb21
Copy link
Collaborator Author

mb21 commented Sep 12, 2019

@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?

@jgm
Copy link
Owner

jgm commented Sep 12, 2019

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

@cagix
Copy link

cagix commented Sep 12, 2019

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

?

@tremain74
Copy link

I would like to contribute to this code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants