Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 1 | # Markdown |
| 2 | |
Han-Wen Nienhuys | 7144d60 | 2017-01-17 12:49:04 +0100 | [diff] [blame] | 3 | The [Gitiles](https://gerrit.googlesource.com/gitiles/) source browser |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 4 | automatically renders `*.md` Markdown files into HTML for simplified |
| 5 | documentation. |
| 6 | |
| 7 | [TOC] |
| 8 | |
| 9 | ## Access controls |
| 10 | |
| 11 | Access controls for documentation is identical to source code. |
| 12 | |
| 13 | Documentation stored with source files shares the same permissions. |
| 14 | Documentation stored in a separate Git repository can use different |
| 15 | access controls. If Gerrit Code Review is being used, branch level |
| 16 | read permissions can be used to grant or restrict access to any |
| 17 | documentation branches. |
| 18 | |
| 19 | ## READMEs |
| 20 | |
| 21 | Files named `README.md` are automatically displayed below the file's |
| 22 | directory listing. For the top level directory this mirrors the |
| 23 | standard [GitHub](https://github.com/) presentation. |
| 24 | |
| 25 | *** promo |
| 26 | README.md files are meant to provide orientation for developers |
| 27 | browsing the repository, especially first-time users. |
| 28 | *** |
| 29 | |
| 30 | We recommend that Git repositories have an up-to-date top-level |
| 31 | `README.md` file. |
| 32 | |
| 33 | ## Markdown syntax |
| 34 | |
| 35 | Gitiles supports the core Markdown syntax described in |
| 36 | [Markdown Basics]. Additional extensions are supported |
| 37 | to more closely match [GitHub Flavored Markdown] and |
| 38 | simplify documentation writing. |
| 39 | |
| 40 | [Markdown Basics]: http://daringfireball.net/projects/markdown/basics |
| 41 | [GitHub Flavored Markdown]: https://help.github.com/articles/github-flavored-markdown/ |
| 42 | |
| 43 | ### Paragraphs |
| 44 | |
| 45 | Paragraphs are one or more lines of consecutive text, followed by |
| 46 | one or more blank lines. Line breaks within a paragraph are ignored |
| 47 | by the parser, allowing authors to line-wrap text at any comfortable |
| 48 | column width. |
| 49 | |
| 50 | ``` |
| 51 | Documentation writing can be fun and profitable |
| 52 | by helping users to learn and solve problems. |
| 53 | |
| 54 | After documentation is written, it needs to be published on the |
| 55 | web where it can be easily accessed for reading. |
| 56 | ``` |
| 57 | |
| 58 | ### Headings |
| 59 | |
| 60 | Headings can be indicated by starting the line with one or more `#` |
| 61 | marks. The number of `#` used determines the depth of the heading in |
| 62 | the document outline. Headings 1 through 6 (`######`) are supported. |
| 63 | |
| 64 | ``` |
| 65 | # A level one (H1) heading |
| 66 | ## A level two (H2) heading |
| 67 | ### A level three (H3) heading |
| 68 | ``` |
| 69 | |
| 70 | Headings can also use the less popular two line `======` and `------` |
| 71 | forms to create H1 and H2 level headers: |
| 72 | |
| 73 | ``` |
| 74 | A first level header |
| 75 | ==================== |
| 76 | |
| 77 | A second level header |
| 78 | --------------------- |
| 79 | ``` |
| 80 | |
| 81 | This form is discouraged as maintaining the length of the `===` or |
| 82 | `---` lines to match the preceding line can be tedious work that is |
| 83 | unnecessary with the `#` headers. |
| 84 | |
| 85 | ### Lists |
| 86 | |
| 87 | A bullet list: |
| 88 | |
| 89 | ``` |
| 90 | * Fruit |
| 91 | * Orange |
| 92 | * Pear |
| 93 | * Cake |
| 94 | ``` |
| 95 | |
| 96 | will render into HTML as: |
| 97 | |
| 98 | * Fruit |
| 99 | * Orange |
| 100 | * Pear |
| 101 | * Cake |
| 102 | |
| 103 | The second level items (above Orange, Pear) must be indented with more |
| 104 | spaces than the item they are nested under. Above 2 spaces were used. |
Shannon Woods | 7ea7112 | 2015-11-05 16:05:05 -0500 | [diff] [blame] | 105 | Additionally, the entire list must be preceded and followed by a blank |
| 106 | line. |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 107 | |
| 108 | A numbered list: |
| 109 | |
| 110 | ``` |
| 111 | 1. Fruit |
| 112 | 1. Orange |
| 113 | 2. Pear |
| 114 | 5. Cake |
| 115 | ``` |
| 116 | |
| 117 | will render into HTML as: |
| 118 | |
| 119 | 1. Fruit |
| 120 | 1. Orange |
| 121 | 2. Pear |
| 122 | 5. Cake |
| 123 | |
| 124 | List items will be renumbered sequentially by the browser, which is |
| 125 | why `5` above displays as `2`. Even with this feature it is a good |
| 126 | idea to maintain list item numbers in the source Markdown to simplify |
| 127 | reading the source file. |
| 128 | |
| 129 | Like bullet lists, numbered lists can be nested by using more leading |
| 130 | space than the prior list item. |
| 131 | |
David Pursehouse | 3146836 | 2016-10-04 14:48:28 +0900 | [diff] [blame] | 132 | Paragraphs can be properly nested within lists by indenting with at |
| 133 | least 2 leading spaces: |
| 134 | |
| 135 | ``` |
| 136 | 1. Fruit |
| 137 | |
| 138 | In botany, a fruit is the seed-bearing structure in flowering |
| 139 | plants. |
| 140 | |
| 141 | In common language usage, "fruit" normally means the fleshy |
| 142 | seed-associated structures of a plant that are sweet or sour, and |
| 143 | edible in the raw state, such as apples, bananas, grapes, lemons, |
| 144 | oranges, and strawberries. |
| 145 | |
| 146 | 2. Cake |
| 147 | |
| 148 | The cake is a lie. |
| 149 | ``` |
| 150 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 151 | ### Tables |
| 152 | |
Shawn Pearce | b55cf2b | 2017-06-29 21:56:37 -0700 | [diff] [blame] | 153 | Requires `markdown.tables` to be true (default). |
| 154 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 155 | Simple tables are supported with column alignment. The first line is |
| 156 | the header row and subsequent lines are data rows: |
| 157 | |
| 158 | ``` |
| 159 | | Food | Calories | Tasty? | |
| 160 | |-------|---------:|:------:| |
| 161 | | Apple | 95 | Yes | |
| 162 | | Pear | 102 | Yes | |
| 163 | | Hay | 977 | | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 164 | ``` |
| 165 | |
| 166 | will render as: |
| 167 | |
| 168 | | Food | Calories | Tasty? | |
| 169 | |-------|---------:|:------:| |
| 170 | | Apple | 95 | Yes | |
| 171 | | Pear | 102 | Yes | |
| 172 | | Hay | 977 | | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 173 | |
| 174 | Placing `:` in the separator line indicates how the column should be |
| 175 | aligned. A colon on the left side is a **left-aligned** column; a |
| 176 | colon on the right-most side is **right-aligned**; a colon on both |
David Pursehouse | dea03ba | 2017-06-29 21:08:49 +0900 | [diff] [blame] | 177 | sides is **center-aligned**. If no alignment is specified, the column |
| 178 | is aligned with the default for HTML `<td>` tags (left-aligned by |
| 179 | default unless overridden by css). |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 180 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 181 | Empty table cells are indicated by whitespace between the column |
| 182 | dividers (`| |`) while multiple column cells omit the whitespace. |
| 183 | |
| 184 | ### Emphasis |
| 185 | |
| 186 | Emphasize paragraph text with *italic* and **bold** styles. Either `_` |
| 187 | or `*` can be used for italic (1 character) and bold text (2 |
| 188 | characters). This allows styles to be mixed within a statement: |
| 189 | |
| 190 | ``` |
| 191 | Emphasize paragraph text with *italic* and **bold** text. |
| 192 | |
| 193 | **It is _strongly_ encouraged to review documentation for typos.** |
| 194 | ``` |
| 195 | |
| 196 | **It is _strongly_ encouraged to review documentation for typos.** |
| 197 | |
| 198 | Emphasis within_words_is_ignored which helps write technical |
| 199 | documentation. Literal \*bold* can be forced by prefixing the |
| 200 | opening `*` with \ such as `\*bold*`. |
| 201 | |
| 202 | ### Strikethrough |
| 203 | |
Shawn Pearce | b55cf2b | 2017-06-29 21:56:37 -0700 | [diff] [blame] | 204 | Requires `markdown.strikethrough` to be true (default). |
| 205 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 206 | Text can be ~~struck out~~ within a paragraph: |
| 207 | |
| 208 | ``` |
| 209 | Text can be ~~struck out~~ within a paragraph. |
| 210 | ``` |
| 211 | |
| 212 | Note two tildes are required (`~~`) on either side of the struck out |
| 213 | section of text. |
| 214 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 215 | ### Blockquotes |
| 216 | |
| 217 | Blockquoted text can be used to stand off text obtained from |
| 218 | another source: |
| 219 | |
| 220 | ``` |
| 221 | Sir Winston Churchill once said: |
| 222 | |
| 223 | > A lie gets halfway around the world before the truth has a |
| 224 | > chance to get its pants on. |
| 225 | ``` |
| 226 | |
| 227 | renders as: |
| 228 | |
| 229 | Sir Winston Churchill once said: |
| 230 | |
| 231 | > A lie gets halfway around the world before the truth has a |
| 232 | > chance to get its pants on. |
| 233 | |
| 234 | ### Code (inline) |
| 235 | |
| 236 | Use `backticks` to markup inline code within a paragraph: |
| 237 | |
| 238 | ``` |
| 239 | Use `backticks` to markup inline code within a paragraph. |
| 240 | ``` |
| 241 | |
| 242 | ### Code (blocks) |
| 243 | |
| 244 | Create a fenced code block using three backticks before and after a |
| 245 | block of code, preceeded and followed by blank lines: |
| 246 | |
Shawn Pearce | 12c8fab | 2016-05-15 16:55:21 -0700 | [diff] [blame] | 247 | ```` |
| 248 | This is a simple hello world program in C: |
| 249 | |
| 250 | ``` c |
| 251 | #include <stdio.h> |
| 252 | |
| 253 | int main() { |
| 254 | printf("Hello, World.\n"); |
| 255 | return 0; |
| 256 | } |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 257 | ``` |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 258 | |
Shawn Pearce | 12c8fab | 2016-05-15 16:55:21 -0700 | [diff] [blame] | 259 | To compile it use `gcc hello.c`. |
| 260 | ```` |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 261 | |
| 262 | Text within a fenced code block is taken verbatim and is not |
| 263 | processed for Markdown markup. |
| 264 | |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 265 | Syntax highlighting can optionally be enabled for common languages |
| 266 | by adding the language name in lowercase on the opening line. |
| 267 | Supported languages include: |
| 268 | |
| 269 | |||---||| 2,2,2,2,4 |
| 270 | |
| 271 | #### Scripting |
| 272 | * bash, sh |
| 273 | * lua |
| 274 | * perl |
| 275 | * python, py |
| 276 | * ruby |
| 277 | * tcl |
| 278 | |
Andrew Bonventre | 4434b80 | 2015-09-29 12:27:56 -0400 | [diff] [blame] | 279 | #### Web |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 280 | * css |
| 281 | * dart |
| 282 | * html |
| 283 | * javascript, js |
| 284 | * json |
| 285 | |
| 286 | #### Compiled |
| 287 | * basic, vb |
| 288 | * c |
| 289 | * cpp (C++) |
| 290 | * go |
| 291 | * java |
| 292 | * pascal |
| 293 | * scala |
| 294 | |
| 295 | #### Markup |
| 296 | * tex, latex |
| 297 | * wiki |
| 298 | * xml |
| 299 | * xquery |
| 300 | * xsl |
| 301 | * yaml |
| 302 | |
| 303 | #### Other |
| 304 | * clj (Clojure) |
| 305 | * erlang |
| 306 | * hs (Haskell) |
| 307 | * lisp |
| 308 | * [llvm](http://llvm.org/docs/LangRef.html) |
| 309 | * matlab |
| 310 | * ml (OCaml, SML, F#) |
| 311 | * r |
| 312 | * [rd](http://cran.r-project.org/doc/manuals/R-exts.html) |
| 313 | * rust |
| 314 | * sql |
| 315 | * vhdl |
| 316 | |||---||| |
| 317 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 318 | ### Horizontal rules |
| 319 | |
Shawn Pearce | b55cf2b | 2017-06-29 21:56:37 -0700 | [diff] [blame] | 320 | If `markdown.ghthematicbreak` is true, a horizontal rule can be |
| 321 | inserted using GitHub style `--` surrounded by blank lines. |
| 322 | Alternatively repeating `-` or `*` and space on a line will also |
| 323 | create a horizontal rule: |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 324 | |
| 325 | ``` |
Shawn Pearce | 12c8fab | 2016-05-15 16:55:21 -0700 | [diff] [blame] | 326 | --- |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 327 | |
| 328 | - - - - |
| 329 | |
| 330 | * * * * |
| 331 | ``` |
| 332 | |
| 333 | ### Links |
| 334 | |
| 335 | Wrap text in `[brackets]` and the link destination in parens |
| 336 | `(http://...)` such as: |
| 337 | |
| 338 | ``` |
| 339 | Visit [this site](http://example.com/) for more examples. |
| 340 | ``` |
| 341 | |
| 342 | Links can also use references to obtain URLs from elsewhere in the |
| 343 | same document. This style can be useful if the same URL needs to be |
| 344 | mentioned multiple times, is too long to cleanly place within text, |
| 345 | or the link is within a table cell: |
| 346 | |
| 347 | ``` |
| 348 | Search for [markdown style][1] examples. |
| 349 | |
| 350 | [1]: https://www.google.com/?gws_rd=ssl#q=markdown+style+guide |
| 351 | ``` |
| 352 | |
| 353 | References can be simplified if the text alone is sufficient: |
| 354 | |
| 355 | ``` |
| 356 | Visit [Google] to search the web. |
| 357 | |
| 358 | [Google]: https://www.google.com/ |
| 359 | ``` |
| 360 | |
| 361 | Automatic hyperlinking can be used where the link text should |
| 362 | obviously also be the URL: |
| 363 | |
| 364 | ``` |
| 365 | Use https://www.google.com/ to search the web. |
| 366 | ``` |
| 367 | |
| 368 | Well formed URLs beginning with `https://`, `http://`, and `mailto:` |
| 369 | are used as written for the link's destination. Malformed URLs may be |
David Pursehouse | d40dbc2 | 2016-08-26 13:28:01 +0900 | [diff] [blame] | 370 | replaced with `about:invalid#zSoyz` to prevent browser evaluation of dangerous |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 371 | content. |
| 372 | |
| 373 | HTML escaping of URL characters such as `&` is handled internally by |
| 374 | the parser/formatter. Documentation writers should insert the URL |
| 375 | literally and allow the parser and formatter to make it HTML safe. |
| 376 | |
| 377 | Relative links such as `../src/api.md` are resolved relative to the |
| 378 | current markdown's file path within the Git repository. Absolute |
| 379 | links such as `/src/api.md` are resolved relative to the top of the |
| 380 | enclosing Git repository, but within the same branch or Git commit. |
| 381 | Links may point to any file in the repository. A link to a `*.md` |
| 382 | file will present the rendered markdown, while a link to a source file |
| 383 | will display the syntax highlighted source. |
| 384 | |
Shawn Pearce | 25d9196 | 2015-06-22 15:35:36 -0700 | [diff] [blame] | 385 | ### Named anchors |
| 386 | |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 387 | Explicit anchors can be inserted anywhere in the document using |
Shawn Pearce | b55cf2b | 2017-06-29 21:56:37 -0700 | [diff] [blame] | 388 | `<a name="tag"></a>`, or `{#tag}` if `markdown.namedanchor` is true. |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 389 | |
| 390 | Implicit anchors are automatically created for each |
| 391 | [heading](#Headings). For example `## Section 1` will have |
| 392 | the anchor `Section-1`. |
| 393 | |
| 394 | *** note |
| 395 | *Anchor generation* |
| 396 | |
| 397 | * letters and digits, after removing accents (á → a) |
David Pursehouse | f768078 | 2015-06-24 02:52:12 +0000 | [diff] [blame] | 398 | * spaces are replaced with hyphens (`-`) |
| 399 | * other characters are replaced with underscores (`_`) |
| 400 | * runs of hyphens and underscores are collapsed |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 401 | *** |
| 402 | |
| 403 | If a document contains the same named subsection under different |
| 404 | parents the parent anchor will prefix the subsections to |
| 405 | disambiguate. For example the following document will have anchors |
| 406 | `Running-Format` and `Coding-Format` and `Libraries` as that subsection |
| 407 | is unique: |
| 408 | |
| 409 | ``` |
| 410 | ## Running |
| 411 | ### Format |
| 412 | ## Coding |
| 413 | ### Format |
| 414 | ### Libraries |
| 415 | ``` |
| 416 | |
| 417 | When placed in a section header the explicit anchor will override |
| 418 | the automatic anchor. The following are identical and associate |
| 419 | the anchor `live-examples` with the section header instead of the |
| 420 | automaticly generated name `Examples`. |
Shawn Pearce | 25d9196 | 2015-06-22 15:35:36 -0700 | [diff] [blame] | 421 | |
| 422 | ``` |
| 423 | ## Examples {#live-examples} |
| 424 | ## Examples <a name="live-examples"></a> |
| 425 | ``` |
| 426 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 427 | ### Images |
| 428 | |
| 429 | Similar to links but begin with `!` to denote an image reference: |
| 430 | |
| 431 | ``` |
| 432 |  |
| 433 | ``` |
| 434 | |
| 435 | For images the text in brackets will be included as the alt text for |
| 436 | screen readers. |
| 437 | |
| 438 | Well formed image URLs beginning with `https://` and `http://` will be |
| 439 | used as written for the `<img src="...">` attribute. Malformed URLs |
| 440 | will be replaced with a broken `data:` reference to prevent browsers |
| 441 | from trying to load a bad destination. |
| 442 | |
| 443 | Relative and absolute links to image files within the Git repository |
| 444 | (such as `../images/banner.png`) are resolved during rendering by |
| 445 | inserting the base64 encoding of the image using a `data:` URI. Only |
James Zern | b592dbe | 2020-09-24 13:08:39 -0700 | [diff] [blame] | 446 | PNG (`*.png`), JPEG (`*.jpg` or `*.jpeg`), GIF (`*.gif`) and WebP (`*.webp`) |
| 447 | image formats are supported when referenced from the Git repository. |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 448 | |
Tom Fuke | 43c3f7f | 2020-12-10 09:37:59 +0000 | [diff] [blame] | 449 | Unsupported extensions or files larger than [image size](config.md#Image-size) |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 450 | limit (default 256K) will display a broken image. |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 451 | |
| 452 | *** note |
| 453 | _Inline image caching_ |
| 454 | |
| 455 | Gitiles allows browsers to locally cache rendered markdown pages. |
| 456 | Cache invalidation is triggered by the markdown file being modified |
| 457 | and having a different SHA-1 in Git. Inlined images may need a |
| 458 | documentation file update to be refreshed when viewed through unstable |
| 459 | URLs like `/docs/+/master/index.md`. |
| 460 | *** |
| 461 | |
| 462 | ### HTML |
| 463 | |
Shawn Pearce | 12c8fab | 2016-05-15 16:55:21 -0700 | [diff] [blame] | 464 | Most HTML tags are not supported. HTML will be dropped on the floor |
| 465 | by the parser with no warnings, and no output from that section of the |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 466 | document. |
| 467 | |
Shawn Pearce | b55cf2b | 2017-06-29 21:56:37 -0700 | [diff] [blame] | 468 | If `markdown.safehtml` is true there are small exceptions for `<br>`, |
| 469 | `<hr>`, `<a name>` and `<iframe>` elements, see [named anchor](#Named-anchors) |
| 470 | and [HTML IFrame](#HTML-IFrame). |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 471 | |
| 472 | ## Markdown extensions |
| 473 | |
| 474 | Gitiles includes additional extensions to the Markdown language that |
| 475 | make documentation writing for the web easier without using raw HTML. |
| 476 | |
| 477 | ### Table of contents |
| 478 | |
Shawn Pearce | b55cf2b | 2017-06-29 21:56:37 -0700 | [diff] [blame] | 479 | Requires `markdown.toc` to be true. |
| 480 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 481 | Place `[TOC]` surrounded by blank lines to insert a generated |
| 482 | table of contents extracted from the H1, H2, and H3 headers |
| 483 | used within the document: |
| 484 | |
| 485 | ``` |
| 486 | # Title |
| 487 | |
| 488 | [TOC] |
| 489 | |
| 490 | ## Section 1 |
| 491 | Blah blah... |
| 492 | |
| 493 | ## Section 2 |
| 494 | Go on... |
| 495 | ``` |
| 496 | |
| 497 | H1 headers are omitted from the table of contents if there is only one |
| 498 | level one header present. This allows H1 to be used as the document |
| 499 | title without creating an unnecessary entry in the table of contents. |
| 500 | |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 501 | Anchors are automatically extracted from the headers, see |
| 502 | [named anchors](#Named-anchors). |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 503 | |
| 504 | ### Notification, aside, promotion blocks |
| 505 | |
Shawn Pearce | b55cf2b | 2017-06-29 21:56:37 -0700 | [diff] [blame] | 506 | Requires `markdown.blocknote` to be true. |
| 507 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 508 | Similar to fenced code blocks these blocks start and end with `***`, |
| 509 | are surrounded by blank lines, and include the type of block on the |
| 510 | opening line. |
| 511 | |
| 512 | #### Note |
| 513 | |
| 514 | ``` |
| 515 | *** note |
| 516 | **Warning:** watch out for nested formatting. |
| 517 | *** |
| 518 | ``` |
| 519 | |
| 520 | *** note |
| 521 | **Warning:** watch out for nested formatting. |
| 522 | *** |
| 523 | |
| 524 | #### Aside |
| 525 | |
| 526 | ``` |
| 527 | *** aside |
| 528 | An aside can stand off less interesting text. |
| 529 | *** |
| 530 | ``` |
| 531 | |
| 532 | *** aside |
| 533 | An aside can stand off less interesting text. |
| 534 | *** |
| 535 | |
| 536 | #### Promo |
| 537 | |
| 538 | ``` |
| 539 | *** promo |
| 540 | Promotions can raise awareness of an important concept. |
| 541 | *** |
| 542 | ``` |
| 543 | |
| 544 | *** promo |
| 545 | Promotions can raise awareness of an important concept. |
| 546 | *** |
| 547 | |
| 548 | ### Column layout |
| 549 | |
Shawn Pearce | b55cf2b | 2017-06-29 21:56:37 -0700 | [diff] [blame] | 550 | Requires `markdown.multicolumn` to be true. |
| 551 | |
Shawn Pearce | ecddc61 | 2015-02-20 22:09:47 -0800 | [diff] [blame] | 552 | Gitiles markdown includes support for up to 12 columns of text across |
| 553 | the width of the page. By default space is divided equally between |
| 554 | the columns. |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 555 | |
| 556 | |||---||| |
| 557 | #### Columns |
| 558 | |
| 559 | can save space. |
| 560 | |
| 561 | #### Prettify |
| 562 | |
| 563 | the page layout. |
| 564 | |
| 565 | *** promo |
| 566 | #### Can be |
| 567 | |
| 568 | trendy. |
| 569 | *** |
| 570 | |||---||| |
| 571 | |
| 572 | A column layout is denoted by a block starting and ending with the |
| 573 | sequence `|||---|||`. Within the layout a new column is started for |
| 574 | each header or note/promo/aside block and all text and formatting flow |
| 575 | into that column until a new column is started. |
| 576 | |
| 577 | ``` |
| 578 | |||---||| |
| 579 | #### Columns |
| 580 | |
| 581 | can save space. |
| 582 | |
| 583 | #### Prettify |
| 584 | |
| 585 | the page layout. |
| 586 | |
| 587 | *** promo |
| 588 | #### Can be |
| 589 | |
| 590 | trendy. |
| 591 | *** |
| 592 | |||---||| |
| 593 | ``` |
| 594 | |
Shawn Pearce | ecddc61 | 2015-02-20 22:09:47 -0800 | [diff] [blame] | 595 | Column spans can be specified on the first line as a comma separated |
| 596 | list. In the example below the first column is 4 wide or 4/12ths of |
| 597 | the page width, the second is 2 wide (or 2/12ths) and the final column |
| 598 | is 6 wide (6/12ths or 50%) of the page. |
| 599 | |
| 600 | ``` |
| 601 | |||---||| 4,2,6 |
| 602 | ``` |
| 603 | |
| 604 | An empty column can be inserted by prefixing its width with `:`, |
| 605 | for example shifting content onto the right by padding 6 columns |
| 606 | on the left: |
| 607 | |
| 608 | ``` |
| 609 | |||---||| :6,3 |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 610 | #### Right |
Shawn Pearce | ecddc61 | 2015-02-20 22:09:47 -0800 | [diff] [blame] | 611 | |||---||| |
| 612 | ``` |
| 613 | |
| 614 | renders as: |
| 615 | |
| 616 | |||---||| :6,3 |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 617 | #### Right |
Shawn Pearce | ecddc61 | 2015-02-20 22:09:47 -0800 | [diff] [blame] | 618 | |||---||| |
| 619 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 620 | ### HTML IFrame |
| 621 | |
Shawn Pearce | b55cf2b | 2017-06-29 21:56:37 -0700 | [diff] [blame] | 622 | Requires `markdown.safehtml` to be true (default). |
| 623 | |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 624 | Although HTML is stripped the parser has special support for a limited |
| 625 | subset of `<iframe>` elements: |
| 626 | |
| 627 | ``` |
| 628 | <iframe src="https://example.com/embed" height="200px" width="400px"></iframe> |
| 629 | ``` |
| 630 | |
| 631 | The parser allows whitespace including newlines between attributes, |
| 632 | but strictly limits the supported attribute set to: |
| 633 | |
| 634 | src |
| 635 | : An `https://` or `http://` URL of the page to embed inside of an |
| 636 | iframe at this position in the document. Malformed URLs will cause |
| 637 | the iframe to be silently dropped. _(required)_ |
| 638 | |
| 639 | height |
| 640 | : CSS pixel height such as `250px` defining the amount of vertical |
| 641 | space to give to the embedded content. Only `px` units are supported; |
| 642 | a malformed dimension will drop the iframe. _(required)_ |
| 643 | |
| 644 | width |
| 645 | : CSS pixel width such as `250px` or a precentage such as `80%` |
| 646 | defining the amount of horizontal space to give to the embedded |
| 647 | content. Only `px` units or `%` are supported; a malformed dimension |
| 648 | will drop the iframe. _(required)_ |
| 649 | |
| 650 | frameborder |
| 651 | : By default a border is drawn around the iframe by the browser. The |
| 652 | border can be hidden by adding `frameborder="0"` to the iframe tag. |
| 653 | _(optional)_ |
| 654 | |
| 655 | Embedded source URLs must also be whitelisted by the Gitiles |
Shawn Pearce | 7e598e1 | 2016-08-26 08:51:12 -0700 | [diff] [blame] | 656 | [`markdown.allowiframe`](config.md#IFrames) configuration |
David Pursehouse | bbcc513 | 2016-08-26 13:26:13 +0900 | [diff] [blame] | 657 | variable. |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 658 | |
| 659 | ## Site layout |
| 660 | |
| 661 | Gitiles includes additional support to create functional documentation |
| 662 | sites served directly from Git repositories. |
| 663 | |
| 664 | ### Navigation bar |
| 665 | |
| 666 | A top level navigation bar is automatically included on all pages if |
| 667 | there is a `navbar.md` file present in the top of the repository. |
| 668 | This file should be a simple bulleted list of links to include in the |
| 669 | navigation bar. |
| 670 | |
| 671 | ``` |
| 672 | * [Home](/index.md) |
| 673 | * [Markdown](/docs/markdown.md) |
| 674 | * [Configuration](/docs/configuration.md) |
| 675 | ``` |
| 676 | |
| 677 | Links are resolved relative to the current page, not `navbar.md`. |
| 678 | Links to other files within the repository should use absolute paths |
| 679 | to ensure they are resolved correctly from any Markdown file within |
| 680 | the repository. |
| 681 | |
| 682 | ### Site title |
| 683 | |
Mike Colagrosso | ad02821 | 2016-01-20 23:25:59 -0700 | [diff] [blame] | 684 | A site-wide banner is displayed on all Markdown pages if `navbar.md` |
| 685 | includes an H1 header. The text of the header is displayed on the |
| 686 | left side of the banner. |
Shawn Pearce | a5dad19 | 2015-02-20 16:46:35 -0800 | [diff] [blame] | 687 | |
| 688 | ``` |
| 689 | # Gitiles |
| 690 | |
| 691 | * [Home](/index.md) |
| 692 | ``` |
| 693 | |
| 694 | ### Site logo |
| 695 | |
| 696 | An optional logo image is displayed in the banner to the left of the |
| 697 | site title if a `[logo]` reference exists in `navbar.md`. This image |
| 698 | should be no taller than 45 px. |
| 699 | |
| 700 | ``` |
| 701 | # Gitiles |
| 702 | |
| 703 | [logo]: /images/site_logo.png |
| 704 | ``` |
| 705 | |
| 706 | See [images](#Images) above for acceptable URLs and how repository |
| 707 | relative paths are handled by inline data URIs. |
| 708 | |
| 709 | ### Home link |
| 710 | |
| 711 | Both the site logo (if present) and site title are wrapped in a link |
| 712 | if the `[home]` reference is declared in `navbar.md`. This is |
| 713 | typically also used in the outline for the navigation bar: |
| 714 | |
| 715 | ``` |
| 716 | # Gitiles |
| 717 | |
| 718 | * [Home][home] |
| 719 | * [Markdown](/docs/markdown.md) |
| 720 | |
| 721 | [home]: /index.md |
| 722 | ``` |
| 723 | |
| 724 | ### Page title |
| 725 | |
| 726 | Titles for pages are extracted from the first H1 heading appearing in |
| 727 | the document. This is traditionally placed on the first line of the |
| 728 | markdown file, e.g.: |
| 729 | |
| 730 | ``` |
| 731 | # Markdown |
| 732 | ``` |
| 733 | |
| 734 | The title is included in the HTML `<title>` element and also in the |
| 735 | right side of the banner if `navbar.md` defines a |
| 736 | [site title](#Site-title). |
Shawn Pearce | 7b4044c | 2015-06-23 16:36:18 -0700 | [diff] [blame] | 737 | |
| 738 | ## Configuration |
| 739 | |
| 740 | The `gitiles.config` file supporting the site contains several |
David Pursehouse | 240fbff | 2016-08-25 09:58:15 +0900 | [diff] [blame] | 741 | configuration options that impact markdown rendering. Refer to the |
| 742 | [configuration documentation](config.md#Markdown) for details. |