このページはまだ翻訳されていません。原文の内容が表示されています。
html
Typst's HTML export is currently under active development. The feature is still
very incomplete and only available for experimentation behind a feature flag. Do
not use this feature for production use cases. In the CLI, you can experiment
with HTML export by passing --features html
or setting the TYPST_FEATURES
environment variables to html
. In the web app, HTML export is not available at
this time. Visit the tracking issue
to follow progress on HTML export and learn more about planned features.
HTML files describe a document structurally. The aim of Typst's HTML export is to capture the structure of an input document and produce semantically rich HTML that retains this structure. The resulting HTML should be accessible, human-readable, and editable by hand and downstream tools.
PDF, PNG, and SVG export, in contrast, all produce visual representations of a fully-laid out document. This divergence in the formats' intents means that Typst cannot simply produce perfect HTML for your existing Typst documents. It cannot always know what the best semantic HTML representation of your content is.
Instead, it gives you full control: You can check the current export format
through the target
function and when it is set to HTML, generate raw HTML
elements. The primary intended use of these elements is in
templates and show rules. This way, the document's contents can be fully
agnostic to the export target and content can be shared between PDF and HTML
export.
Currently, Typst will always output a single HTML file. Support for outputting directories with multiple HTML documents and assets, as well as support for outputting fragments that can be integrated into other HTML documents is planned.
Typst currently does not output CSS style sheets, instead focussing on emitting semantic markup. You can of course write your own CSS styles and still benefit from sharing your content between PDF and HTML. For the future, we plan to give you the option of automatically emitting CSS, taking more of your existing set rules into account.
Exporting as HTML
Command Line
Pass --format html
to the compile
or watch
subcommand or provide an output
file name that ends with .html
. Note that you must also pass --features html
or set TYPST_FEATURES=html
to enable this experimental export target.
When using typst watch
, Typst will spin up a live-reloading HTTP server. You
can configure it as follows:
- Pass
--port
to change the port. (Defaults to the first free port in the range 3000-3005.) - Pass
--no-reload
to disable injection of a live reload script. (The HTML that is written to disk isn't affected either way.) - Pass
--no-serve
to disable the server altogether.
Web App
Not currently available.
HTML-specific functionality
Typst exposes HTML-specific functionality in the global html
module. See below
for the definitions it contains.
定義
- Hyperlink.
- Abbreviation.
- Contact information for a page or article element.
- Hyperlink or dead area on an image map.
- Self-contained syndicatable or reusable composition.
- Sidebar for tangentially related content.
- Audio player.
- Keywords.
- Base URL and default target navigable for hyperlinks and forms.
- Text directionality isolation.
- Text directionality formatting.
- A section quoted from another source.
- Document body.
- Line break, e.g. in poem or postal address.
- Button control.
- Scriptable bitmap canvas.
- Table caption.
- Title of a work.
- Computer code.
- Table column.
- Group of columns in a table.
- Machine-readable equivalent.
- Container for options for combo box control.
- Content for corresponding dt element(s).
- A removal from the document.
- Disclosure control for hiding details.
- Defining instance.
- Dialog box or window.
- Generic flow container, or container for name-value groups in dl elements.
- Association list consisting of zero or more name-value groups.
- Legend for corresponding dd element(s).
- An HTML element that can contain Typst content.
- Stress emphasis.
- Plugin.
- Group of form controls.
- Caption for figure.
- Figure with optional caption.
- Footer for a page or section.
- User-submittable form.
- An element that lays out its content as an inline SVG.
- Heading.
- Heading.
- Heading.
- Heading.
- Heading.
- Heading.
- Container for document metadata.
- Introductory or navigational aids for a page or section.
- Heading container.
- Thematic break.
- Root element.
- Alternate voice.
- Child navigable.
- Image.
- Form control.
- An addition to the document.
- User input.
- Caption for a form control.
- Caption for fieldset.
- List item.
- Link metadata.
- Container for the dominant contents of the document.
- Image map.
- Highlight.
- Menu of commands.
- Text metadata.
- Gauge.
- Section with navigational links.
- Fallback content for script.
- Image, child navigable, or plugin.
- Ordered list.
- Group of options in a list box.
- Option in a list box or combo box control.
- Calculated output value.
- Paragraph.
- Image.
- Block of preformatted text.
- Progress bar.
- Quotation.
- Parenthesis for ruby annotation text.
- Ruby annotation text.
- Ruby annotation(s).
- Inaccurate text.
- Computer output.
- Embedded script.
- Container for search controls.
- Generic document or application section.
- List box control.
- Shadow tree slot.
- Side comment.
- Image source for img or media source for video or audio.
- Generic phrasing container.
- Importance.
- Embedded styling information.
- Subscript.
- Caption for details.
- Superscript.
- Table.
- Group of rows in a table.
- Table cell.
- Template.
- Multiline text controls.
- Group of footer rows in a table.
- Table header cell.
- Group of heading rows in a table.
- Machine-readable equivalent of date- or time-related data.
- Document title.
- Table row.
- Timed text track.
- Unarticulated annotation.
- List.
- Variable.
- Video player.
- Line breaking opportunity.