Google is committed to advancing racial equity for Black communities. See how.

Markdown style guide

Fuchsia.dev supports the markdown elements documented in this guide.

Blockquotes

Markdown uses the greater-than character (>) to render text as a blockquote (that is, quoted text).

Markdown

This is a Markdown paragraph.

> This is a blockquote with two paragraphs. The first line of a blockquote
> paragraph has to have a greater-than character (`>`), but for readability
> in the source file, add a greater-than character to every subsequent line
> of the paragraph like this example. Though this isn't a requirement as
> shown in the second blockquote paragraph below.
>
> This is a second blockquote paragraph that only has a greater-than
character (`>`) for the first line. Donec sit amet nisl. Aliquam semper
ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus
adipiscing. Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec,
fringilla in, laoreet vitae, risus.

Rendered

This is a Markdown paragraph.

This is a blockquote with two paragraphs. The first line of a blockquote paragraph has to have a greater-than character (>); but for readability in the source file, add a greater-than character to every subsequent line of the paragraph like this example. However, this isn't a requirement, as shown in the second blockquote paragraph below.

This is a second blockquote paragraph that only has a greater-than character (>) for the first line. Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.

Code blocks

Code blocks are used to provide programmatic examples or markup source code. The content within a code block is not parsed like a normal Markdown paragraph but is instead rendered as it's written.

You can use code blocks to specify which programming language to render the code in for highlighting.

A blank line is required both before and after the three backticks (```). The backticks do not render in the final output. However, blank lines within a code block render in the final output.

Markdown

Example 1: Uses Java syntax highlighting

```java
public class Hello {

  public static void main(String arg[]) {

    System.out.println("Hello.");
  }
}
```

Example 2: Prevents syntax highlighting

```none {:.devsite-disable-click-to-copy}
Some pseudo-code doesn't need syntax highlighting.
```

Example 3: Includes a replacement variable

```none {:.devsite-disable-click-to-copy}
Hello, my name is {{ '<var>' }}your-name{{ '</var>' }}.
```

Generated HTML

<p>Example 1: Uses Java syntax highlighting</p>
<pre class="prettyprint lang-java"><code>public class Hello {<br/>public
static void main(String arg[]) {<br/>System.out.println("Hello.");<br/>}
<br/>}<br/></code></pre>
<p>Example 2: Prevents syntax highlighting</p>
<pre class="click-to-copy"><code><br/><p>Some pseudo-code doesn't need
syntax highlighting.</p><br/>
</code></pre>
<p>Example 3: Includes a replacement variable</p>
<pre class="no-prettyprint"><code><br/><p>Hello, my name is <var>your-name</var>.
</p><br/></code></pre>

Rendered

Example 1: Uses Java syntax highlighting

public class Hello {

  public static void main(String arg[]) {

    System.out.println("Hello.");
  }
}

Example 2: Prevents syntax highlighting

Some pseudo-code doesn't need syntax highlighting.

Example 3: Includes a replacement variable

Hello, my name is your-name.

Using replaceable variables inside a code block

To use <var> tags in a code block, use Jinja expression brackets as follows:

{{ '<var>' }}PORT{{ '</var>' }}

The example above renders the following:

PORT

Comments

Fuchsia.dev supports single-line and multi-line comments in Markdown and HTML. The comments do not display on published pages. These comments are useful to alert contributors if your document contains includecode or MathJax.

Single-line comments

{# To see the fully rendered MathJax equations on this page,
  see the published page at https://fuchsia.dev/#}

Multi-line comments

To use a multi-line comment on fuchsia.dev:

Wrap each line with {# ... #}. This works in both HTML and Markdown:

{# I wonder how drivers are doing? #}
{# I hear they are awesome! #}

Custom attributes

Fuchsia.dev allows you to set custom HTML attributes (such as class, id, or attribute='value') in Markdown files.

Supported Markdown elements

The following elements support custom attributes:

  • Code spans
  • Code blocks
  • Headings
  • Links
  • Lists
  • Paragraphs
  • Tables and multi-line tables

Format

Syntax Description
{ and } Start and end of custom attribute.
: Required for Markdown custom attribute in fuchsia.dev.
. Word after period (.) sets the class of the element.
# Word after hash (#) sets the id of the element.
attribute='value' Sets an attribute name and value pair for the element; use a space to separate pairs.

Markdown

This is a Markdown paragraph.
{:.customClass #custom_id attribute='value'}

Generated HTML

<p class="customClass" id="custom_id" attribute="value">This is a Markdown paragraph.</p>

Definition lists

To create a definition list in Markdown, list the term on a single line, then precede every definition with a colon (:) on a new line below the definition.

Markdown

Apple
: A fruit
: A tech company

Orange
: A citrus fruit

    A definition can also contain other block or inline elements. This is a
    paragraph within the same definition as "A citrus fruit". Elements
    within must be indented four spaces to be recognized as part of the
    preceding definition.

: A color

Generated HTML

<dl>
  <dt>Apple</dt>
  <dd>A fruit</dd>
  <dd>A tech company</dd>

  <dt>Orange</dt>
  <dd>
    <p>A citrus fruit</p>
    <p>
      A definition can also contain other block or inline elements. This is
      a paragraph within the same definition as "A citrus fruit". Elements
      within must be indented four spaces to be recognized as part of the
      preceding definition.
    </p>
  </dd>
  <dd>
    <p>A color</p>
  </dd>
</dl>

Rendered

Apple
A fruit
A tech company
Orange

A citrus fruit

A definition can also contain other block or inline elements. This is a paragraph within the same definition as "A citrus fruit". Elements within must be indented four spaces to be recognized as part of the preceding definition.

A color

Emphasis and strong

Markdown uses asterisks (*) and underscores (_) for emphasis and strong formatting.

Emphasis

Text in one asterisk (*) or underscore (_) provides an italic style to specific text.

Markdown

*single asterisks*

_single underscores_

supercali*fragilistic*expialidocious

supercali_fragilistic_expialidocious                 // won't format

Generated HTML

<em>single asterisks</em>

<em>single underscores</em>

supercali<em>fragilistic</em>expialidocious

supercali_fragilistic_expialidocious

Rendered

single asterisks

single underscores

supercalifragilisticexpialidocious

supercali_fragilistic_expialidocious

Strong

Text in double asterisks (**) or underscores (__) provides a bold style to specific text.

Markdown

**double asterisks**

__double underscores__

supercali**fragilistic**expialidocious

supercali__fragilistic__expialidocious

Generated HTML

<strong>double asterisks</strong>

<strong>double underscores</strong>

supercali<strong>fragilistic</strong>expialidocious

supercali<strong>fragilistic</strong>expialidocious

Rendered

double asterisks

double underscores

supercalifragilisticexpialidocious

supercalifragilisticexpialidocious

Escaping

Certain characters are reserved syntax in Markdown. To use a special character, use a backslash escape (``) to display the following literal characters:

\   backslash
`   backtick
*   asterisk
_   underscore
{}  curly braces
[]  square brackets
()  parentheses
#   hash mark
+   plus sign
-   minus sign (hyphen)
.   dot
!   exclamation mark

Footnotes

Footnotes are a useful tool for including additional or supplementary content without disrupting the flow of the page. The syntax is similar to reference links:

In the main text, include a label[^1] that starts with a caret.

[^1]: The footnote content goes here.

The footnote label can be any arbitrary string as long as it starts with a caret ^.

Headings

Markdown supports atx-style headers use between one and six hash characters (#) at the start of the line, which correspond to header levels one through six.

Markdown

# This is an H1

## This is an H2

###### This is an H6

Rendered

This is an H1

This is an H2

This is an H6

Header IDs

Fuchsia.dev supports custom HTML id attribute for every header. If you want to override the default id, add the custom attribute {#user_defined_name} at the end of the Markdown header.

Markdown

# Working with contacts {#working-with-contacts}
## Contact Entry
### Contacts are working

Generated HTML

<h1 id="working-with-contacts">Working with contacts</h1>
<h2 id="contact-entry">Contact Entry</h2>
<h3 id="contacts-are-working">Contacts are working</h3>

Table of contents

For every second- and third-level heading, fuchsia.dev automatically generates a table of contents (TOC) for the page. To hide headers from the TOC, add the custom attribute {:.hide-from-toc} at the end of the header.

Markdown

## Hidden in TOC {:.hide-from-toc}             // try to find it!

Rendered

Hidden in TOC

Horizontal rules

Markdown supports a horizontal rule tag (<hr>) by placing three or more hyphens, asterisks, or underscores on a line.

Each of the following will produce a horizontal rule:

* * *

***

*****

- - -

---------------------------------------

Images

Markdown uses an image syntax that is intended to resemble the syntax for links, allowing for two styles: inline and reference.

Every image has the following properties:

  • Starting exclamation mark: !.
  • Set of square brackets, containing the alt attribute text.
  • Set of parentheses, containing the URL or path to the image, and an optional title attribute enclosed in double or single quotes.
  • Set of optional classes using custom attribute syntax {: .my-custom-css-class}

Inline syntax

The following are valid inline image syntax:

![Alt text](/docs/images/benchmarking/test_suite_example.png)

![Alt text](/docs/images/benchmarking/test_suite_example.png "Optional title")

![Alt text](/docs/images/benchmarking/test_suite_example.png "Optional title"){: .my-custom-css-class} 

Reference syntax

The following is reference-style image syntax:

![Alt text][ID]

Where ID is the name of a defined image reference. Image references are defined using syntax identical to link references:

[ID]: docs/images/benchmarking/test_suite_example.png  "Optional title attribute"

Custom syntax

You can specify the width of a Markdown image using the following syntax:

![Alt text](/docs/images/benchmarking/test_suite_example.png){: width="123"} 

Include code

The includecode tag includes a region of text from another file, especially a region of source code. The tag can also generate a downloadable file within the text, instead of including the text in the document.

You can use this tag to insert a portion of source code into a document, and maintain that source code as a runnable file.

The gerrit_repo+path parameter refers to a repository and path hosted on Gerrit or Git. The repo is in the format instance or repository and path is in the format of path/to/file.

{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="examples/fidl/fuchsia.examples/types.test.fidl" %}

Including a portion of a file

There are three ways to specify a region of the file to include: region tags, regular expressions, and indented blocks.

Region tag

Region tags allow you to add lines to the source file that indicate the first and last lines of the region along with a tag name.

{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="examples/fidl/fuchsia.examples/types.test.fidl" region_tag="consts" %}

Rendered:

const BOARD_SIZE uint8 = 9;
const NAME string = "Tic-Tac-Toe";

Regular expressions

You can also use regular expressions to define the region to extract, using the regexp parameter. For example:

{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="examples/fidl/fuchsia.examples/types.test.fidl" regexp="WRITE = 0b010;" %}

Rendered:

WRITE = 0b010;

The pattern uses the Python regular expression syntax. For more information, see the official Python documentation.

Indented blocks

You can include code from a function or class definition without defining region tags. Use the indented_block parameter:

{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="examples/fidl/fuchsia.examples/types.test.fidl" indented_block="type User" %}

Rendered:

type User = table {
    1: reserved;
    2: age uint8;
    3: name string:MAX_STRING_LENGTH;
};

The pattern uses the Python regular expression syntax. For more information, see the official Python documentation.

Parameters

The following are optional parameters for includecode:

Markdown

Parameters
highlight Optional
You can use the highlight parameter to call attention to a specific part of the code. Use comma separated values to indicate the lines you would like to highlight. The line numbers are relative to the region you select and not to the entire file.

Example
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="examples/fidl/fuchsia.examples/types.test.fidl" region_tag="bits" highlight="2,3,4" %}
adjust_indentation Optional
By default, includecode returns the specified section of the source code, including whitespace. You can adjust the indentation of the code with the adjust_indentation option.

adjust_indentation takes two possible values:
  • number - An integer. This indicates the number of spaces by which every line will be unindented. For example, a value of 4 would dedent the line by 4 spaces, while -2 would indent the line by 2 spaces.
  • 'auto' - The string auto. The publishing tool will unindent the selected code by the minimum number of leading spaces found in a region. In other words, it will remove as much leading whitespace as is common to all lines in the code snippet.
Example
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="examples/fidl/fuchsia.examples/types.test.fidl" region_tag="bits" adjust_indentation="-2" %}
html_escape Optional
By default, includecode HTML-escapes all code. You can set html_escape to False to un-escape HTML.

Example
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="examples/fidl/fuchsia.examples/echo.test.fidl" region_tag="launcher" html_escape="False" %}
exclude_regexp Optional
You can remove certain lines according to a regex. This is useful for removing comments or other irrelevant content. You can not use multiline regex.

Example
{% includecode gerrit_repo="fuchsia/fuchsia" gerrit_path="examples/fidl/fuchsia.examples/types.test.fidl" region_tag="bits" exclude_regexp="READ" %}

Rendered

Parameters
highlight Before highlight="2,3,4":
        bits FileMode : uint16 {
          READ = 0b001;
          WRITE = 0b010;
          EXECUTE = 0b100;
        };
After highlight="2,3,4":
        bits FileMode : uint16 {
          READ = 0b001;
          WRITE = 0b010;
          EXECUTE = 0b100;
        };
adjust_indentation Before adjust_indentation="-2":
        bits FileMode : uint16 {
          READ = 0b001;
          WRITE = 0b010;
          EXECUTE = 0b100;
        };
After adjust_indentation="-2":
            bits FileMode : uint16 {
              READ = 0b001;
              WRITE = 0b010;
              EXECUTE = 0b100;
            };
html_escape Before html_escape="False":
MAX_STRING_LENGTH echo_prefix, request<Echo> request);
After html_escape="True":
MAX_STRING_LENGTH echo_prefix, request request);
exclude_regexp Before exclude_regexp="READ":
      bits FileMode : uint16 {
        READ = 0b001;
        WRITE = 0b010;
        EXECUTE = 0b100;
      };
