Markdown -> Asciidoc converter

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Markdown -> Asciidoc converter

Sisyphos
Has anyone a recommendation for Markdow to Asciidoc converter? When I use pandoc I got lot of Anchors, what is unnecessary ballast. Another issue is, that I prefer "=" characters in the section heading, not below, what padoc is creating.

Any suggestions?
Reply | Threaded
Open this post in threaded view
|

Re: Markdown -> Asciidoc converter

mojavelinux
Administrator
I am not much of a fan of pandoc for AsciiDoc generation either. That's why I created a converter from Kramdown that outputs AsciiDoc. It's not 100% complete, but it gets you most of the way there. Plus, it's hackable.


I would very much like to see that project get finished. However, I don't have the bandwidth at the moment. But, of course, that could change as opportunities arise.

Cheers,

-Dan

On Wed, Nov 8, 2017 at 3:55 AM, Sisyphos [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Has anyone a recommendation for Markdow to Asciidoc converter? When I use pandoc I got lot of Anchors, what is unnecessary ballast. Another issue is, that I prefer "=" characters in the section heading, not below, what padoc is creating.

Any suggestions?


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Markdown-Asciidoc-converter-tp6014.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux
Reply | Threaded
Open this post in threaded view
|

Re: Markdown -> Asciidoc converter

Sisyphos
Hi Dan,

Thank you very much for your quick answer. I greatly admire your dedication to Asciidoc. A great project.

Most of it looks good. The headings have no index and are simply converted to a "=" character. That looks nice.

I have stumbled on two things: Unfortunately, I use front matter in Jekyll style for my files. eg:

---
title: Title of my Doc
---

As far as I understand kramdown, the "---" characters there are just horizontal rules (https://kramdown.gettalong.org/syntax.html#horizontal-rules). If that in adoc-files also become horizontal rules, that would be fine for me. Unfortunately kramdown-asciidoc doesn't like that at all:

/data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:21:in `block in inner': undefined method `convert_hr' for #<Kramdown::Converter::Asciidoc:0x00556ba829fa68> (NoMethodError)
Did you mean?  convert_br
               convert_header
               convert
               convert_a
               convert_p
               convert_root
               convert_li
               convert_ol
               convert_ul
               convert_em
               convert_strong
               convert_img
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:17:in `each'
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:17:in `each_with_index'
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:17:in `inner'
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:29:in `convert_root'
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:10:in `convert'
        from /var/lib/gems/2.3.0/gems/kramdown-1.15.0/lib/kramdown/converter/base.rb:105:in `convert'
        from /var/lib/gems/2.3.0/gems/kramdown-1.15.0/lib/kramdown/document.rb:117:in `method_missing'
        from bin/kramdown-asciidoc:24:in `<main>'

However, since front matters are not part of kramdown, I don't see this as a bug.

A structural problem is somewhat more serious. As far as I understand asciidoc, texts with one leading "=" are interpreted as document headers. kramdown-asciidoc converts the levels one to one, which means that there are several document headers.

Since you can't know what kind of title the author wants without front matter, I would suggest that the headlines be moved down one level during conversion. (So "#" becomes "=="). After the conversion, I would simply set a document header by myself.

Regards,
Benjamin
Reply | Threaded
Open this post in threaded view
|

Re: Markdown -> Asciidoc converter

mojavelinux
Administrator
The Markdown to AsciiDoc converter has been drastically improved. It also has much better documentation. If you're still looking for a solution, I encourage you to check it out. It can also be installed from rubygems.org.


Feel free to file issues in that repository if you find something that doesn't work.

Cheers,

-Dan

On Thu, Nov 9, 2017 at 1:43 AM Sisyphos [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi Dan,

Thank you very much for your quick answer. I greatly admire your dedication to Asciidoc. A great project.

Most of it looks good. The headings have no index and are simply converted to a "=" character. That looks nice.

I have stumbled on two things: Unfortunately, I use front matter in Jekyll style for my files. eg:

---
title: Title of my Doc
---

As far as I understand kramdown, the "---" characters there are just horizontal rules (https://kramdown.gettalong.org/syntax.html#horizontal-rules). If that in adoc-files also become horizontal rules, that would be fine for me. Unfortunately kramdown-asciidoc doesn't like that at all:

/data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:21:in `block in inner': undefined method `convert_hr' for #<Kramdown::Converter::Asciidoc:0x00556ba829fa68> (NoMethodError)
Did you mean?  convert_br
               convert_header
               convert
               convert_a
               convert_p
               convert_root
               convert_li
               convert_ol
               convert_ul
               convert_em
               convert_strong
               convert_img
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:17:in `each'
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:17:in `each_with_index'
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:17:in `inner'
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:29:in `convert_root'
        from /data1/Software/kramdown-asciidoc/lib/kramdown-asciidoc/converter.rb:10:in `convert'
        from /var/lib/gems/2.3.0/gems/kramdown-1.15.0/lib/kramdown/converter/base.rb:105:in `convert'
        from /var/lib/gems/2.3.0/gems/kramdown-1.15.0/lib/kramdown/document.rb:117:in `method_missing'
        from bin/kramdown-asciidoc:24:in `<main>'

However, since front matters are not part of kramdown, I don't see this as a bug.

A structural problem is somewhat more serious. As far as I understand asciidoc, texts with one leading "=" are interpreted as document headers. kramdown-asciidoc converts the levels one to one, which means that there are several document headers.

Since you can't know what kind of title the author wants without front matter, I would suggest that the headlines be moved down one level during conversion. (So "#" becomes "=="). After the conversion, I would simply set a document header by myself.

Regards,
Benjamin


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Markdown-Asciidoc-converter-tp6014p6016.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML


--
Dan Allen | @mojavelinux | https://twitter.com/mojavelinux