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