Technical document writing using asciidoctor via Leo

68 views
Skip to first unread message

Xu Wang

unread,
Apr 28, 2020, 1:27:41 AM4/28/20
to leo-e...@googlegroups.com
Dear All,

I'm switching from Markdown to Asciidoctor for writing documents. I'd like to use Leo as the central part for orgenizing all the docs.

There are a list of questions I'm going to explore. If you have experience or recommendations please share we me.

1) which leo directive to enable syntax highlight for asciidoc
2) which directive to use for generating external .adoc file from Leoeditor
3) how to use extensions in .adoc file, for example diagrams, slides
4) which leo command to generate html from .adoc file
5) which leo command to generate pdf from .adoc file

Best Regards,
Austin

Thomas Passin

unread,
Apr 28, 2020, 3:34:35 PM4/28/20
to leo-editor
I can not give you any comprehensive answers, but I can suggest some hope.  I have been enhancing the viewrendered3 plugin.  It inherited code from the older vewrendered plugin, and that code attempts to render asciidoc nodes in a separate viewing pane. I say attempts, because the code as is cannot find the asciidoc executable.  But I know how to fix that.

So far, the plugin enhancements cover restructured text and Markdown.  It should be easy enough to enhance asciidoc nodes in a similar way.  When complete, you would be able to

1. Render asciidoc nodes and subtrees (by means of rendering to HTML);
2. Recognize @language asciidoc directives in node bodies and render those parts using asciidoc;
3. Recognize other @language directives and render as appropriate;
4. Render code and literal blocks differently from normal asciidoc text (e.g., in <pre> tags for literal blocks);
5. Execute code blocks in the subtree (python only for the time being) and append any printed output;
6. Have code blocks colorized;
7. Export the HTML rendering to the system browser;
8. Render mathematics with MathJax, if asciidoc can work with or convert the math to latex. (RsT and MD can, and I imagine that asciidoc can too)

To some extent, making all these capabilities available will depend on just how asciidoctor works, and I have never worked with it.  Still, everything should be possible.

Developing these enhancements for asciidoc was fairly far down in my priority list, but if there is some interest out there I would be willing to move it up.  I realize that this would not address everything you mentioned, but it would be a good start.  Feedback, please!

Xu Wang

unread,
Apr 29, 2020, 1:47:13 AM4/29/20
to leo-e...@googlegroups.com
Thanks Thomas for the information. 

For now, I can live without preview, just use an external browser or PDF reader for that purpose. The computer screen is too small, I will leave more room for the body panel when writing. If only I can create buttons for generating HTML/PDF from asciidoc tree, there is no problem for me to refresh the external browser.

I tried @language asciidoc, however the syntax highlight is not complete, only very few syntax are recognized. Even headlines are not highlighted. This may be a problem when working on the body panel.

Best Regards,
Austin




Thomas Passin <tbp1...@gmail.com> 于2020年4月29日周三 上午3:34写道:
--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/leo-editor/17e109e2-db92-4f24-8ee7-586187f92088%40googlegroups.com.

Xu Wang

unread,
Apr 29, 2020, 8:31:24 AM4/29/20
to leo-e...@googlegroups.com
Some findings I have so far.

1) which leo directive to enable syntax highlight for asciidoc

Use the @adoc node, for example a node with headline @adoc leoasciidoctest.adoc,
Put @language asciidoc on the body of that node.

2) which directive to use for generating external .adoc file from Leoeditor
Use adoc command, it will generate both .adoc file and corresponding .html file

3) how to use extensions in .adoc file, for example diagrams, slides

I put some diagram in the asciidoc file, the correct command for generating html is
         asciidoctor -r asciidoctor-diagram leoasciidoctest.adoc

However, the default adoc command is without the -r asciidoctor-diagram parameter.  
Need to figure out a way to add parameters for the command.

4) which leo command to generate html from .adoc file
Use adoc command as #2

5) which leo command to generate pdf from .adoc file
May need to add new command by calling g.execute_shell_commands. 


Edward K. Ream

unread,
Apr 29, 2020, 9:18:17 AM4/29/20
to leo-editor
On Wed, Apr 29, 2020 at 7:31 AM Xu Wang <xu4...@gmail.com> wrote:
Some findings I have so far.

Good work. These should likely become part of Leo's AsciiDoctor page.

Edward

Xu Wang

unread,
Apr 29, 2020, 10:55:37 AM4/29/20
to leo-e...@googlegroups.com
One more finding, in the generated .adoc file, there is one empty line between the tittle and the author line, 

= headline1

Austin Xu Wang
:doctype: book
:encoding: utf-8
:lang: en
:toc: left
:numbered:

The empty line should be removed, otherwise the generated html is with wrong format.

Edward K. Ream <edre...@gmail.com> 于2020年4月29日周三 下午9:18写道:
--
You received this message because you are subscribed to the Google Groups "leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to leo-editor+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages