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