adoc/README.adoc

56 lines
1.0 KiB
Plaintext
Raw Normal View History

2022-04-06 06:43:31 +02:00
= README.adoc
2022-04-06
2022-04-06 06:26:42 +02:00
2022-04-06 06:43:31 +02:00
The beginnings of a parser for the https://asciidoc-py.github.io/index.html[Asciidoc] markup language.
2022-04-06 06:26:42 +02:00
== Example
2022-06-11 10:48:27 +02:00
https://go.dev/play/p/hF2wn_GdkBK[Run the snippet below on the Go Playground]
2022-04-06 06:26:42 +02:00
----
package main
import (
"fmt"
"strings"
2024-09-15 12:07:22 +02:00
"go-mod.ewintr.nl/adoc"
2022-04-06 06:26:42 +02:00
)
func main() {
sourceDoc := `= This is the title
And this is the first paragraph. With some text. Lists are supported too:
* Item 1
* Item 2
* Item 3
And we also have things like *bold* and _italic_.`
2022-06-11 10:48:27 +02:00
par := adoc.NewParser(strings.NewReader(sourceDoc))
2022-04-06 06:26:42 +02:00
doc := par.Parse()
2022-06-11 10:48:27 +02:00
htmlDoc := adoc.NewHTMLFormatter().Format(doc)
2022-04-06 06:26:42 +02:00
fmt.Println(htmlDoc)
// output:
//
// <!DOCTYPE html>
// <html>
// <head>
// <title>This is the title</title>
// </head>
// <body>
// <p>And this is the first paragraph. With some text. Lists are supported too:</p>
// <ul>
// <li>Item 1</li>
// <li>Item 2</li>
// <li>Item 3</li>
// </ul>
// <p>And we also have things like <strong>bold</strong> and <em>italic</em>.</p>
// </html>
}
----
2023-05-25 12:35:42 +02:00