Asciidoctor HTML: choose a document instead of an unexplained fragment

Deliver one converted workshop note with its authoring source and chosen document wrapper.

The conversion returns a paragraph, but the file you need to send should have a document wrapper. Choose the converter's standalone-document option explicitly. A string conversion and a complete HTML delivery are different outputs, even when both contain the expected sentence.

Start with a fictional workshop note. Keep the original AsciiDoc as the authoring source:

Native Asciidoctor4 output: complete workshop note
Native Asciidoctor4 output: complete workshop note
Open the full example ↗

Open the complete example · Download the full HTML source

= Workshop packing note

Each tray holds *six items*.

== Before delivery

* Confirm the tray count.
* Retain the packing rule with the estimate.

The desired reading output is a titled note with a strong phrase, a section heading, and two list items. The quantities are an illustrative rule, not an observed warehouse specification.

Match the recipe to the installed API

The Asciidoctor.js quick tour currently documents direct imports from @asciidoctor/core and asynchronous conversion:

import { convert } from '@asciidoctor/core';

const html = await convert(source, { standalone: true });

Here, source is the complete AsciiDoc string above. The import needs the corresponding package environment; it is not a browser script that can be pasted into an arbitrary plain HTML file. Record the actual package version when producing the deliverable.

The quick tour explains that string conversion excludes the header and footer by default. Without the standalone option, a fragment is useful when an existing application already provides the surrounding document. Do not wrap a standalone result inside another complete document merely because an embedding slot expects a fragment.

Decide how styles travel

Document structure and styling are separate delivery choices. The documentation describes embedded default styling under its stated safe-mode conditions and a linkcss attribute for linked stylesheets. Inspect the output you actually produce rather than assuming every stylesheet is embedded under every option.

For a file that must travel alone, check its stylesheet and image references. A local path that worked on the author's computer is still an external dependency for the recipient. Keep safe-mode decisions explicit and convert trusted source material; do not relax the processing boundary just to make an unknown include resolve.

Review the document, then retain its source

Compare the rendered title, strong text, section heading, and two list items with the source. Search the generated file for external dependencies and open the actual delivered copy under the intended browser conditions. Keep the generated HTML with the original .adoc text and the conversion options.

The existing AsciiDoc static-site guide addresses Antora's versioned resource identities and cross-page references. This recipe converts one source document and distinguishes a fragment from a complete document. It does not run an Antora site build or establish generated site URLs.

Use the HTML reading copy in NOS to discuss the wording of the packing note. Apply lasting source changes to the AsciiDoc original, then convert again so the next delivery contains the same instructions the author maintains.

Download the AsciiDoc original · Download the AsciiDoc original and HTML fragment (ZIP)

Keep reading