Documentation
¶
Overview ¶
Package markup converts a custom html-like markup into markdown-like text.
Using an interpretation of English-like text as a series of characters in left-to-right columns and top-to-bottom rows, then:
- Newlines: move to the start of the next row.
- Paragraphs: act as a newline followed by an empty row.
- Soft-newlines: at the start of a row, these do nothing. Otherwise they act like a newline.
- Soft-paragraphs: after an empty row, these do nothing. Otherwise they act like a paragraph.
- Lists: a set of uniformly indented rows which may contain nested lists of deeper indentation.
- Ordered lists : each row in the list starts with a number, starting with 1. increasing by 1.
- Unordered lists: each row in the list starts with some uniform marker, ex. a bullet.
The custom html elements include:
<b> - bold text <i> - italic text <s> - strikethrough <u> - underlined text <hr> - horizontal divider <br> - new line <p> - soft-paragraph ( there is no "hard" paragraph marker ) <wbr> - soft-newline <ol></ul> - ordered list <ul></ul> - unordered list <li></li> - line item in a list
Nested tags are okay; interleaved tags are not supported. For example:
<b><i></i></b>
is fine. While this:
<b><i></b></i>
will cause trouble.
Unknown tags are left as is. Tags attributes ( <b class="..."> ) are not supported.
Index ¶
Constants ¶
const ( // Starts a new line of text. Newline = '\n' // Conditionally prints a single line of blank text; // doesn't write a blank line if there already is one. Paragraph = '\v' // Starts a new line only if the output isnt already at the start of a newline. Softline = '\r' Space = ' ' )
Variables ¶
var Formats = Formatting{ Bold: Format{Sub: "**"}, Divider: Format{Sub: "\r-----------------------------\n"}, Italic: Format{Sub: "*"}, Item: Format{Sub: "\r- ", Close: "\r"}, Strike: Format{Sub: "~~"}, Underline: Format{Sub: "__"}, Paragraph: Format{Rune: Paragraph}, Newline: Format{Rune: Newline}, Softline: Format{Rune: Softline}, }
Formats - the default set of replacement string values.
var Tabwidth = 2
Tabwidth - how many spaces should list indentation generate
Functions ¶
Types ¶
type Format ¶
Format - replacement text for certain html tags. If a substitution string exists, it replaces the opening and closing html tags; otherwise the specified rune replaces just the opening tag, and the closing tag gets ignored.
type Formatting ¶
type Formatting struct {
Bold, Divider, Italic, Item, Strike, Underline,
Paragraph, Newline, Softline Format
}
Formatting - all of the unique replacement strings. Which html tags map to which format is hardcoded.