A port of Asciidoctor (AsciiDoc processor) to MoonBit
///|
test "convert a string" {
let html = @asciidoctor.convert("A paragraph with *strong* and _emphasis_.")
inspect(
html,
content=(
#|<div class="paragraph">
#|<p>A paragraph with <strong>strong</strong> and <em>emphasis</em>.</p>
#|</div>
),
)
}///|
test "options" {
let options = @core.Options::new(backend="docbook5", attributes=[
("product", Str("MoonBit")),
])
inspect(
@asciidoctor.convert("Hello from {product}.", options~),
content=(
#|<simpara>Hello from MoonBit.</simpara>
),
)
}///|
test "load and inspect" {
let doc = @asciidoctor.load(
(
#|= Document Title
#|
#|== First Section
#|
#|content
),
)
inspect(doc.doctitle().unwrap(), content="Document Title")
let section = doc.blocks[0]
inspect(section.context.name(), content="section")
inspect(section.title().unwrap(), content="First Section")
inspect(section.id.unwrap(), content="_first_section")
}///|
test "inline macro extension" {
let exts = @core.Extensions::new()
exts.inline_macro("man", (parent, target, attrs) => {
let label = "\{target}(\{attrs.pos_str(1).unwrap_or("")})"
Some(
InlineNode(
@core.create_anchor(
parent,
Some(label),
"link",
target="\{target}.html",
),
),
)
})
let html = @asciidoctor.convert(
"See man:git[1].",
options=@core.Options::new(extensions=exts),
)
inspect(
html,
content=(
#|<div class="paragraph">
#|<p>See <a href="git.html">git(1)</a>.</p>
#|</div>
),
)
}moon build --target native cmd/asciidoctor
./_build/native/debug/build/cmd/asciidoctor/asciidoctor.exe -b html5 -a toc doc.adoc| passing | |
|---|---|
| AST snapshots | 2506 / 2612 |
| converted outputs (HTML5, DocBook5, manpage) | 1705 / 1819 |
| unexpected failures | 0 |
| path | contents |
|---|---|
| regex/ | backtracking regex engine with Ruby (Onigmo) semantics over UTF-16 |
| internal/rb/ | Ruby-compatible string and number helpers (strip, split, succ, Float#to_s, Unicode case mapping) |
| core/ | document model, reader/preprocessor, parser, substitutions, extensions API, converter interface |
| converter/html5, converter/docbook5, converter/manpage | converters |
| io/ | async file-system integration (load_file, convert_file) |
| cmd/asciidoctor | CLI |
| cmd/golden, scripts/ | golden harvesting/replay, regex oracle, corpus comparison |
moon run --target native scripts/check.mbtx # check/test on all targets + golden parity
moon run --target native scripts/check.mbtx -- --corpus # also compare the corpora with Ruby
moon run --target native scripts/corpus.mbtx -- -v # corpus comparison only
moon run --target native scripts/harvest.mbtx # regenerate goldens (needs Ruby + nokogiri)
moon run --target native cmd/golden -- -v -n 20 # golden replay with failure details
moon run --target native cmd/golden -- --prune-known # drop fixed entries from known_failures.txttest {
let html = @asciidoctor.convert("Hello, *World*!")
inspect(
html,
content=(
#|<div class="paragraph">
#|<p>Hello, <strong>World</strong>!</p>
#|</div>
),
)
}