Rework external asciidoctor integration

This commit solves the relative path problem with asciidoctor tooling. An include will resolve relatively, so you can refer easily to files in the same folder.

Also `asciidoctor-diagram` and PlantUML rendering works now, because the created temporary files will be placed in the correct folder.

This patch covers just the Ruby version of asciidoctor. The old AsciiDoc CLI EOLs in Jan 2020, so this variant is removed from code.

The configuration is completely rewritten and now available in `config.toml` under the key `[markup.asciidocext]`:

```toml
[markup.asciidocext]
    extensions = ["asciidoctor-html5s", "asciidoctor-diagram"]
    workingFolderCurrent = true
    trace = true
    [markup.asciidocext.attributes]
        my-base-url = "https://example.com/"
        my-attribute-name = "my value"
```

- backends, safe-modes, and extensions are now whitelisted to the popular (ruby) extensions and valid values.
- the default for extensions is to not enable any, because they're all external dependencies so the build would break if the user didn't install them beforehand.
- the default backend is html5 because html5s is an external gem dependency.
- the default safe-mode is safe, explanations of the modes: https://asciidoctor.org/man/asciidoctor/
- the config is namespaced under asciidocext_config and the parser looks at asciidocext to allow a future native Go asciidoc.
- `uglyUrls=true` option and `--source` flag are supported
- `--destination` flag is required

Follow the updated documentation under `docs/content/en/content-management/formats.md`. 
  
This patch would be a breaking change, because you need to correct all your absolute include pathes to relative paths, so using relative paths must be configured explicitly by setting `workingFolderCurrent = true`.
This commit is contained in:
Derk Muenchhausen 2020-06-25 09:51:33 +02:00 committed by GitHub
parent 77aa385b84
commit f0266e2ef3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 555 additions and 155 deletions

View file

@ -20,7 +20,7 @@ import (
"github.com/gohugoio/hugo/markup/rst"
"github.com/gohugoio/hugo/markup/asciidoc"
"github.com/gohugoio/hugo/markup/asciidocext"
"github.com/gohugoio/hugo/config"
@ -377,7 +377,7 @@ func testAllMarkdownEnginesForPages(t *testing.T,
}{
{"md", func() bool { return true }},
{"mmark", func() bool { return true }},
{"ad", func() bool { return asciidoc.Supports() }},
{"ad", func() bool { return asciidocext.Supports() }},
{"rst", func() bool { return rst.Supports() }},
}