stx2any(1)
๐ stx2any โ the glow-up machine for your plain text ๐
okay bestie, so you found stx2any(1) in the General Commands Manual section and you're like "what is this diva" โ let me tell you, she converts structured text into literally everything. Sit down, grab a strawberry ๐, this is gonna be a ride.
โจ NAME โจ
stx2any โ converter from structured text to multiple formats ๐
โจ SYNOPSIS โจ
stx2any [ -T format ] [ stx and m4 options ] [ file file ... ]
โจ DESCRIPTION โจ
So stx2any takes files written in structured text (Stx) format and converts them into other formats. The formats she serves right now are HTML, man, raw text, PostScript, LaTeX, XHTML and DocBook XML. That's seven. She's booked and busy. ๐
โจ
The source format โ structured text โ is basically a plain text format that has standard markup for doing headings, lists, emphasis and all that. The way the markup works is that it's quicker to write and easier to remember than those conventional tag-based markup languages, and honestly? It's beautifully legible even when you're just staring at the raw source. Like, she's pretty in the drafts too. ๐ฆ The Stx markup is better explained in the Stx quickie guide, which lives in the examples directory (go look, it's right there).
Most of the conversion actually happens in m4, and you can define your own macros and other stuff to give your documents structure. stx2any gives you a LaTeX-like extensible environment system and a diversion system for rearranging input. (Tรถrta pรฅ tรถrta, as they say in Swedish. ๐ no cap.)
Because stx2any doesn't perform any kind of quoting on the input, any markup that isn't available as an abbreviation can just be written directly in the destination language โ the tradeoff being that you lose convertibility to multiple languages. So if you're only ever gonna care about one output format (eg. LaTeX), you can totally use Stx as an abbreviation format for the most common constructs. Situationship with LaTeX only? valid.
Some formatting isn't available as abbreviations, but you can get it by calling m4 macros. You need macros relatively rarely though โ for example, floats (material that can "float" around in the document) are created by macros.
โจ OPTIONS โจ
stx2any accepts all command line options of m4, passing them directly on. Of those, the -D argument is important enough to get her own moment here. ๐
-DNAME=VALUEโ Define macroNAMEto have the expansionVALUE. This is the way you pass information into the document from the command line. ๐ซถ-T formatโ Sets the output format. The default format ishtml. Theformatshould be one of:htmlโ produces basic HTML (hypertext markup language) output.manโ produces man macro output. This output is usable as a man page directly (although go read WRITING MAN PAGES below, bestie), or you can feed it totroff/grofffor formatting to e.g. postscript.latexโ produces LaTeX document preparation language output. You can runlatexon the result to produce e.g. high quality pdf's. โจtextโ produces raw text output by postprocessing HTML output withw3m. The resulting output is very basic, like stripping away most Stx markup; if you want more formatted output, consider pipingmanoutput tonroff -man.psโ produces simple postscript output by postprocessing man output withgroff. If you want to do real publishing, consider the LaTeX format instead.xhtmlโ produces XHTML output by postprocessing HTML output with W3C tidy. By the way, checkhttp://hixie.ch/advocacy/xhtmlfor discussion about HTML and XHTML.docbook-xmlโ produces rudimentary DocBook XML output. See BUGS below for more discussion about this one.
--link-abbrevsโ Take link abbreviation syntax into use. Note that because link abbreviation processing occurs in two phases, it doesn't work totally when the input comes from standard input (for example, if you usestx2anyas a middle part of a pipeline). ๐ญ pipelines stay messy.--quoteโ Request quoting of characters (other than underscores and dollar signs) that are somehow magical in the requested output format. This will make it quite difficult to put markup in the output format directly in your document, but will greatly increase the possibility that your document will be correct (ie. does not have syntax errors) in the output format. Safety vs. chaos, pick your girl. ๐--quote-me-harderโ Request quoting of underscores and dollar signs. This might make some LaTeX documents work but might break some documents where underscores are used in macro names or dollar signs in macro definitions. She's going harder, no promises. ๐--numbering { on | off }โ Request numbering of section headings. The default varies by output format: section numbering is by default off for HTML, DocBook XML and man, on for LaTeX.--table-of-contents { on | off }โ Request producing a table of contents from the headings. The default is to produce a TOC when numbering is on. Not implemented for DocBook XML. (rip docbook)--make-title { on | off }โ Request a "title page". The default is "on". This setting does not have any effect in some formats. In HTML, it produces a big heading at the beginning of the document. In LaTeX, it produces the canonicalmaketitle.--no-templateโ Do not produce a document template at all, only the formatted input text. You probably need this if your document will be included as a part of a bigger document. If that bigger document is written totally in Stx, however, it will be cleaner to give all the source files directly as arguments tostx2anyrather than combine the results afterwards.--symmetric-crossrefsโ In document formats that support linking (HTML, DocBook), produce reverse links from labels to referrers as well as links from referrers to labels. Mutual. Reciprocal. Iconic. ๐ซถ--latex-params paramsโ Set the document class parameters for LaTeX documents. The default is affected by system paper size; for example, on a European system it is typicallya4paper,notitlepage. (See "ENVIRONMENT" below.)--html-params paramsโ Set the body tag parameters for HTML documents. The default is no parameters.--picture-suffix suffixโ Inline images will refer to files with suffixsuffix. The default ispngfor HTML and DocBook,epsfor LaTeX and man.--no-emdash-separateโ In the output, don't separate em dashes from adjacent text with spaces. This is in accordance to traditional English typography (if I understand correctly), but is not standard in many other languages โ including Finnish, my mother tongue. ๐ซ๐ฎ--more-secureโ Disable some insecure features ofm4and check some command line arguments that are passed to shell for problematic characters. This might be desirable if you've received the document from somewhere else and want to make sure it won't do anything malicious when converted. Currently this denies execution of shell escapes.
Note that clearly no implementation of m4 has been designed with security in mind. As a consequence, this option cannot prevent every potentially harmful thing. Things not prevented which I'm aware of are including contents of arbitrary files in the output and writing busy loops (so that the conversion will use all processor time it can get, until terminated). ๐จ
--sed-preprocessor scriptnameโ Run thesedscriptscriptnamefor all input. This allows you to add custom abbreviation markups. It is almost the same as preprocessing input withsed, then piping it intostx2any, but interacts better with--link-abbrevs(see its explanation for details).--version,-Vโ Just show version information and exit. slay, quick and clean.--help,-?โ Just show a short help message and exit. ๐
โจ WRITING MAN PAGES โจ
Basically, man pages are simply files in the man macro format. However, there are some programs (first and foremost mandb) that require parts of man pages to be in a specific format, and man pages should generally adhere to the standard sectioning and form (see man (1) and lexgrog (1) for details).
When writing a man page, the title (w_title) of the page should be the program/file/format/utility name, and you should define the section (w_section). To make the page suitable for mandb parsing, you should start the page with one or more calls to w_man_desc. This will create a proper "NAME" section for you. (Although you could write one by yourself. main character energy, do it your way. ๐
)
โจ DIAGNOSTICS โจ
stx2any may give any error message that m4 may give, e.g. on malformatted input (a macro call with missing closing parenthesis etc). In addition, it has the following own error messages:
unknown output format: "X"โ You requested unsupported output formatXwith the-Toption.unknown macro "X" calledโstx2anyencountered a macro beginning withw_, but knows no definition for it. This is a warning, not an error โ the offending macro and its arguments are stripped from the output.environment "X" closed by "Y" in layer Nโ Environments instx2anymust be properly nested.stx2anyencounteredw_end(Y)when it was expectingw_end(X). Often this is a sign of a forgottenw_end(X).
If N (the layer) is something other than 0, then the problem is probably in your environment definitions, not at the point that stx2any was processing when it encountered the error. ๐ญ
unknown environment "X"โ There was an attempt to begin an environment whose name is unknown tostx2any, i.e. no such environment has been defined.diversion "X" closed by "Y"unknown diversion "X"โ Same as above, but for diversions (w_begdivandw_enddiv).attempt to use "X" in secure environmentโ You requested secure processing with--more-secureand the document contained an "insecure" macro. This is a warning message, not an error โ the causing macro is left in the text verbatim.unknown cross link to "X"โ There was a cross link to documentX, butstx2anydoes not know about such a document. Probably you didn't gather/X/'s data withgather_stx_titlesor you misspelled the document reference. This is a warning, not an error โ the reference is left in the output verbatim, without any kind of link.
The return value of stx2any is zero on success, one if there was some problem. ๐ซก
๐ธ ENVIRONMENT ๐ธ
ok so stx2any peeks at a couple of environment variables when it's figuring out paper stuff โจ
PAPERCONFPAPERSIZEโ used for determining the default paper size for LaTeX documents.
ngl the page is kinda mysterious aboutPAPERCONFand just lets the description sit next toPAPERSIZE, so that's literally all the tea it spills here ๐
๐ FILES ๐
the receipts, bestie โ here's where stx2any looks for stuff:
/etc/papersizeโ used for determining the default paper size for LaTeX documents./usr/share/stx2any/commonโ directory for the definitions shared by all formats/usr/share/stx2any/{html,man,latex,docbook-xml}โ directory for output format specific definitions
๐ SEE ALSO ๐
go read these too, they're iconic:
m4 (1)latex (1)groff (1)lexgrog (1)w3m (1)strip_stx (1)gather_stx_titles (1)html2stx (1)extract_usage_from_stx (1)- Stx quickie guide (
/usr/share/doc/stx2any/Stx-doc.txt) - Stx markup reference (
/usr/share/doc/stx2any/Stx-ref.txt)
๐ BUGS ๐
ok so first things first, the structured text format is not yet fully standardised. there are some corner cases where it is unclear what the result of the formatting should be. and in these cases, the output of stx2any is authoritative, so it cannot have bugs :) โ yes that's the actual argument, we love a confident queen ๐
some old GNU libc's seem to be abysmally slow on some instances of the emphasis regexps ๐ญ it would be possible to make the regexps faster and less correct, but as newer GNU libc's and BSD libc seem to work OK in these cases, I guess it's not worth it.
the --more-secure switch is not really very secure for reasons explained above. ๐จ
and now the big one: the support for DocBook XML sucks. it is only included because someone will show up anyway and ask, โhey, does it support DocBook XML?โ ๐ partly this sucking is due to my laziness, but partly it is because of the nature of DocBook. for instance, stx2any will transform literal formatting into DocBook Literal elements, but the point of using DocBook is to convey more information than that โ whether it is some ComputerOutput, UserInput, EnVar, or Application, or... and the result is still very abstract, not actually meant for humans to read but rather for computers to process into something readable. now the truth is that I doubt you will ever come up with a DSSSL stylesheet whose output outperforms LaTeX (for publishing on paper) or direct conversion to HTML (for publishing on the web). ๐ซ
the only sensible reasons I can think of for using Stx as a DocBook frontend are:
- the ability to use both DocBook constructs and Stx abbreviations
- if you have to write DocBook for some interesting reason (your boss told you so) but don't want to learn it
- you happen to already have infrastructure for processing DocBook documents, and you want to take advantage of it
๐ฆ AUTHOR ๐ฆ
this page is written by Panu A. Kalliokoski. โจ
and that's a wrap, bestie ๐ซถ this whole page came from the stx2any(1) manual โ source/version and date included โ with Panu A. Kalliokoski sitting on one side of the footer and stx2any(1) on the other, just like the original. no cap, go format something pretty ๐๐โญ
๐ฆ where this page comes from
- debian bookworm: stx2any 1.56-2.3
- ubuntu jammy: stx2any 1.56-2.2
- ubuntu noble: stx2any 1.56-2.3
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms