Writing Pages with Micron
Outputting Formatted Text
-\u223f <
Hello! This is output from micron Micron generates formatted text for your terminal
-\u223f <
Nomad Network supports a simple and functional markup language called micron. If you are familiar with markdown or HTML, you will feel right at home writing pages with micron.
With micron you can easily create structured documents and pages with formatting, colors, glyphs and icons, ideal for display in terminals.
Table of Contents
A Few Demo Outputs Micron Tags High Level Stuff Colors Page Foreground and Background Colors Links Anchors Tables Fields & Requests Comments Partials Literals Closing Remarks
Recommendations and Requirements
While micron can output formatted text to even the most basic terminal, there's a few capabilities your terminal must support to display micron output correctly, and some that, while not strictly necessary, make the experience a lot better.
Formatting such as underline, bold or italics will be displayed if your terminal supports it.
If you are having trouble getting micron output to display correctly, try using gnome-terminal or alacritty, which should work with all formatting options out of the box. Most other terminals will work fine as well, but you might have to change some settings to get certain formatting to display correctly.
Encoding
All micron sources are intepreted as UTF-8, and micron assumes it can output UTF-8 characters to the terminal. If your terminal does not support UTF-8, output will be faulty.
Colors
Shading and coloring text and backgrounds is integral to micron output, and while micron will attempt to gracefully degrade output even to 1-bit terminals, you will get the best output with terminals supporting at least 256 colors. True-color support is recommended.
Terminal Font
While any unicode capable font can be used with micron, it's highly recommended to use a "Nerd Font" (see https://www.nerdfonts.com/), which will add a lot of extra glyphs and icons to your output.
A Few Demo Outputs
With micron, you can control layout and presentation
You can change background ...
... and foreground colors
If you want to make a break, horizontal dividers can be inserted. They can be plain, like the one below this text, or you can style them with unicode characters and glyphs, like the wavy divider in the beginning of this document.
-
Text can be underlined, bold or italic.
You can also combine formatting for some fabulous effects.
Sections and Headings
You can define an arbitrary number of sections and sub sections, each with their own named headings. Text inside sections will be automatically indented.
-
If you place a divider inside a section, it will adhere to the section indents.
If no heading text is defined, the section will appear as a sub-section without a header. This can be useful for creating indented blocks of text, like this one.
Micron tags
Tags are used to format text with micron. Some tags can appear anywhere in text, and some must appear at the beginning of a line. If you need to write text that contains a sequence that would be interpreted as a tag, you can escape it with the character \\.
In the following sections, the different tags will be introduced. Any styling set within micron can be reset to the default style by using the special \\`\\` tag anywhere in the markup, which will immediately remove any formatting previously specified.
Alignment
To control text alignment use the tag \\ to center text, \\ to left-align, \\ to right-align, and \\ to return to the default alignment of the document. Alignment tags must appear at the beginning of a line. Here is an example:
This line will be centered. So will this. The alignment has now been returned to default. This will be aligned to the right
The above markup produces the following output:
This line will be centered. So will this.
The alignment has now been returned to default.
This will be aligned to the right
Formatting
Text can be formatted as bold by using the \\ tag, underline by using the \\ tag and italic by using the \\ tag.
Here's an example of formatting text:
We shall soon see bold paragraphs of text decorated with underlines and italics. Some even dare combine them!
The above markup produces the following output:
We shall soon see bold paragraphs of text decorated with underlines and italics. Some even dare combine them!
Sections
To create sections and subsections, use the > tag. This tag must be placed at the beginning of a line. To specify a sub-section of any level, use any number of > tags. If text is placed after a > tag, it will be used as a heading.
Here is an example of sections:
High Level Stuff This is a section. It contains this text.
Another Level This is a sub section.
Going deeper A sub sub section. We could continue, but you get the point.
Wait! It's worth noting that we can also create sections without headings. They look like this.
The above markup produces the following output:
High Level Stuff This is a section. It contains this text.
Another Level This is a sub section.
Going deeper A sub sub section. We could continue, but you get the point.
Wait! It's worth noting that we can also create sections without headings. They look like this.
Colors
Foreground colors can be specified with the \\`F tag, followed by three hexadecimal characters. To return to the default foreground color, use the \\ tag. Background color is specified in the same way, but by using the \\`B and \\ tags.
Here's a few examples:
You can use color formatting for some fabulous effects.
The above markup produces the following output:
You can use color formatting for some fabulous effects.
Page Foreground and Background Colors
To specify a background color for the entire page, place the #!bg=X header on one of the first lines of your page, where X is the color you want to use, for example 444. If you're also using the cache control header, the background specifier must come after the cache control header. Likewise, you can specify the default text color by using the #!fg=X header.
Links
Links to pages, files or other resources can be created with the \\`[ tag, which should always be terminated with a closing ]. You can create links with and without labels, it is up to you to control the formatting of links with other tags. Although not strictly necessary, it is good practice to at least format links with underlining.
Here's a few examples:
Here is a link without any label: `[72914442a3689add83a09a767963f57c:/page/index.mu]
This is a labeled link to the same page, but it's hard to see if you don't know it
Here is a more visible link
The above markup produces the following output:
Here is a link without any label: `[72914442a3689add83a09a767963f57c:/page/index.mu]
This is a labeled link to the same page, but it's hard to see if you don't know it
Here is a more visible link
When links like these are displayed in the built-in browser, clicking on them or activating them using the keyboard will cause the browser to load the specified URL.
Anchors
Anchors let you create jump points within a single page similar to anchors in HTML. You declare a position in the page with a name, then link to it from anywhere on the same page.
Auto-anchors from headers
Every section heading you write also becomes an anchor automatically. The anchor name is the heading text after slugifying: lowercased, with any run of non-alphanumeric characters replaced by a single hyphen, and leading or trailing hyphens stripped. So >Hello World becomes the anchor hello-world, and >Introduction & Setup becomes introduction-setup.
Explicit anchors
If you want an anchor, that isn't tied to a heading, place one anywhere in your text with the \\`: tag, followed by a name. Names may contain the characters A-Z, a-z, 0-9, _ and -, and end at any other character (a space, a newline, or punctuation).
The anchor itself takes up no space and does not render. Is's just a position marker. An explicit anchor declared on an otherwise empty line binds to that line's position.
`:install-notes Some installation notes for the user.
You can also drop one mid-line. Example: see `:tip-3 ⚠ tip 3 below for caveats.
Linking to an anchor
Reuse the standard link syntax, with a #-prefixed URL:
Jump to Install Notes
When the user activates the link the browser scrolls the current page to the anchor's row.
Jumping to the next section
If the URL is just # with no name after it, the link jumps to the next \\`> header that appears after the link's own position in the document. This is convenient for "Continue ↓" buttons after a long paragraph, without having to name every section:
Continue
Anchors in external links
If you want to link to an anchor on another page, you can include it as a request variable:
Conclusion
Notes on namespaces and collisions
Auto-anchors from headings and explicit \\`: anchors share a single namespace per page. If an explicit anchor collides with a heading slug, the first one declared is where it will jump to.
Tables
You can include rendered tables by enclosing them in \\`t tags. Optionally, you can also specify alignment and max rendering width by adding these properties to the opening \\`t tag, like \\`tc30. Here's an example:
`t | Name | Price | Qty | | ---- | :---: | --: | | Apple | Free | 5 | | Orange | Ask, nicely | 3 | `t
The above markup produces the following table:
`t | Name | Price | Qty | | ---- | :---: | --: | | Apple | Free | 5 | | Orange | Ask, nicely | 3 | `t
Fields & Requests
Nomad Network lets you use simple input fields for submitting data to node-side applications. Submitted data, along with other session variables will be available to the node-side script / program as environment variables.
Request Links
Links can contain request variables and a list of fields to submit to the node-side application. You can include all fields on the page, only specific ones, and any number of request variables. To simply submit all fields on a page to a specified node-side page, create a link like this:
Submit Fields
Note the * following the extra \\! at the end of the path. This * denotes all fields. You can also specify a list of fields to include:
Submit Fields
If you want to include pre-set variables, you can do it like this:
Query the System
Fields
Here's an example of creating a field. We'll create a field named user_input and fill it with the text Pre-defined data. Note that we are using background color tags to make the field more visible to the user:
A simple input field: `<user_input`Pre-defined data>
You must always set a field name, but you can of course omit the pre-defined value of the field:
An empty input field: ____
You can set the size of the field like this:
A sized input field: ____
It is possible to mask fields, for example for use with passwords and similar:
A masked input field: `<!|masked_demo`hidden text>
And you can of course control all parameters at the same time:
Full control: `<!32|all_options`hidden text>
Collecting the above markup produces the following output:
A simple input field: `<user_input`Pre-defined data>
An empty input field: ____
A sized input field: ____
A masked input field: `<!|masked_demo`hidden text>
Full control: `<!32|all_options`hidden text>
Checkboxes
In addition to text fields, Checkboxes are another way of submitting data. They allow the user to make a single selection or select multiple options.
____ Label Text`
When the checkbox is checked, it's field will be set to the provided value. If there are multiple checkboxes that share the same field name, the checked values will be concatenated when they are sent to the node by a comma.
____ Sign me up`
You can also pre-check both checkboxes and radio groups by appending a |* after the field value.
____ Pre-checked checkbox`
Radio groups
Radio groups are another input that lets the user chose from a set of options. Unlike checkboxes, radio buttons with the same field name are mutually exclusive.
Example:
____ Red
____ Green
____ Blue
will render:
____ Red
____ Green
____ Blue
In this example, when the data is submitted, ` field_color will be set to whichever value from the list was selected.
Comments
You can insert comments that will not be displayed in the output by starting a line with the # character.
Here's an example:
This line will
The above markup produces the following output:
This line will
Partials
You can include partials in pages, which will load asynchronously once the page itself has loaded.
`{f64a846313b874ee4a357040807f8c77:/page/partial_1.mu}
It's also possible to set an auto-refresh interval for partials. Omit or set to 0 to disable. The following partial will update every 10 seconds.
`{f64a846313b874ee4a357040807f8c77:/page/refreshing_partial.mu`10}
You can include field values and variables in partial updates, and by setting the pid variable, you can create links that update one or more specific partials.
Name: ____
Say hello
`{f64a846313b874e84a357039807f8c77:/page/hello_partial.mu`0`pid=32|user_name}
Literals
To display literal content, for example source-code, or blocks of text that should not be interpreted by micron, you can use literal blocks, specified by the \\ tag. Below is the source code of this entire document, presented as a literal block.
-