Documentation ¶
Overview ¶
Styledown is a simple markup language for representing styled text.
In the most basic form, Styledown markup consists of alternating text lines and style lines, where each character in the style line specifies the style of the character directly above it. For example:
foobar ***### lorem _____
represents two lines:
- "foo" in bold plus "bar" in reverse video
- "lorem" in underline
The following style characters are built-in:
- space for no style
- * for bold
- _ for underline
- # for reverse video
This package can be used as a Go library or via Elvish's render-styledown command (https://elv.sh/ref/builtin.html#render-styledown).
Double-width characters ¶
Characters in text and style lines are matched up using their visual width, as calculated by src.elv.sh/pkg/wcwidth.OfRune. This means that double-width characters need to have their style character doubled:
好 foo ** ###
The two style characters must be the same.
Configuration stanza ¶
An optional configuration stanza can follow the text and style lines (the content stanza), separated by a single newline. It can define additional style characters like this:
foobar rrrGGG r fg-red G inverse fg-green
Each line consists of the style character and one or more stylings as recognized by src.elv.sh/pkg/ui.ParseStyling, separated by whitespaces. The character must be a single Unicode codepoint and have a visual width of 1.
The configuration stanza can also contain additional options, and there's currently just one:
- no-eol: suppress the newline after the last line
Rationale ¶
Styledown is suitable for authoring a large chunk of styled text when the exact width and alignment of text need to be preserved.
For example, it can be used to manually create and edit terminal mockups. In future it will be used in Elvish's tests for its terminal UI.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
This section is empty.