stx2any(1)

๐Ÿ“ฆ version 1.56, in debian bookworm, ubuntu jammy, ubuntu noble

๐Ÿ’– 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 macro NAME to have the expansion VALUE. This is the way you pass information into the document from the command line. ๐Ÿซถ
  • -T format โ€” Sets the output format. The default format is html. The format should 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 to troff / groff for formatting to e.g. postscript.
    • latex โ€” produces LaTeX document preparation language output. You can run latex on the result to produce e.g. high quality pdf's. โœจ
    • text โ€” produces raw text output by postprocessing HTML output with w3m. The resulting output is very basic, like stripping away most Stx markup; if you want more formatted output, consider piping man output to nroff -man.
    • ps โ€” produces simple postscript output by postprocessing man output with groff. 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, check http://hixie.ch/advocacy/xhtml for 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 use stx2any as 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 canonical maketitle.
  • --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 to stx2any rather 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 typically a4paper,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 suffix suffix. The default is png for HTML and DocBook, eps for 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 of m4 and 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 the sed script scriptname for all input. This allows you to add custom abbreviation markups. It is almost the same as preprocessing input with sed, then piping it into stx2any, 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 format X with the -T option.
  • unknown macro "X" called โ€” stx2any encountered a macro beginning with w_, 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 in stx2any must be properly nested. stx2any encountered w_end(Y) when it was expecting w_end(X). Often this is a sign of a forgotten w_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 to stx2any, i.e. no such environment has been defined.
  • diversion "X" closed by "Y"
  • unknown diversion "X" โ€” Same as above, but for diversions (w_begdiv and w_enddiv).
  • attempt to use "X" in secure environment โ€” You requested secure processing with --more-secure and 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 document X, but stx2any does not know about such a document. Probably you didn't gather /X/'s data with gather_stx_titles or 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 โœจ

  • PAPERCONF
  • PAPERSIZE โ€” used for determining the default paper size for LaTeX documents.
ngl the page is kinda mysterious about PAPERCONF and just lets the description sit next to PAPERSIZE, 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:

  1. the ability to use both DocBook constructs and Stx abbreviations
  2. if you have to write DocBook for some interesting reason (your boss told you so) but don't want to learn it
  3. 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