ossp-pkg/sugar/sugar.sug
Sugar - The Markup Language With Invisible Syntactic Sugar
==========================================================
Title: Sugar
Subtitle: The Markup Language With Invisible Syntactic Sugar
Author: Ralf S. Engelschall <rse@engelschall.com>
Author: Christian Reiber <chrei@krischan.org>
Genesis: 12-Mar-1999
Date: 08-Mar-2002
Introduction
------------
Sugar is a markup language and corresponding translator tool for
writing technical documentation that uses mostly invisible markup
tags (the so-called //syntactic sugar// in compiler construction folk
terminology).
The general idea is that the markup text looks already mostly like
the textual output of the translator phase, that is, the Sugar source
can be already treated as its text output format ("ASCII WYSIWYG").
Additionally the Sugar markup language is considered intuitive enough
to be recognized easily, so writing technical documentation is mainly
just a matter of performing a brain dump.
So, Sugars syntactic principle is "keep it simple, stupid" (KISS)
but still powerful enough to allow one to produce high-quality
output. Sugars goal is not to provide all features of a full-featured
documentation system. Instead it provides only a few markup concepts
but those are streched to their maximum.
Sugar Grammar
-------------
A Sugar document is described by the following grammar:
++ | | | |
| <document> | ::= | <block>* |
| <block> | ::= | <tagged-block> \| <regular-block> |
| <tagged-block> | ::= | <1d-block> \| <2d-block> |
| <1d-block> | ::= | <1d-tag> <document> |
| <2d-block> | ::= | <2d-tag> <document> |
| <1d-tag> | ::= | "!!##!!" \| "!!\|\!!|" \| "!!``!!" \| "!!''!!" \| ... |
| <2d-tag> | ::= | "!!**!!" \| ... |
where <regular-block> is defined visually as a rectangular block
of continued text inside the document, that is a paragraph of
text (without any blank lines) where each line starts at the same
indentation position.
Block Concept
-------------
\n\s*<tag>\s+ -> <2d-tag>
<tag> -> <1d-tag>
Markup Language
---------------
The Sugar markup language consists of markup tags grouped into a few
classes:
o ..Formatting..
For visual formatting of text the following tags exists. They can
be used either as a <1d-tag>, inlined in a paragraph by using them
twice (to delimit begin and end) or as a <2d-tag> for marking
up a whole block by using them in marched-out way (to delimit
the indented block). The tags (and any number of concatenated
repetitions of them) are also allowed to be placed at the end of a
<1d-block>. Then they conver the whole (preceeding) block text.
++ | tag | formatting | allowed context |
| !!__!! | underline | inline |
| !!**!! | bold | inline |
| !!//!! | italics | inline |
| !!''!! | code | inline, block |
| !!==!! | header (level I) | block |
| !!--!! | header (level II) | block |
| !!~~!! | header (level III)| block |
| !!..!! | header (level IV) | block |
| !!\!\!!! | verbatim | inline, block |
| !![[!! | boxed | block |
| !!>>!! | indented | block |
| !!%%!! | centered | block |
| !!))!! | right flushed | block |
| !!((!! | left flushed | block |
Example:
!! A headline
==========
This line contains //italic// and **bold** words.
>> '' And this paragraph contains
indented code.
And this line again is __non-indented__ text.
o ..Links and References..
For referencing textual locations (both document internal and to
external documents), links can be specified.
++ | construct | description |
| !!->!![//text//]!!(!!//scheme//!!:!!//path//!!)!! |
external hyperlink via URL |
| !!->!!//text//!!(!!//ref//!!)!! |
internal hyperlink via anchor name |
| !!(+!!//ref//!!+)!! |
internal anchor definition |
Example:
!! Header A (+hA+)
--------
This is text of header A. For B see ->header B(hB).
For Sugar go to ->(http://www.ossp.org/pkg/tool/sugar/).
Header B (+hB+)
--------
This is text of header B. For A see ->header A(hA).
For other neat things watch ->OSSP(http://www.ossp.org/).
o ..List Environment..
Three types of list environments can be used. They are identified
by the first non-blank word in the first line of each list item.
For ordered lists the start position is selectable by specifying an
explicit digit instead of the generic item character.
++ | construct | alternatives | type |
| !!-!! | !!o!!, !!*!! | unordered |
| !!-.!! | !!o.!!, !!*.!!, m/[0-9]+\./ | ordered |
| <block> !!::!! | | itemized |
Example:
!! A Sugar list:
1. foo
o. bar
- baz
- foobar
o. quux
o ..Table Environment..
A generic table environment is provided for any type of data which
has to be rendered in a tabular layout. A table is a <2d-block>
starting with a !!++!! tag.
The contents of the <2d-block> consists of a 2-dimensional table
specified by cells. The table cells are seperated by ''|''
characters. Every row has to start with a ''|'' at the same
horizontal position. The number of columns is indicated by the
first table row. This first row can be either a complete (all cells
are specified) and regular (the contents is used) row, or (in case
the first //regular// row is not a complete one, that is, it has
multi-column cell spans), the first row can be an empty row (all
cells are specified for indication but are left blank).
The ''|'' marks can be placed arbitrary in each row, but if
multi-column spans exists, the surrounding ''|'' marks have to be
placed exactly at the same horizontal character position as the
first table row has (else the multi-column cells are ambiguous).
Empty rows can be indicated by using just the starting ''|'' mark.
Example:
!!
++ | | | |
| foo | !!bar | quux |
|
| foo | baz
bar | quux |
| bazfoo
fjfjkwq
rwrqwd sddksjk
| dsdjks
| foo |
| dsdsds |
____
o ..Special Formatting..
'' quotemeta
## command (charblock until EOL)
`` shell command (charblock until EOL)
o ..Escaping and Special Characters..
-- em-dash (ger. "Gedankenstrich")
\_ strong blank (prevents line break as in HTML's )
\n line break (as in HTML's <br>)
\\ a backslash (there no block concept!)
\X escapes following character X
\{name}
o ..Commands (all charblock until EOL)..
##! <shebang>
##include
##// line comment
##/* block comment anfang
##*/ block comment ende
##if
##elsif
##endif
##img ...
##<formatierung> [range]
Sugar Output Formatting
-----------------------
The Sugar transformation tool parses a Sugar source text, transforms
it into an internal abstracted syntax tree and finally applies to it a
particular output formatting module in order to transform the abstract
syntax tree into target markup language. The target language then is
either already an end-user document (HTML, Text, etc.) or intended for
post-processing by external programs (LaTeX, PDF, etc.).
The following outputs are supported:
++ | sugar output | post-processor(s) | final output |
| Text | - | Text |
| HTML | - | HTML |
| Roff | nroff | Text |
| Lout | lout | Postscript |
| PDF | pdflib | PDF |
| LaTeX | latex, dvips | DVI, Postscript, PDF |
| XML | docbook | ... |
| POD | pod2xxx | ... |