markdown-asciidoc / markdown-to-asciidoc

Java Library to convert Markdown to AsciiDoc
Other
77 stars 12 forks source link

Some code spans should be transformed with a pass macro or shorthand, depending on content #62

Open Vampire opened 5 months ago

Vampire commented 5 months ago

https://github.com/asciidoctor/kramdown-asciidoc does not translate all code spans 1:1 but sometimes uses `+the code here+` or `pass:c[the code here]` depending on the wrapped code.

It does this depending on a regex and some ^ check: https://github.com/asciidoctor/kramdown-asciidoc/blob/main/lib/kramdown-asciidoc/converter.rb#L525.

Maybe this would make sense here too.

Otherwise for example `foo(...)` gets rendered as image when with `+foo(...)+` it would be rendered better and more consistent with Markdown as image

bodiam commented 4 months ago

hmm, I'm not really sure what to do here. Again, a testcase might help.

Vampire commented 4 months ago

Again here, just copy my concrete example into the scenario

  Scenario: Codespan with pass shorthand
    Given the Markdown source
    """
    `foo(...)`
    """
    When it is converted to AsciiDoc
    Then the result should match the AsciiDoc source
    """
    `+foo(...)+`
    """

But this is just one of many cases. I'd suggest to implement the same logic as kramdoc uses, as it is written by the maintainer of Asciidoctor who should know best when what should better be used. That's why I linked you to the regex that is used and the additional logic around ^. So what you imho should do is to port that logic from kramdoc to this lib so that they behave the same.