2023-01-04 12:24:36 -05:00
|
|
|
// Copyright 2023 The Hugo Authors. All rights reserved.
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2020-09-09 17:41:53 -04:00
|
|
|
// Package asciidocext converts AsciiDoc to HTML using Asciidoctor
|
|
|
|
// external binary. The `asciidoc` module is reserved for a future golang
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
// implementation.
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
package asciidocext_test
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
|
2023-02-11 10:20:24 -05:00
|
|
|
"github.com/gohugoio/hugo/common/collections"
|
2021-12-12 06:11:11 -05:00
|
|
|
"github.com/gohugoio/hugo/common/hexec"
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
"github.com/gohugoio/hugo/common/loggers"
|
2021-06-09 04:58:18 -04:00
|
|
|
"github.com/gohugoio/hugo/config"
|
2021-12-12 06:11:11 -05:00
|
|
|
"github.com/gohugoio/hugo/config/security"
|
2023-01-04 12:24:36 -05:00
|
|
|
"github.com/gohugoio/hugo/config/testconfig"
|
|
|
|
"github.com/gohugoio/hugo/markup/asciidocext"
|
|
|
|
"github.com/gohugoio/hugo/markup/asciidocext/internal"
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
"github.com/gohugoio/hugo/markup/converter"
|
2020-07-23 09:59:48 -04:00
|
|
|
"github.com/gohugoio/hugo/markup/markup_config"
|
2023-01-04 12:24:36 -05:00
|
|
|
"github.com/spf13/afero"
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
|
|
|
|
qt "github.com/frankban/quicktest"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestAsciidoctorDefaultArgs(t *testing.T) {
|
|
|
|
c := qt.New(t)
|
2021-06-09 04:58:18 -04:00
|
|
|
cfg := config.New()
|
2023-01-04 12:24:36 -05:00
|
|
|
conf := testconfig.GetTestConfig(afero.NewMemMapFs(), cfg)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
p, err := asciidocext.Provider.New(
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
converter.ProviderConfig{
|
2023-01-04 12:24:36 -05:00
|
|
|
Conf: conf,
|
2023-06-16 02:17:42 -04:00
|
|
|
Logger: loggers.NewDefault(),
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
},
|
|
|
|
)
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
ac := conv.(*internal.AsciidocConverter)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c.Assert(ac, qt.Not(qt.IsNil))
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
args := ac.ParseArgs(converter.DocumentContext{})
|
2020-09-08 04:00:57 -04:00
|
|
|
expected := []string{"--no-header-footer"}
|
2020-07-23 09:59:48 -04:00
|
|
|
c.Assert(args, qt.DeepEquals, expected)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAsciidoctorNonDefaultArgs(t *testing.T) {
|
|
|
|
c := qt.New(t)
|
|
|
|
mconf := markup_config.Default
|
|
|
|
mconf.AsciidocExt.Backend = "manpage"
|
|
|
|
mconf.AsciidocExt.NoHeaderOrFooter = false
|
|
|
|
mconf.AsciidocExt.SafeMode = "safe"
|
|
|
|
mconf.AsciidocExt.SectionNumbers = true
|
|
|
|
mconf.AsciidocExt.Verbose = true
|
|
|
|
mconf.AsciidocExt.Trace = false
|
|
|
|
mconf.AsciidocExt.FailureLevel = "warn"
|
2023-01-04 12:24:36 -05:00
|
|
|
|
|
|
|
conf := testconfig.GetTestConfigSectionFromStruct("markup", mconf)
|
|
|
|
|
|
|
|
p, err := asciidocext.Provider.New(
|
2020-07-23 09:59:48 -04:00
|
|
|
converter.ProviderConfig{
|
2023-01-04 12:24:36 -05:00
|
|
|
Conf: conf,
|
2023-06-16 02:17:42 -04:00
|
|
|
Logger: loggers.NewDefault(),
|
2020-07-23 09:59:48 -04:00
|
|
|
},
|
|
|
|
)
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
ac := conv.(*internal.AsciidocConverter)
|
2020-07-23 09:59:48 -04:00
|
|
|
c.Assert(ac, qt.Not(qt.IsNil))
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
args := ac.ParseArgs(converter.DocumentContext{})
|
2020-07-23 09:59:48 -04:00
|
|
|
expected := []string{"-b", "manpage", "--section-numbers", "--verbose", "--failure-level", "warn", "--safe-mode", "safe"}
|
|
|
|
c.Assert(args, qt.DeepEquals, expected)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAsciidoctorDisallowedArgs(t *testing.T) {
|
|
|
|
c := qt.New(t)
|
|
|
|
mconf := markup_config.Default
|
|
|
|
mconf.AsciidocExt.Backend = "disallowed-backend"
|
2021-01-11 03:46:31 -05:00
|
|
|
mconf.AsciidocExt.Extensions = []string{"./disallowed-extension"}
|
2020-07-23 09:59:48 -04:00
|
|
|
mconf.AsciidocExt.Attributes = map[string]string{"outdir": "disallowed-attribute"}
|
|
|
|
mconf.AsciidocExt.SafeMode = "disallowed-safemode"
|
|
|
|
mconf.AsciidocExt.FailureLevel = "disallowed-failurelevel"
|
2023-01-04 12:24:36 -05:00
|
|
|
|
|
|
|
conf := testconfig.GetTestConfigSectionFromStruct("markup", mconf)
|
|
|
|
|
|
|
|
p, err := asciidocext.Provider.New(
|
2020-07-23 09:59:48 -04:00
|
|
|
converter.ProviderConfig{
|
2023-01-04 12:24:36 -05:00
|
|
|
Conf: conf,
|
2023-06-16 02:17:42 -04:00
|
|
|
Logger: loggers.NewDefault(),
|
2020-07-23 09:59:48 -04:00
|
|
|
},
|
|
|
|
)
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
ac := conv.(*internal.AsciidocConverter)
|
2020-07-23 09:59:48 -04:00
|
|
|
c.Assert(ac, qt.Not(qt.IsNil))
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
args := ac.ParseArgs(converter.DocumentContext{})
|
2020-09-08 04:00:57 -04:00
|
|
|
expected := []string{"--no-header-footer"}
|
2020-07-23 09:59:48 -04:00
|
|
|
c.Assert(args, qt.DeepEquals, expected)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
}
|
|
|
|
|
2021-01-11 03:46:31 -05:00
|
|
|
func TestAsciidoctorArbitraryExtension(t *testing.T) {
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c := qt.New(t)
|
|
|
|
mconf := markup_config.Default
|
2021-01-11 03:46:31 -05:00
|
|
|
mconf.AsciidocExt.Extensions = []string{"arbitrary-extension"}
|
2023-01-04 12:24:36 -05:00
|
|
|
conf := testconfig.GetTestConfigSectionFromStruct("markup", mconf)
|
|
|
|
p, err := asciidocext.Provider.New(
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
converter.ProviderConfig{
|
2023-01-04 12:24:36 -05:00
|
|
|
Conf: conf,
|
2023-06-16 02:17:42 -04:00
|
|
|
Logger: loggers.NewDefault(),
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
},
|
|
|
|
)
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
ac := conv.(*internal.AsciidocConverter)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c.Assert(ac, qt.Not(qt.IsNil))
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
args := ac.ParseArgs(converter.DocumentContext{})
|
2021-01-11 03:46:31 -05:00
|
|
|
expected := []string{"-r", "arbitrary-extension", "--no-header-footer"}
|
2020-07-23 09:59:48 -04:00
|
|
|
c.Assert(args, qt.DeepEquals, expected)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
}
|
|
|
|
|
2021-01-11 03:46:31 -05:00
|
|
|
func TestAsciidoctorDisallowedExtension(t *testing.T) {
|
|
|
|
c := qt.New(t)
|
2023-01-04 12:24:36 -05:00
|
|
|
|
2021-01-11 03:46:31 -05:00
|
|
|
for _, disallowedExtension := range []string{
|
|
|
|
`foo-bar//`,
|
|
|
|
`foo-bar\\ `,
|
|
|
|
`../../foo-bar`,
|
|
|
|
`/foo-bar`,
|
|
|
|
`C:\foo-bar`,
|
|
|
|
`foo-bar.rb`,
|
|
|
|
`foo.bar`,
|
|
|
|
} {
|
|
|
|
mconf := markup_config.Default
|
|
|
|
mconf.AsciidocExt.Extensions = []string{disallowedExtension}
|
2023-01-04 12:24:36 -05:00
|
|
|
conf := testconfig.GetTestConfigSectionFromStruct("markup", mconf)
|
|
|
|
p, err := asciidocext.Provider.New(
|
2021-01-11 03:46:31 -05:00
|
|
|
converter.ProviderConfig{
|
2023-01-04 12:24:36 -05:00
|
|
|
Conf: conf,
|
2023-06-16 02:17:42 -04:00
|
|
|
Logger: loggers.NewDefault(),
|
2021-01-11 03:46:31 -05:00
|
|
|
},
|
|
|
|
)
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
ac := conv.(*internal.AsciidocConverter)
|
2021-01-11 03:46:31 -05:00
|
|
|
c.Assert(ac, qt.Not(qt.IsNil))
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
args := ac.ParseArgs(converter.DocumentContext{})
|
2021-01-11 03:46:31 -05:00
|
|
|
expected := []string{"--no-header-footer"}
|
|
|
|
c.Assert(args, qt.DeepEquals, expected)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
func TestAsciidoctorWorkingFolderCurrent(t *testing.T) {
|
|
|
|
c := qt.New(t)
|
2023-01-04 12:24:36 -05:00
|
|
|
cfg := config.FromTOMLConfigString(`
|
|
|
|
[markup]
|
|
|
|
[markup.asciidocext]
|
|
|
|
workingFolderCurrent = true
|
|
|
|
trace = false
|
|
|
|
`)
|
|
|
|
|
|
|
|
conf := testconfig.GetTestConfig(afero.NewMemMapFs(), cfg)
|
|
|
|
|
|
|
|
p, err := asciidocext.Provider.New(
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
converter.ProviderConfig{
|
2023-01-04 12:24:36 -05:00
|
|
|
Conf: conf,
|
2023-06-16 02:17:42 -04:00
|
|
|
Logger: loggers.NewDefault(),
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
},
|
|
|
|
)
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
|
|
|
ctx := converter.DocumentContext{Filename: "/tmp/hugo_asciidoc_ddd/docs/chapter2/index.adoc", DocumentName: "chapter2/index.adoc"}
|
|
|
|
conv, err := p.New(ctx)
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
ac := conv.(*internal.AsciidocConverter)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c.Assert(ac, qt.Not(qt.IsNil))
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
args := ac.ParseArgs(ctx)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c.Assert(len(args), qt.Equals, 5)
|
|
|
|
c.Assert(args[0], qt.Equals, "--base-dir")
|
|
|
|
c.Assert(filepath.ToSlash(args[1]), qt.Matches, "/tmp/hugo_asciidoc_ddd/docs/chapter2")
|
|
|
|
c.Assert(args[2], qt.Equals, "-a")
|
2023-01-04 12:24:36 -05:00
|
|
|
c.Assert(args[3], qt.Matches, `outdir=.*chapter2`)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c.Assert(args[4], qt.Equals, "--no-header-footer")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAsciidoctorWorkingFolderCurrentAndExtensions(t *testing.T) {
|
|
|
|
c := qt.New(t)
|
2023-01-04 12:24:36 -05:00
|
|
|
cfg := config.FromTOMLConfigString(`
|
|
|
|
[markup]
|
|
|
|
[markup.asciidocext]
|
|
|
|
backend = "html5s"
|
|
|
|
workingFolderCurrent = true
|
|
|
|
trace = false
|
|
|
|
noHeaderOrFooter = true
|
|
|
|
extensions = ["asciidoctor-html5s", "asciidoctor-diagram"]
|
|
|
|
`)
|
|
|
|
conf := testconfig.GetTestConfig(afero.NewMemMapFs(), cfg)
|
|
|
|
|
|
|
|
p, err := asciidocext.Provider.New(
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
converter.ProviderConfig{
|
2023-01-04 12:24:36 -05:00
|
|
|
Conf: conf,
|
2023-06-16 02:17:42 -04:00
|
|
|
Logger: loggers.NewDefault(),
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
},
|
|
|
|
)
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
ac := conv.(*internal.AsciidocConverter)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c.Assert(ac, qt.Not(qt.IsNil))
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
args := ac.ParseArgs(converter.DocumentContext{})
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c.Assert(len(args), qt.Equals, 11)
|
|
|
|
c.Assert(args[0], qt.Equals, "-b")
|
|
|
|
c.Assert(args[1], qt.Equals, "html5s")
|
|
|
|
c.Assert(args[2], qt.Equals, "-r")
|
|
|
|
c.Assert(args[3], qt.Equals, "asciidoctor-html5s")
|
|
|
|
c.Assert(args[4], qt.Equals, "-r")
|
|
|
|
c.Assert(args[5], qt.Equals, "asciidoctor-diagram")
|
|
|
|
c.Assert(args[6], qt.Equals, "--base-dir")
|
|
|
|
c.Assert(args[7], qt.Equals, ".")
|
|
|
|
c.Assert(args[8], qt.Equals, "-a")
|
|
|
|
c.Assert(args[9], qt.Contains, "outdir=")
|
|
|
|
c.Assert(args[10], qt.Equals, "--no-header-footer")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestAsciidoctorAttributes(t *testing.T) {
|
|
|
|
c := qt.New(t)
|
2023-01-04 12:24:36 -05:00
|
|
|
cfg := config.FromTOMLConfigString(`
|
|
|
|
[markup]
|
|
|
|
[markup.asciidocext]
|
|
|
|
trace = false
|
|
|
|
[markup.asciidocext.attributes]
|
|
|
|
my-base-url = "https://gohugo.io/"
|
|
|
|
my-attribute-name = "my value"
|
|
|
|
`)
|
|
|
|
conf := testconfig.GetTestConfig(nil, cfg)
|
|
|
|
p, err := asciidocext.Provider.New(
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
converter.ProviderConfig{
|
2023-01-04 12:24:36 -05:00
|
|
|
Conf: conf,
|
2023-06-16 02:17:42 -04:00
|
|
|
Logger: loggers.NewDefault(),
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
},
|
|
|
|
)
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
ac := conv.(*internal.AsciidocConverter)
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c.Assert(ac, qt.Not(qt.IsNil))
|
|
|
|
|
|
|
|
expectedValues := map[string]bool{
|
|
|
|
"my-base-url=https://gohugo.io/": true,
|
|
|
|
"my-attribute-name=my value": true,
|
|
|
|
}
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
args := ac.ParseArgs(converter.DocumentContext{})
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
c.Assert(len(args), qt.Equals, 5)
|
|
|
|
c.Assert(args[0], qt.Equals, "-a")
|
|
|
|
c.Assert(expectedValues[args[1]], qt.Equals, true)
|
|
|
|
c.Assert(args[2], qt.Equals, "-a")
|
|
|
|
c.Assert(expectedValues[args[3]], qt.Equals, true)
|
|
|
|
c.Assert(args[4], qt.Equals, "--no-header-footer")
|
|
|
|
}
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
func getProvider(c *qt.C, mConfStr string) converter.Provider {
|
|
|
|
confStr := `
|
|
|
|
[security]
|
|
|
|
[security.exec]
|
|
|
|
allow = ['asciidoctor']
|
|
|
|
`
|
|
|
|
confStr += mConfStr
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
cfg := config.FromTOMLConfigString(confStr)
|
|
|
|
conf := testconfig.GetTestConfig(nil, cfg)
|
|
|
|
securityConfig := conf.GetConfigSection("security").(security.Config)
|
|
|
|
|
|
|
|
p, err := asciidocext.Provider.New(
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
converter.ProviderConfig{
|
2023-06-16 02:17:42 -04:00
|
|
|
Logger: loggers.NewDefault(),
|
2023-01-04 12:24:36 -05:00
|
|
|
Conf: conf,
|
|
|
|
Exec: hexec.New(securityConfig),
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
},
|
|
|
|
)
|
|
|
|
c.Assert(err, qt.IsNil)
|
2021-12-12 06:11:11 -05:00
|
|
|
return p
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestConvert(t *testing.T) {
|
2023-01-04 12:24:36 -05:00
|
|
|
if !asciidocext.Supports() {
|
2021-12-12 06:11:11 -05:00
|
|
|
t.Skip("asciidoctor not installed")
|
|
|
|
}
|
|
|
|
c := qt.New(t)
|
|
|
|
|
2023-01-04 12:24:36 -05:00
|
|
|
p := getProvider(c, "")
|
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`.
2020-06-25 03:51:33 -04:00
|
|
|
|
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
|
|
|
|
b, err := conv.Convert(converter.RenderContext{Src: []byte("testContent")})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
c.Assert(string(b.Bytes()), qt.Equals, "<div class=\"paragraph\">\n<p>testContent</p>\n</div>\n")
|
|
|
|
}
|
2020-08-24 13:23:16 -04:00
|
|
|
|
|
|
|
func TestTableOfContents(t *testing.T) {
|
2023-01-04 12:24:36 -05:00
|
|
|
if !asciidocext.Supports() {
|
2020-09-09 17:41:53 -04:00
|
|
|
t.Skip("asciidoctor not installed")
|
2020-08-24 13:23:16 -04:00
|
|
|
}
|
|
|
|
c := qt.New(t)
|
2023-01-04 12:24:36 -05:00
|
|
|
p := getProvider(c, "")
|
2021-12-12 06:11:11 -05:00
|
|
|
|
2020-08-24 13:23:16 -04:00
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
2020-09-16 18:02:35 -04:00
|
|
|
r, err := conv.Convert(converter.RenderContext{Src: []byte(`:toc: macro
|
2020-08-24 13:23:16 -04:00
|
|
|
:toclevels: 4
|
|
|
|
toc::[]
|
|
|
|
|
|
|
|
=== Introduction
|
|
|
|
|
|
|
|
== Section 1
|
|
|
|
|
|
|
|
=== Section 1.1
|
|
|
|
|
|
|
|
==== Section 1.1.1
|
|
|
|
|
|
|
|
=== Section 1.2
|
|
|
|
|
|
|
|
testContent
|
|
|
|
|
|
|
|
== Section 2
|
|
|
|
`)})
|
|
|
|
c.Assert(err, qt.IsNil)
|
2020-09-16 18:02:35 -04:00
|
|
|
toc, ok := r.(converter.TableOfContentsProvider)
|
2020-08-24 13:23:16 -04:00
|
|
|
c.Assert(ok, qt.Equals, true)
|
2023-02-11 10:20:24 -05:00
|
|
|
|
|
|
|
c.Assert(toc.TableOfContents().Identifiers, qt.DeepEquals, collections.SortedStringSlice{"_introduction", "_section_1", "_section_1_1", "_section_1_1_1", "_section_1_2", "_section_2"})
|
2020-09-16 18:02:35 -04:00
|
|
|
c.Assert(string(r.Bytes()), qt.Not(qt.Contains), "<div id=\"toc\" class=\"toc\">")
|
2020-08-24 13:23:16 -04:00
|
|
|
}
|
2020-09-09 17:41:53 -04:00
|
|
|
|
|
|
|
func TestTableOfContentsWithCode(t *testing.T) {
|
2023-01-04 12:24:36 -05:00
|
|
|
if !asciidocext.Supports() {
|
2020-09-09 17:41:53 -04:00
|
|
|
t.Skip("asciidoctor not installed")
|
|
|
|
}
|
|
|
|
c := qt.New(t)
|
2023-01-04 12:24:36 -05:00
|
|
|
p := getProvider(c, "")
|
2020-09-09 17:41:53 -04:00
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
2020-09-16 18:02:35 -04:00
|
|
|
r, err := conv.Convert(converter.RenderContext{Src: []byte(`:toc: auto
|
2020-09-09 17:41:53 -04:00
|
|
|
|
|
|
|
== Some ` + "`code`" + ` in the title
|
|
|
|
`)})
|
|
|
|
c.Assert(err, qt.IsNil)
|
2020-09-16 18:02:35 -04:00
|
|
|
toc, ok := r.(converter.TableOfContentsProvider)
|
|
|
|
c.Assert(ok, qt.Equals, true)
|
2023-02-11 10:20:24 -05:00
|
|
|
c.Assert(toc.TableOfContents().HeadingsMap["_some_code_in_the_title"].Title, qt.Equals, "Some <code>code</code> in the title")
|
2020-09-16 18:02:35 -04:00
|
|
|
c.Assert(string(r.Bytes()), qt.Not(qt.Contains), "<div id=\"toc\" class=\"toc\">")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestTableOfContentsPreserveTOC(t *testing.T) {
|
2023-01-04 12:24:36 -05:00
|
|
|
if !asciidocext.Supports() {
|
2020-09-16 18:02:35 -04:00
|
|
|
t.Skip("asciidoctor not installed")
|
|
|
|
}
|
|
|
|
c := qt.New(t)
|
2023-01-04 12:24:36 -05:00
|
|
|
confStr := `
|
|
|
|
[markup]
|
|
|
|
[markup.asciidocExt]
|
|
|
|
preserveTOC = true
|
|
|
|
`
|
|
|
|
p := getProvider(c, confStr)
|
2021-12-12 06:11:11 -05:00
|
|
|
|
2020-09-16 18:02:35 -04:00
|
|
|
conv, err := p.New(converter.DocumentContext{})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
r, err := conv.Convert(converter.RenderContext{Src: []byte(`:toc:
|
|
|
|
:idprefix:
|
|
|
|
:idseparator: -
|
|
|
|
|
|
|
|
== Some title
|
|
|
|
`)})
|
|
|
|
c.Assert(err, qt.IsNil)
|
|
|
|
toc, ok := r.(converter.TableOfContentsProvider)
|
2020-09-09 17:41:53 -04:00
|
|
|
c.Assert(ok, qt.Equals, true)
|
2023-02-11 10:20:24 -05:00
|
|
|
|
|
|
|
c.Assert(toc.TableOfContents().Identifiers, qt.DeepEquals, collections.SortedStringSlice{"some-title"})
|
2020-09-16 18:02:35 -04:00
|
|
|
c.Assert(string(r.Bytes()), qt.Contains, "<div id=\"toc\" class=\"toc\">")
|
2020-09-09 17:41:53 -04:00
|
|
|
}
|