-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(renderer): add XHTML5 support (#618)
This adds support for XHTML5 output, tests, and the `-b` (or `--bakend`) flag which can now be used like `-b [html,html5,xhtml,xhtml5]`. Tests are enclosed, and we leverage as much as we can from the HTML5 backend. Also, added test cases to cover both HTML and XHTML5 backends, as well as invalid backends. Fixes #601
- Loading branch information
Showing
47 changed files
with
8,767 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
= AsciiDoc Article Title | ||
Firstname Lastname <author@asciidoctor.org> | ||
1.0, July 29, 2014, Asciidoctor 1.5 article template | ||
:toc: | ||
:icons: font | ||
:quick-uri: https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/ | ||
|
||
Content entered directly below the header but before the first section heading is called the preamble. | ||
|
||
== First level heading | ||
|
||
This is a paragraph with a *bold* word and an _italicized_ word. | ||
|
||
.Image caption | ||
image::image-file-name.png[I am the image alt text.] | ||
|
||
This is another paragraph.footnote:[I am footnote text and will be displayed at the bottom of the article.] | ||
|
||
=== Second level heading | ||
|
||
.Unordered list title | ||
* list item 1 | ||
** nested list item | ||
*** nested nested list item 1 | ||
*** nested nested list item 2 | ||
* list item 2 | ||
|
||
This is a paragraph. | ||
|
||
.Example block title | ||
==== | ||
Content in an example block is subject to normal substitutions. | ||
==== | ||
|
||
.Sidebar title | ||
**** | ||
Sidebars contain aside text and are subject to normal substitutions. | ||
**** | ||
|
||
==== Third level heading | ||
|
||
[#id-for-listing-block] | ||
.Listing block title | ||
---- | ||
Content in a listing block is subject to verbatim substitutions. | ||
Listing block content is commonly used to preserve code input. | ||
---- | ||
|
||
===== Fourth level heading | ||
|
||
.Table title | ||
|=== | ||
|Column heading 1 |Column heading 2 | ||
|
||
|Column 1, row 1 | ||
|Column 2, row 1 | ||
|
||
|Column 1, row 2 | ||
|Column 2, row 2 | ||
|=== | ||
|
||
====== Fifth level heading | ||
|
||
[quote, firstname lastname, movie title] | ||
____ | ||
I am a block quote or a prose excerpt. | ||
I am subject to normal substitutions. | ||
____ | ||
|
||
[verse, firstname lastname, poem title and more] | ||
____ | ||
I am a verse block. | ||
Indents and endlines are preserved in verse blocks. | ||
____ | ||
|
||
== First level heading | ||
|
||
TIP: There are five admonition labels: Tip, Note, Important, Caution and Warning. | ||
|
||
// I am a comment and won't be rendered. | ||
|
||
. ordered list item | ||
.. nested ordered list item | ||
. ordered list item | ||
|
||
The text at the end of this sentence is cross referenced to <<_third_level_heading,the third level heading>> | ||
|
||
== First level heading | ||
|
||
This is a link to the https://asciidoctor.org/docs/user-manual/[Asciidoctor User Manual]. | ||
This is an attribute reference {quick-uri}[which links this text to the Asciidoctor Quick Reference Guide]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package xhtml5_test | ||
|
||
import ( | ||
"bufio" | ||
"bytes" | ||
"github.com/bytesparadise/libasciidoc/pkg/renderer/sgml/xhtml5" | ||
"os" | ||
|
||
"github.com/bytesparadise/libasciidoc/pkg/configuration" | ||
"github.com/bytesparadise/libasciidoc/pkg/parser" | ||
"github.com/bytesparadise/libasciidoc/pkg/renderer" | ||
"github.com/davecgh/go-spew/spew" | ||
. "github.com/onsi/ginkgo" //nolint golint | ||
. "github.com/onsi/gomega" //nolint golint | ||
) | ||
|
||
var _ = Describe("article.adoc", func() { | ||
|
||
It("should render without failure", func() { | ||
f, err := os.Open("article.adoc") | ||
Expect(err).ToNot(HaveOccurred()) | ||
reader := bufio.NewReader(f) | ||
config := configuration.NewConfiguration() | ||
doc, err := parser.ParseDocument(reader, config) | ||
Expect(err).ToNot(HaveOccurred()) | ||
GinkgoT().Logf("actual document: `%s`", spew.Sdump(doc)) | ||
buff := &bytes.Buffer{} | ||
ctx := renderer.NewContext(doc, config) | ||
_, err = xhtml5.Render(ctx, doc, buff) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package xhtml5 | ||
|
||
const ( | ||
lineBreakTmpl = "<br/>" | ||
blankLineTmpl = "\n\n" | ||
) |
Oops, something went wrong.