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 #826

Conversation

anthonyfok
Copy link
Member

Push Request: Experimental AsciiDoc support with external helpers
(Replaces my previously borked PR #823)

  • Modeled after 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. :-)

More discussions at Issue #470 and at PR #823.

@bep
Copy link
Member

bep commented Jan 24, 2015

Running with asciidoctor works fine, but there are room for fine-tuning:

1000 small pages, Blackfriday vs acsiidoctor:

0 of 1001 drafts rendered
0 future content 
1024 pages created 
4 categories created
4 series created
52 tags created
in 2499 ms

0 of 1001 drafts rendered
0 future content 
1024 pages created 
52 tags created
4 categories created
4 series created
in 77172 ms

@anthonyfok anthonyfok force-pushed the external-asciidoctor-support-experimental branch 4 times, most recently from ec257d6 to bdcba05 Compare January 30, 2015 21:12
@anthonyfok anthonyfok force-pushed the external-asciidoctor-support-experimental branch 2 times, most recently from a4384ae to 5aab938 Compare January 31, 2015 14:31
@anthonyfok anthonyfok mentioned this pull request Jan 31, 2015
@Fale
Copy link
Contributor

Fale commented Feb 21, 2015

The .adoc extension is very popular for asciidoc files. I would add it too :)

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`, `*.adoc` 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. :-)

2015-01-30: Updated for the replaceShortcodeTokens() syntax change
2015-02-21: Add `.adoc` extension as suggested by @Fale
@anthonyfok anthonyfok force-pushed the external-asciidoctor-support-experimental branch from 5aab938 to c5ad8cd Compare February 21, 2015 19:20
@anthonyfok
Copy link
Member Author

Thank you for your suggestion, @Fale! The .adoc extension is now added. :-)

@Fale
Copy link
Contributor

Fale commented Feb 21, 2015

Thanks to you for the fast fix. I hope to see it in mainline soon :)

@spf13
Copy link
Contributor

spf13 commented Mar 13, 2015

Merged as 358dcce

@spf13 spf13 closed this Mar 13, 2015
@anthonyfok anthonyfok deleted the external-asciidoctor-support-experimental branch December 19, 2015 18:56
@bwklein
Copy link
Contributor

bwklein commented May 13, 2016

@anthonyfok Is there a way to pass attributes to asciidoctor when Hugo calls for it to render content?

@anthonyfok
Copy link
Member Author

Hi @bwklein,

No, not yet. There are some command-line options that are passed to asciidoctor when Hugo calls it, but it is not user-configurable, at least not yet.

If you would like this to be implemented, please open a new issue and perhaps give some example use cases, especially what command-line options you would like to be user-configurable.

Thanks!

Anthony

@bwklein
Copy link
Contributor

bwklein commented May 17, 2016

@anthonyfok Thank you for the reply. This is a good example of how Middleman does it.
https://github.com/middleman/middleman-asciidoc

@github-actions
Copy link

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 Feb 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants