Markdown Blocks



Code: Block¶ To specify an entire block of pre-formatted code, indent every line of the block by 1 tab or 4 spaces. Ampersands and angle brackets will automatically be translated into HTML entities. Note: The instructions from this guide are referring to the Classic Editor. If you are using the WordPress block editor, please see this guide. See the Markdown page for instructions on enabling Markdown for posts, pages and comments on your blog, and for more detailed information about using Markdown. It’s easy to find any coupon for Github Markdown Code Block Language by searching it on the internet through popular coupon sites such as Retailmenot.

  1. Markdown Blockquote
  2. Markdown Block Text

A common use of directives and roles is to designate “special blocks” of your content.This allows you to include more complex information such as warnings and notes, citations, and figures.This section covers a few common ones.

MyST syntax extensions¶

MyST Markdown has a base syntax that it supports, and additional syntax can be enabled to add extra functionality.By default, Jupyter Book enables a few extra syntax pieces for MyST in order to more closely resemble the Markdown experience in Jupyter Notebooks and interfaces.These extensions are:

dollarmath

To support $$ and $ syntax for math blocks. See Math and equations.

linkify

To auto-detect HTML-like links in your markdown and convert them to hyperlinks.

substitution

To allow you to define markdown “variables” and substitute text in using them. See Substitutions and variables in markdown.

colon_fence

To allow you to use ::: fences for admonitions, in order to make them easier to render in interfaces that do not support MyST. See Markdown-friendly directives with :::.

To enable your own syntax extensions, use the following configuration pattern:

Note that this will override the default Jupyter Book extension list.You should include all of the extensions that you want to be enabled.

See also

For a list of syntax extensions in MyST, see the MyST documentation.

Notes, warnings, and other admonitions¶

Let’s say you wish to highlight a particular block of text that exists slightly apart from the narrative of your page.You can use the {note} directive for this.

For example, the following text:

Results in the following output:

Note

Here is a note!

There are a number of similarly-styled blocks of text. For example, here is a {warning}block:

Warning

Here’s a warning! It was created with:

For a complete list of options, see the sphinx-book-theme documentation.

Blocks of text with custom titles¶

You can also choose the title of your message box by using the{admonition} directive. For example, the following text:

Results in the following output:

Here’s your admonition

Here’s the admonition content

If you’d like to style these blocks, then use the :class: option. Forexample:

This admonition was styled…

Using the following pattern:

Markdown-friendly directives with :::

The admonition syntax above utilises the general directives syntax.However, if you’re using an interface that does not support MyST Markdown, it will render as a raw literal block.Many directives contain markdown inside, and if you’d like this markdown to render “normally”, you may also use ::: fences rather than ``` fences to define the directive. As a result, the contents of the directive will be rendered as markdown.

For example:

Note

This text is standardMarkdown

Similar to normal directives, these admonitions can also be nested:

Important

Note

You can use this syntax for any kind of directive, though it is generally recommended to use only with directives that contain pure markdown in their content.

Insert code cell outputs into admonitions¶

If you’d like to insert the outputs of running code inside admonitionblocks, we recommend using glue functionality.For example, we’ll insert one of the outputs that was glued into the book from the code outputs page.

The code below:

generates:

Note

Here’s my figure:

See Insert code outputs into page content for more information on how to use glue to insert your outputs directly into your content.

Tip

To hide code input and output that generated the variable you are inserting, use the remove_cell tag.See Hide or remove content for more information and other tag options.

HTML admonitions¶

A drawback of admonition syntax is that it will not render in interfaces that do not support this syntax (e.g., GitHub). If you’d like to use admonitions that are defined purely with HTML, MyST can parse them via the html_admonitions extension. To use it, first enable it with the following configuration:

Then, you may define admonitions in your book like so:

See HTML Admonitions for more information about HTML admonitions.

Panels¶

Panels provide an easy way for you to organize chunks of content into flexible containers on your page.They are useful for creating card-like layouts, flexible columns, and grids.Panels are based off of Bootstrap CSS, and utilize Bootstrap’s classes to control the look and feel of panels.

Here is an example that creates two panels:

  • --- separates each panel

  • ^^^ defines the panel header

  • +++ defines the panel footer

Note

Panel headers and footers are optional.If you don’t include ^^^ or +++ in your panel, they will not show up.

You can embed all kinds of content inside of panels. For example, the following panels:

were created with:

See also

See the Sphinx Panels card layout documentation for more information.

Controlling the look and feel of panels¶

You can control the look and feel of panels by passing attaching bootstrap classes to panel headers/body/footers.You do this by passing configuration options to your {panels} directive.

For example:

See also

See the Panels card styling documentation for more information.

For example, you can control how many columns are in your panels by using Bootstrap column classes. These panels:

Body A

Body B

Body C

Were created by this code:

Dropdowns¶

Dropdowns allows you to hide content behind a title and a button.There are two kinds of dropdowns in Jupyter Book:

The {dropdown} directive¶

Use the {dropdown} directive to create a clickable dropdown with a title.

For example:

Here’s my dropdown

Dropdown admonitions¶

You can also hide the body of your admonition blocks so that users must click a button to reveal their content.This is helpful if you’d like to include some text that isn’t immediately visible to the user.

To turn an admonition into a dropdown, add the dropdown class to them. For example:

You can use this in conjunction with {admonition} directives to include yourown titles and stylings. For example:

Important

Admonition dropdowns require JavaScript to be enabled on the browser which they are viewed.By contrast, the dropdown directive below works purely via HTML+CSS.

Definition lists¶

Definition lists are enabled by defining the following setting in your _config.yml:

Definition lists utilise the markdown-it-py deflist plugin, which itself is based on the Pandoc definition list specification.

Here’s an example:

Term 1

Definition

Term 2

Definition

From the Pandoc documentation:

Each term must fit on one line, which may optionally be followed by a blank line, and must be followed by one or more definitions.A definition begins with a colon or tilde, which may be indented one or two spaces.

A term may have multiple definitions, and each definition may consist of one or more block elements (paragraphs, code blocks, lists, etc.)

Here is a more complex example, demonstrating some of these features:

Term with Markdown

Definition with reference

A second paragraph

A second definition

Term 2

Definition 2a

Definition 2b

Term 3

A quote

A final definition, that can even include images:

This was created with the following Markdown:

Quotations and epigraphs¶

Quotations and epigraphs provide ways to highlight information given by others.

Quotations¶

Regular quotations are controlled with standard Markdown syntax, i.e., byinserting a caret (>) symbol in front of one or more lines of text. For example:

Epigraphs¶

Epigraphs draw more attention to a quote and highlight its author. You shouldkeep these relatively short so that they don’t take up too much vertical space. Here’show an epigraph looks:

You can provide an attribution to an epigraph by adding -- to the final line, followed by the quote author. For example:

Glossaries¶

Glossaries allow you to define terms in a glossary so you can then link back to itthroughout your content. You can create a glossary with the followingsyntax:

which creates:

Term one¶

An indented explanation of term 1

A second term¶

An indented explanation of term2

To reference terms in your glossary, use the {term} role. For example,{term}`Termone` becomes Term one and {term}`Asecondterm`becomes A second term.

Tabbed content¶

You can also use sphinx-panels to produce tabbed content.This allows you to display a variety of tabbed content blocks that users can click on.

For example, here’s a group of tabs showing off code in a few different languages:

You can use this functionality with the {tabbed} directive. You can provide a sequence of {tabbed} directives, and each one will be used to generate a new tab (unless the :new-group: option is added to a {tabbed} directive.)

For example, the following code:

produces

My second tab with somecode!

Insert code outputs in your tabs with the glue functionality.

For example, the following tabs use this functionality to glue images and tables generated somewhere else in these docs:

Fig. 1 This is a caption, with an embedded {glue:text} element: 3.00!

firstsecondthird
02.8642793.0961703.040294
12.8505203.5829232.632284
23.1826123.0267273.013184
33.1597712.7932573.151598
43.0870323.1590383.132074

Fig. 2 A caption for a pandas table.

See the sphinx-panels tabbed documentation for more information on how to use this.

Substitutions and variables in markdown¶

Substitutions allow you to define variables in the front-matter of your page, and then insert those variables into your content throughout.

To use a substitution, first add front-matter content to the top of a page like so:

You can use these substitutions inline or as blocks, and you can even nest substitutions in other substitutions (but circular references are prohibited):

Inline: I’m a substitution

Block level:

You can also insert substitutions inside of other markdown structures like tables:

col1

col2

See also

For more information about Substitutions, see Substitutions (with Jinja2).

Define substitutions for your whole book¶

You can also define book-level substitution variables with the following configuration:

These substitutions will be available throughout your book. For example, the global substitution key my-global-substitution is defined in this book’s _config.yml file, and it produces: My global value!.

Formatting substitutions¶

MyST substitutions use Jinja templates in order to substite in key / values. This means that you can apply any standard Jinja formatting to your substitutions. For example, you can replace text in your substitutions like so:

The original key1: I’m a substitution

I’m the best substitution

Using substitutions in links¶

If you’d like to use substitutions to insert and modify links in your book, here are two options to explore:

  1. Define the entire markdown link as a variable. For example:

    Here’s my link: my repo url

  2. Use Jinja features to insert the variable.Because substitutions use Jinja templates, you also have access to Python formatting operations in your substitution.For example:

    Here’s my link: my repo: jupyter-book

Citations and cross-references¶

You can add citations and cross-references to your book. SeeCitations and bibliographies for more information on how to do this.

Figures¶

You can thoroughly customise the look of figures in your book. See Images and figures formore information.

Page layout and sidebar content¶

You can also use MyST to control various aspects of the page layout. For moreinformation on this, see Control the page layout.

Footnotes¶

You can include footnotes in your book using standard Markdown syntax.This will include a numbered reference to the footnote in-line, and append the footnoteto a list of footnotes at the bottom of the page.

To create a footnote, first insert a reference in-line with this syntax: [^mylabel].Then, define the text for that label like so:

You can define [^mylabel] anywhere in the page, though its definition will alwaysbe placed at the bottom of your built page. For example, here’s a footnote 1and here’s another one 2. You can click either of them to see the footnotesat the bottom of this page.

Custom <div> blocks¶

You can add custom div blocks along with whatever classes you’d like usingthe {div} directive. The {div} directive will wrap everything inside in a single <div> with the classes you provide. For example:

Blocks

Will result in the following HTML when your book is built:

This can be useful if you’d like to style your book with custom CSS or JavaScript.

1

Here’s the text of my first note.

2

And the text of my second note.Note thatyou can include Markdown footnote definitions.

-->

This article provides an alphabetical reference for writing Markdown for docs.microsoft.com (Docs).

Markdown is a lightweight markup language with plain text formatting syntax. Docs supports CommonMark compliant Markdown parsed through the Markdig parsing engine. Docs also supports custom Markdown extensions that provide richer content on the Docs site.

You can use any text editor to write Markdown, but we recommend Visual Studio Code with the Docs Authoring Pack. The Docs Authoring Pack provides editing tools and preview functionality that lets you see what your articles will look like when rendered on Docs.

Alerts (Note, Tip, Important, Caution, Warning)

Alerts are a Markdown extension to create block quotes that render on docs.microsoft.com with colors and icons that indicate the significance of the content. The following alert types are supported:

These alerts look like this on docs.microsoft.com:

Note

Information the user should notice even if skimming.

Tip

Optional information to help a user be more successful.

Important

Essential information required for user success.

Caution

Negative potential consequences of an action.

Warning

Dangerous certain consequences of an action.

Angle brackets

If you use angle brackets in text in your file--for example, to denote a placeholder--you need to manually encode the angle brackets. Otherwise, Markdown thinks that they're intended to be an HTML tag.

For example, encode <script name> as &lt;script name&gt; or <script name>.

Angle brackets don't have to be escaped in text formatted as inline code or in code blocks.

Apostrophes and quotation marks

If you copy from Word into a Markdown editor, the text might contain 'smart' (curly) apostrophes or quotation marks. These need to be encoded or changed to basic apostrophes or quotation marks. Otherwise, you end up with things like this when the file is published: It’s

Here are the encodings for the 'smart' versions of these punctuation marks:

  • Left (opening) quotation mark: &#8220;
  • Right (closing) quotation mark: &#8221;
  • Right (closing) single quotation mark or apostrophe: &#8217;
  • Left (opening) single quotation mark (rarely used): &#8216;

Blockquotes

Blockquotes are created using the > character:

The preceding example renders as follows:

This is a blockquote. It is usually rendered indented and with a different background color.

Bold and italic text

To format text as bold, enclose it in two asterisks:

To format text as italic, enclose it in a single asterisk:

To format text as both bold and italic, enclose it in three asterisks:

Code snippets

Docs Markdown supports the placement of code snippets both inline in a sentence and as a separate 'fenced' block between sentences. For more information, see How to add code to docs.

Columns

The columns Markdown extension gives Docs authors the ability to add column-based content layouts that are more flexible and powerful than basic Markdown tables, which are only suited for true tabular data. You can add up to four columns, and use the optional span attribute to merge two or more columns.

The syntax for columns is as follows:

Columns should only contain basic Markdown, including images. Headings, tables, tabs, and other complex structures shouldn't be included. A row can't have any content outside of column.

For example, the following Markdown creates one column that spans two column widths, and one standard (no span) column:

This renders as follows:

This is a 2-span column with lots of text.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec vestibulum mollis nuncornare commodo. Nullam ac metus imperdiet, rutrum justo vel, vulputate leo. Donecrutrum non eros eget consectetur.

Headings

Docs supports six levels of Markdown headings:

  • There must be a space between the last # and heading text.
  • Each Markdown file must have one and only one H1 heading.
  • The H1 heading must be the first content in the file after the YML metadata block.
  • H2 headings automatically appear in the right-hand navigating menu of the published file. Lower-level headings don't appear, so use H2s strategically to help readers navigate your content.
  • HTML headings, such as <h1>, aren't recommended, and in some cases will cause build warnings.
  • You can link to individual headings in a file via bookmark links.

HTML

Although Markdown supports inline HTML, HTML isn't recommended for publishing to Docs, and except for a limited list of values will cause build errors or warnings.

Images

The following file types are supported by default for images:

  • .jpg
  • .png

Standard conceptual images (default Markdown)

The basic Markdown syntax to embed an image is:

Where <alt text> is a brief description of the image and <folder path> is a relative path to the image. Alternate text is required for screen readers for the visually impaired. It's also useful if there's a site bug where the image can't render.

Underscores in alt text aren't rendered properly unless you escape them by prefixing them with a backslash (_). However, don't copy file names for use as alt text. For example, instead of this:

Write this:

Standard conceptual images (Docs Markdown)

The Docs custom :::image::: extension supports standard images, complex images, and icons.

For standard images, the older Markdown syntax will still work, but the new extension is recommended because it supports more powerful functionality, such as specifying a localization scope that's different from the parent topic. Other advanced functionality, such as selecting from the shared image gallery instead of specifying a local image, will be available in the future. The new syntax is as follows:

If type='content' (the default), both source and alt-text are required.

Complex images with long descriptions

You can also use this extension to add an image with a long description that is read by screen readers but not rendered visually on the published page. Long descriptions are an accessibility requirement for complex images, such as graphs. The syntax is the following:

If type='complex', source, alt-text, a long description, and the :::image-end::: tag are all required.

Specifying loc-scope

Sometimes the localization scope for an image is different from that of the article or module that contains it. This can cause a bad global experience: for example, if a screenshot of a product is accidentally localized into a language the product isn't available in. To prevent this, you can specify the optional loc-scope attribute in images of types content and complex.

Icons

The image extension supports icons, which are decorative images and should not have alt text. The syntax for icons is:

If type='icon', only source should be specified.

Included Markdown files

Where markdown files need to be repeated in multiple articles, you can use an include file. The includes feature instructs Docs to replace the reference with the contents of the include file at build time. You can use includes in the following ways:

  • Inline: Reuse a common text snippet inline with within a sentence.
  • Block: Reuse an entire Markdown file as a block, nested within a section of an article.

An inline or block include file is a Markdown (.md) file. It can contain any valid Markdown. Include files are typically located in a common includes subdirectory, in the root of the repository. When the article is published, the included file is seamlessly integrated into it.

Includes syntax

Block include is on its own line:

Inline include is within a line:

Where <title> is the name of the file and <filepath> is the relative path to the file. INCLUDE must be capitalized and there must be a space before the <title>.

Here are requirements and considerations for include files:

  • Use block includes for significant amounts of content--a paragraph or two, a shared procedure, or a shared section. Do not use them for anything smaller than a sentence.
  • Includes won't be rendered in the GitHub rendered view of your article, because they rely on Docs extensions. They'll be rendered only after publication.
  • Ensure that all the text in an include file is written in complete sentences or phrases that do not depend on preceding text or following text in the article that references the include. Ignoring this guidance creates an untranslatable string in the article.
  • Don't embed include files within other include files.
  • Place media files in a media folder that's specific to the include subdirectory--for instance, the <repo>/includes/media folder. The media directory should not contain any images in its root. If the include does not have images, a corresponding media directory is not required.
  • As with regular articles, don't share media between include files. Use a separate file with a unique name for each include and article. Store the media file in the media folder that's associated with the include.
  • Don't use an include as the only content of an article. Includes are meant to be supplemental to the content in the rest of the article.

Links

For information on syntax for links, see Use links in documentation.

Lists (Numbered, Bulleted, Checklist)

Numbered list

To create a numbered list, you can use all 1s. The numbers are rendered in ascending order as a sequential list when published. For increased source readability, you can increment your lists manually.

Don't use letters in lists, including nested lists. They don't render correctly when published to Docs. Nested lists using numbers will render as lowercase letters when published. For example:

This renders as follows:

  1. This is
  2. a parent numbered list
    1. and this is
    2. a nested numbered list
  3. (fin)

Bulleted list

To create a bulleted list, use - or * followed by a space at the beginning of each line:

This renders as follows:

  • This is
  • a parent bulleted list
    • and this is
    • a nested bulleted list
  • All done!

Whichever syntax you use, - or *, use it consistently within an article.

Checklist

Checklists are available for use on Docs via a custom Markdown extension:

This example renders on Docs like this:

  • List item 1
  • List item 2
  • List item 3

Use checklists at the beginning or end of an article to summarize 'What will you learn' or 'What have you learned' content. Do not add random checklists throughout your articles.

Next step action

You can use a custom extension to add a next step action button to Docs pages.

The syntax is as follows:

For example:

This renders as follows:

You can use any supported link in a next step action, including a Markdown link to another web page. In most cases, the next action link will be a relative link to another file in the same docset.

Non-localized strings

You can use the custom no-loc Markdown extension to identify strings of content that you would like the localization process to ignore.

All strings called out will be case-sensitive; that is, the string must match exactly to be ignored for localization.

To mark an individual string as non-localizable, use this syntax:

For example, in the following, only the single instance of Document will be ignored during the localization process:

Note

Use to escape special characters:

You can also use metadata in the YAML header to mark all instances of a string within the current Markdown file as non-localizable:

Note

The no-loc metadata is not supported as global metadata in docfx.json file. The localization pipeline doesn't read the docfx.json file, so the no-loc metadata must be added into each individual source file.

In the following example, both in the metadata title and the Markdown header the word Document will be ignored during the localization process.

In the metadata description and the Markdown main content the word document is localized, because it does not start with a capital D.

Selectors

Selectors are UI elements that let the user switch between multiple flavors of the same article. They are used in some doc sets to address differences in implementation across technologies or platforms. Selectors are typically most applicable to our mobile platform content for developers.

Because the same selector Markdown goes in each article file that uses the selector, we recommend placing the selector for your article in an include file. Then you can reference that include file in all your article files that use the same selector.

There are two types of selectors: a single selector and a multi-selector.

Single selector

... will be rendered like this:

Multi-selector

... will be rendered like this:

Subscript and superscript

You should only use subscript or superscript when necessary for technical accuracy, such as when writing about mathematical formulas. Don't use them for non-standard styles, such as footnotes.

For both subscript and superscript, use HTML:

This renders as follows:

Hello This is subscript!

This renders as follows:

Goodbye This is superscript!

Tables

The simplest way to create a table in Markdown is to use pipes and lines. To create a standard table with a header, follow the first line with dashed line:

This renders as follows:

This isa simpletable header
tabledatahere
it doesn'tactuallyhave to line up nicely!

You can align the columns by using colons:

Renders as follows:

FunWithTables
left-aligned columnright-aligned columncentered column
$100$100$100
$10$10$10
$1$1$1

Tip

The Docs Authoring Extension for VS Code makes it easy to add basic Markdown tables!

You can also use an online table generator.

Line breaks within words in any table cell

Long words in a Markdown table might make the table expand to the right navigation and become unreadable. You can solve that by allowing Docs rendering to automatically insert line breaks within words when needed. Just wrap up the table with the custom class [!div].

Here is a Markdown sample of a table with three rows that will be wrapped by a div with the class name mx-tdBreakAll.

It will be rendered like this:

NameSyntaxMandatory for silent installation?Description
Quiet/quietYesRuns the installer, displaying no UI and no prompts.
NoRestart/norestartNoSuppresses any attempts to restart. By default, the UI will prompt before restart.
Help/helpNoProvides help and quick reference. Displays the correct use of the setup command, including a list of all options and behaviors.

Line breaks within words in second column table cells

You might want line breaks to be automatically inserted within words only in the second column of a table. To limit the breaks to the second column, apply the class mx-tdCol2BreakAll by using the div wrapper syntax as shown earlier.

Markdown Blockquote

Data matrix tables

A data matrix table has both a header and a weighted first column, creating a matrix with an empty cell in the top left. Docs has custom Markdown for data matrix tables:

Every entry in the first column must be styled as bold (**bold**); otherwise the tables won't be accessible for screen readers or valid for Docs.

HTML Tables

Markdown Block Text

HTML tables aren't recommended for docs.microsoft.com. They aren't human readable in the source - which is a key principle of Markdown.