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

Experimental AsciiDoc support with external helpers #823

Closed
wants to merge 1 commit into from

Conversation

anthonyfok
Copy link
Member

See #470

  • Based on existing support for reStructuredText files

  • Handles content files with extensions .asciidoc and .ad

  • Pipes content through asciidoctor --safe -.
    If asciidoctor is not installed, then asciidoc --safe -.

  • To make sure asciidoctor or asciidoc is found, after adding
    a piece of AsciiDoc content, run hugo with the -v flag
    and look for this message:

    INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...
    

Caveats:

  • The final "Last updated" timestamp is currently not stripped.

  • When hugo is run with -v, you may see a lot of these messages

    INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...
    

    if you have lots of *.ad or *.asciidoc files.

  • Some versions of asciidoc may have trouble with its safe mode.
    To test if you are affected, try this:

    $ echo "Hello" | asciidoc --safe -
    asciidoc: ERROR: unsafe: ifeval invalid
    asciidoc: FAILED: ifeval invalid safe document
    

    If so, I recommend that you install asciidoctor instead.

Feedback and patches welcome!

Ideally, we should be using https://github.com/VonC/asciidocgo,
@VonC's wonderful Go implementation of Asciidoctor. However,
there is still a bit of work needed for asciidocgo to expose
its API so that Hugo can actually use it.

Until then, hope this "experimental AsciiDoc support through external
helpers" can serve as a stopgap solution for our community. :-)

See #470

 * Based on existing support for reStructuredText files

 * Handles content files with extensions `.asciidoc` and `.ad`

 * Pipes content through `asciidoctor --safe -`.
   If `asciidoctor` is not installed, then `asciidoc --safe -`.

 * To make sure `asciidoctor` or `asciidoc` is found, after adding
   a piece of AsciiDoc content, run `hugo` with the `-v` flag
   and look for this message:

        INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...

Caveats:

 * The final "Last updated" timestamp is currently not stripped.

 * When `hugo` is run with `-v`, you may see a lot of these messages

        INFO: 2015/01/23 Rendering with /usr/bin/asciidoctor ...

   if you have lots of `*.ad` or `*.asciidoc` files.

 * Some versions of `asciidoc` may have trouble with its safe mode.
   To test if you are affected, try this:

        $ echo "Hello" | asciidoc --safe -
        asciidoc: ERROR: unsafe: ifeval invalid
        asciidoc: FAILED: ifeval invalid safe document

   If so, I recommend that you install `asciidoctor` instead.

Feedback and patches welcome!

Ideally, we should be using https://github.com/VonC/asciidocgo,
@VonC's wonderful Go implementation of Asciidoctor.  However,
there is still a bit of work needed for asciidocgo to expose
its API so that Hugo can actually use it.

Until then, hope this "experimental AsciiDoc support through external
helpers" can serve as a stopgap solution for our community. :-)
@bep
Copy link
Member

bep commented Jan 23, 2015

Cool.

But whats missing from asciidocgo that prevent us from using it?

@bep
Copy link
Member

bep commented Jan 23, 2015

On an added note - I think we should wait and/or make it so we can use the Go implementation. One thing is to use a Python lib for code highlighting -- but dragging some slow Ruby into the mix for the vital rendering part ...

@bep
Copy link
Member

bep commented Jan 23, 2015

Had a quick look at the go library -- and it looks very unfinished.

@anthonyfok
Copy link
Member Author

Had a quick look at the go library -- and it looks very unfinished.

Indeed. The fork https://github.com/ciarand/asciidocgo by @ciarand has gone a bit further, but still not in a readily usable state. When a first look at it a couple months ago, it appears that @VonC has completed all the internals, but the actual external API is... not written (!) at the moment? Looks very promising, but I don't think it would be ready for Hugo v0.13. Maybe v0.14.

Yes, Asciidoctor will be quite a bit slower than the rest of Hugo, but I suppose it would satisfy the many AsciiDoc fans who want to start using Hugo with AsciiDoc today. ;-) We just need a BIG DISCLAIMER in the documentation that this AsciiDoc feature is experimental and s-l-o-w, and improvement in speed are expected in future versions once asciidocgo is ready, hopefully a few months later. :-)

@anthonyfok anthonyfok added this to the v0.13 milestone Jan 23, 2015
@ciarand
Copy link
Contributor

ciarand commented Jan 24, 2015

Yeah, unfortunately I haven't had (and probably won't have) time to fix it up
for at least the next 6 months.

@anthonyfok
Copy link
Member Author

Thank you for your input @ciarand, and for spearheading the effort to finish the last mile for asciidocgo. Perhaps fellow Gophers would be interested in rising to the challenge to make asciidocgo complete? :-)

By the way, apologies to fellow Hugo developers: I have mistakenly pushed this topic branch to the main hugo git repository, whereas I was supposed to push it to my fork and then make the pull request there. (Oops!) Sorry for my oversight.

@anthonyfok
Copy link
Member Author

Notes for possible solutions to the caveats:

@bep
Copy link
Member

bep commented Jan 24, 2015

As to the topic branch: Please delete it on spf13, and push it to your own repo. That would also mean creating a new PR, but that's OK.

@anthonyfok
Copy link
Member Author

@bjornerik: Good idea, thanks! I'll do that right away.

@anthonyfok anthonyfok closed this Jan 24, 2015
@anthonyfok anthonyfok deleted the external-asciidoctor-support-experimental branch January 24, 2015 09:17
@github-actions
Copy link

github-actions bot commented Mar 5, 2022

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants