Make all Markdown extensions configurable Allow site admins to selectively enable or disable Markdown extensions. This can help a site avoid creating documentation that isn't compatible with other CommonMark parsers. Change-Id: I0466b03ef213a398d79f943af2ddf95a7e0853e7
diff --git a/Documentation/config.md b/Documentation/config.md index 65feff2..27db57a 100644 --- a/Documentation/config.md +++ b/Documentation/config.md
@@ -52,8 +52,51 @@ imageLimit = 256K ``` +### Extensions + +The following extensions can be enabled/disabled in the markdown +section: + +* `githubFlavor`: enable extensions that mirror GitHub Flavor + Markdown behavior. Default is true. + +* `autolink`: automatically convert plain URLs and email + addresses into links. Default follows `gihubFlavor`. + +* `blocknote`: Gitiles style note/promo/aside blocks to raise + awareness to important content. Default false. + +* `ghthematicbreak`: accept `--` for `<hr>`, like GitHub Flavor + Markdown. Default follows `githubFlavor`. + +* `multicolumn`: Gitiles extension to layout content in a 12 cell + grid, delinated by section headers. Default false. + +* `namedanchor`: Gitiles extension to extract named anchors using + `#{id}` syntax. Default false. + +* `safehtml`: Gitiles extension to accept very limited HTML; for + security reasons all other HTML is dropped regardless of this + setting. Default follows `githubFlavor`. + +* `smartquote`: Gitiles extension to convert single and double quote + ASCII characters to Unicode smart quotes when in prose. Default + false. + +* `strikethrough`: strikethrough text with GitHub Flavor Markdown + style `~~`. Default follows `githubFlavor`. + +* `tables`: format tables with GitHub Flavor Markdown. Default + follows `githubFlavor`. + +* `toc`: Gitiles extension to replace `[TOC]` in a paragraph by itself + with a server-side generated table of contents extracted from section + headers. Default true. + ### IFrames +IFrame support requires `markdown.safehtml` to be true. + IFrame source URLs can be whitelisted by providing a list of allowed URLs. URLs ending with a `/` are treated as prefixes, allowing any source URL beginning with that prefix.
diff --git a/Documentation/markdown.md b/Documentation/markdown.md index 958fed9..23e3bae 100644 --- a/Documentation/markdown.md +++ b/Documentation/markdown.md
@@ -150,6 +150,8 @@ ### Tables +Requires `markdown.tables` to be true (default). + Simple tables are supported with column alignment. The first line is the header row and subsequent lines are data rows: @@ -199,6 +201,8 @@ ### Strikethrough +Requires `markdown.strikethrough` to be true (default). + Text can be ~~struck out~~ within a paragraph: ``` @@ -313,9 +317,10 @@ ### Horizontal rules -A horizontal rule can be inserted using GitHub style `--` surrounded -by blank lines. Alternatively repeating `-` or `*` and space on a -line will also create a horizontal rule: +If `markdown.ghthematicbreak` is true, a horizontal rule can be +inserted using GitHub style `--` surrounded by blank lines. +Alternatively repeating `-` or `*` and space on a line will also +create a horizontal rule: ``` --- @@ -380,7 +385,7 @@ ### Named anchors Explicit anchors can be inserted anywhere in the document using -`<a name="tag"></a>` or `{#tag}`. +`<a name="tag"></a>`, or `{#tag}` if `markdown.namedanchor` is true. Implicit anchors are automatically created for each [heading](#Headings). For example `## Section 1` will have @@ -460,9 +465,9 @@ by the parser with no warnings, and no output from that section of the document. -There are small exceptions for `<br>`, `<hr>`, `<a name>` and -`<iframe>` elements, see [named anchor](#Named-anchors) and -[HTML IFrame](#HTML-IFrame). +If `markdown.safehtml` is true there are small exceptions for `<br>`, +`<hr>`, `<a name>` and `<iframe>` elements, see [named anchor](#Named-anchors) +and [HTML IFrame](#HTML-IFrame). ## Markdown extensions @@ -471,6 +476,8 @@ ### Table of contents +Requires `markdown.toc` to be true. + Place `[TOC]` surrounded by blank lines to insert a generated table of contents extracted from the H1, H2, and H3 headers used within the document: @@ -496,6 +503,8 @@ ### Notification, aside, promotion blocks +Requires `markdown.blocknote` to be true. + Similar to fenced code blocks these blocks start and end with `***`, are surrounded by blank lines, and include the type of block on the opening line. @@ -538,6 +547,8 @@ ### Column layout +Requires `markdown.multicolumn` to be true. + Gitiles markdown includes support for up to 12 columns of text across the width of the page. By default space is divided equally between the columns. @@ -608,6 +619,8 @@ ### HTML IFrame +Requires `markdown.safehtml` to be true (default). + Although HTML is stripped the parser has special support for a limited subset of `<iframe>` elements: