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