After exclude_regexp="READ":
      bits FileMode : uint16 {
        WRITE = 0b010;
        EXECUTE = 0b100;
      };

Inline code

You can indicate code within a Markdown paragraph by wrapping text with backtick quotes (`).

Markdown

Use the `printf()` function. Code for the `printf()` function is located in the `system\ ` directory.

This sentence has inline `  {code}    ` with a lot of spaces but none are rendered.

Generated HTML

<p>Use the <code>printf()</code> function. Code for the <code>printf()</code>
function is located in the <code>system\</code> directory.</p>
<p>This sentence has inline <code>{code}</code>with a lot of spaces but none
are rendered.</p>

Rendered

Use the printf() function. Code for the printf() function is located in the system\ directory.

This sentence has inline {code} with a lot of spaces but none are rendered.

Inline HTML

Markdown syntax does not offer the full versatility of HTML, however Markdown supports inline HTML. You can wrap your text in an HTML element tag such as:

Markdown

This sentence is in Markdown with a <b>bold inline HTML tag</b>.

Rendered

This sentence is in Markdown with a bold inline HTML tag.

Fuchsia.dev supports three style of links: inline, reference, and external. In all styles, the link text is delimited by [] (square brackets).

To create an inline link, use a set of regular parentheses immediately after the link text's closing square bracket. Inside the parentheses, put the URL where you want the link to point, along with an optional title for the link, surrounded in quotes. For example:

This is [an example](https://fuchsia.dev/ "Title") inline link.

[This link](https://fuchsia.dev/) has no title attribute.

This produces the following HTML:

Markdown

<p>This is <a href="https://fuchsia.dev/" title="Title">
an example</a> inline link.</p>

<p><a href="fuchsia.dev">This link</a> has no
title attribute.</p>

If you're referring to a local resource on the same server, you can use relative paths:

See my [docs](/docs/) page for details.

Generated HTML

This is an example inline link.

This link has no title attribute.

If you're referring to a local resource such as a file in the source tree, you can use relative paths:

See my docs page for details.

Reference-style links use a second set of square brackets, inside which you provide a label to identify the link:

This is [an example][id] reference-style link.

You can optionally use a space to separate the sets of brackets:

This is [an example] [id] reference-style link.

Then, at the bottom of the document, you define your link at the bottom of the document, on a single line:

[id]: https://{{example_url}}/  "Optional Title Here"

You can alert readers that a link will lead to an external site by adding {: .external} to the syntax. For example:

See the [official documentation](https://my_external_website){: .external} for details.

Lists

Using Markdown syntax, you can easily create a bulleted or a numbered list. These are commonly known as unordered (that is bulleted) or ordered (that is numbered) lists since they refer to the generated (<ul>) and (<ol>) HTML tags.

Unordered lists

Unordered lists can use asterisks (*), pluses (+), or dashes (-) as list markers. The list renders the same, regardless of which marker you use.

Markdown

This is a Markdown paragraph:
                                             // required blank line
* Red
* Green
* Blue

This is another Markdown paragraph:
                                            // required blank line
+ Red
+ Green
+ Blue

This is yet another Markdown paragraph:
                                            // required blank line
- Red
- Green
- Blue

Generated HTML

<p>This is a Markdown paragraph:</p>
<ul>
  <li>Red</li>
  <li>Green</li>
  <li>Blue</li>
</ul>
<p>This is another Markdown paragraph:</p>
<ul>
  <li>Red</li>
  <li>Green</li>
  <li>Blue</li>
</ul>
<p>This is yet another Markdown paragraph:</p>
<ul>
  <li>Red</li>
  <li>Green</li>
  <li>Blue</li>
</ul>

Rendered

This is a Markdown paragraph:

  • Red
  • Green
  • Blue

This is another Markdown paragraph:

  • Red
  • Green
  • Blue

This is yet another Markdown paragraph:

  • Red
  • Green
  • Blue

Multi-level unordered lists

You can use asterisks (*), pluses (+), or dashes (-) for list markers in multi-level unordered lists. The second-level markers must precede by at least four spaces and remain consistent at every level. See the example below:

Markdown

This is a Markdown paragraph:
                              // required blank line before parent list
 * Bird
     * Celtics
     * Retired
       * Larry                // extra space; not consistent w/ "Celtics"
 * Magic
     * Lakers

Generated HTML

<p>This is a Markdown paragraph:</p>
<ul>
  <li>Bird
    <ul>
      <li>Celtics</li>
      <li>Retired</li>
      <ul>
        <li>Larry</li>
      </ul>
    </ul>
  </li>
  <li>Magic
    <ul>
      <li>Lakers</li>
    </ul>
  </li>
</ul>

Rendered

This is a Markdown paragraph:

  • Bird
    • Celtics
    • Retired
      • Larry
  • Magic
    • Lakers

Ordered lists

Ordered lists use a number and a period before the list item. You may define your own ordinal numbers in your ordered lists or use 1. for automatic numbering. See the example below:

Markdown

This is a Markdown paragraph:
                                   // required blank line
1. Bird                            // recommended numbering
1. McHale
1. Parish

This is another Markdown paragraph:
                                   // required blank line
1. Bird                            // sequential numbering is allowed,
2. McHale                          // but not recommended
3. Parish

This is yet another Markdown paragraph:
                                   // required blank line
3. Bird                            // non-sequential numbering is allowed,
1. McHale                          // but not recommended
8. Parish

Generated HTML

<p>This is a Markdown paragraph:</p>
<ol>
  <li>Bird</li>
  <li>McHale</li>
  <li>Parish</li>
</ol>
<p>This is another Markdown paragraph:</p>
<ol>
  <li>Bird</li>
  <li>McHale</li>
  <li>Parish</li>
</ol>
<p>This is yet another Markdown paragraph:</p>
<ol>
  <li>Bird</li>
  <li>McHale</li>
  <li>Parish</li>
</ol>

Rendered

This is a Markdown paragraph:

  1. Bird
  2. McHale
  3. Parish

This is another Markdown paragraph:

  1. Bird
  2. McHale
  3. Parish

This is yet another Markdown paragraph:

  1. Bird
  2. McHale
  3. Parish

Multi-level ordered lists

You can create multi-level ordered lists; the second-level markers must precede by at least four spaces.

Markdown

 1. Bird
     1. Lakers
 1. McHale
     1. Celtics

Generated HTML

<ol>
  <li>Bird
    <ol>
      <li>Lakers</li>
    </ol>
  </li>
  <li>McHale
    <ol>
      <li>Celtics</li>
    </ol>
  </li>
</ol>

Rendered

  1. Bird
    1. Lakers
  2. McHale
    1. Celtics

MathJax

The <devsite-mathjax> custom element allows you to display mathematical notation in fuchsia.dev content using MathJax 2.7. MathJax utilizes LaTeX syntax to create mathematical notion. See the LaTeX syntax guide to learn more.

Usage

To utilize MathJax in your document, you must include the custom element one time in your document:

  {# To see the fully rendered MathJax equations on this page,
  see the published page at https://fuchsia.dev/<PATH_TO_YOUR_DOCUMENT>#}
  <devsite-mathjax config="TeX-AMS-MML_SVG"></devsite-mathjax>

After including the custom element, you can write mathematical notion inside of a $$ block or $ inline.

Standalone block

Markdown

<!-- <devsite-mathjax config="TeX-AMS-MML_SVG"></devsite-mathjax> -->

<div>
  $$
  R_{\mu\nu}-\frac{1}{2}Rg_{\mu\nu}+\Lambda{g_{\mu\nu}} = \frac{8\pi{G}}{c^4}{T_{\mu\nu}}
  $$
</div>

Rendered

$$ R_{\mu\nu}-\frac{1}{2}Rg_{\mu\nu}+\Lambda{g_{\mu\nu}} = \frac{8\pi{G}}{c^4}{T_{\mu\nu}} $$

Inline

Markdown

<!--Included only one time previously-->
<devsite-mathjax config="TeX-AMS-MML_SVG"></devsite-mathjax>

The area of a circle can be computed using the equation $ A = \pi{r^2} $,
where $ r $ is the radius of the circle, and $ \pi $ is the mathematical
constant that is approximately equal to 3.14159.

Rendered

The area of a circle can be computed using the equation $ A = \pi{r^2} $, where $ r $ is the radius of the circle, and $ \pi $ is the mathematical constant that is approximately equal to 3.14159.

Paragraphs

A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing but spaces or tabs is considered blank.) You do not need to indent normal paragraphs with spaces or tabs.

Tables

Markdown makes it easy to format tables with pipes (|) and hyphens (-). Deliminate text with pipes to create columns; a header row is defined when the following row has at least three hyphens for each column header.

Markdown

Lesson                     | Description
------------------------   | ---------------------------------------
What is Fuchsia?           | An open source effort to create a production-grade operating system
What is FIDL?              | Fuchsia Interface Definition Language
Getting Started            | Download the Fuchsia source code

Generated HTML

<table>
  <thead>
    <tr>
      <th>Lesson</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>What is Fuchsia?</td>
      <td>An open source effort to create a production-grade operating system</td>
    </tr>
    <tr>
      <td>What is FIDL?</td>
      <td>Fuchsia Interface Definition Language</td>
    </tr>
    <tr>
      <td>Getting Started</td>
      <td>Download the Fuchsia source code</td>
    </tr>
  </tbody>
</table>

Rendered

Lesson Description
What is Fuchsia? An open source effort to create a production-grade operating system
What is FIDL? Fuchsia Interface Definition Language
Getting Started Download the Fuchsia source code

Formatting text in a table

You can use Markdown syntax to format text within a table (that is, *emphasis*, **strong**, `code`). To align text within a column, add a colon : in the dash --- row to indicate direction (that is, left, center, right) as in the example below:

Markdown

Left-aligned     | Center-aligned | Right-aligned
:---             |     :---:      |          ---:
info             | info           | info
more info        | more info      | more info
even *more* info | some `code`    | **not** code

Rendered

Left-aligned Center-aligned Right-aligned
info info info
more info more info more info
even more info some code not code