用語集

左側のキーワードの1つを選択…

UtilitiesMarkdown

読書の時間: ~25 min

Websites are written in HTML, which is a document specification language that supports many embellishments like boldface, italics, numbered lists, links, etc. HTML can be difficult to read directly, however, because the markers are quite obtrusive. Here's a (silly) example to illustrate the point:

Markdown was invented in 2004 by John Gruber and Aaron Swartz as a tool for specifying rich text (boldface, italics, links, etc.) in a plain text file that is easy to read and write. Here's the example above in Markdown:

The *quick* brown fox **jumped** over the lazy `dog`.

Markdown has since become a lingua franca among developers and data scientists. For example, forum content on GitHub is specified in Markdown. Rather than having a single rich-text editor, the user is presented with a plain text editor and a Preview tab to see how the Markdown will render in the forum:

Markdown rules

The list of essential Markdown rules is pretty short:

  1. Boldface is indicated with double underscores or double asterisks: __This text is bold__ or **This text is bold**.

  1. For italics, use underscores or asterisks: _This text is italic_ or *This text is italic*.

  1. Headers are indicated with a number of hashmarks followed by a space and the header text. Top-level headers use a single hashmark, and using more hashmarks makes the resulting font size increasingly small

    # Top-level title
    ## Section 1
    ### Subsection
    ## Section 2

  1. Links use square brackets around the text to be displayed and parentheses around the URL to be linked: [Click here](http://www.google.com).

  1. Images are included using the link syntax preceded by an exclamation point. The contents of the square brackets are used as alt-text (the text that appears if there's an issue loading the image).

    ![a tiger](https://upload.wikimedia.org/wikipedia/commons/5/56/Tiger.50.jpg)

  1. Blockquotes are marked with a greater-than sign at the beginning of the line:

    > "Imagination is more important than knowledge." -Albert Einstein

  1. Bullet lists are achieved with an asterisk and a space at the beginning of each line containing a list item:

    * Limits
    * Differentiation
    * Integration

  1. Numbered lists use numbers instead of asterisks. Numbers are assigned sequentially when the list is rendered, so you can use 1 for every list item in the source file. For nested lists, indent two spaces:

    1. Limits
    1. Differentiation
      1. Power rule
      2. Product rule
      3. Chain rule
    1. Integration
      1. Power rule
      1. Substitution
      1. Integration-by-parts

  1. Inline code is surrounded by backticks, as in "try the `sqrt` function". Code blocks are surrounded by three backticks, with an optional language name following the first set:

    ```python
    import numpy as np
    np.sqrt(3)
    ```

  1. A single newline character is ignored by default, so that you can break up the lines of a paragraph however you want without affecting the output. To separarate paragraphs, put a blank line between them. To force a line break without a paragraph break, put two spaces just before the newline.

Exercise
Answer each of the following questions about Markdown.

  1. Code fences are marked using .
  2. Markdown will automatically correct the numbering in your numbered lists .
  3. The syntax for inserting an image is an followed by containing the followed by containing the .
  4. The syntax for inserting links is containing the followed by containing the .
  5. Inline code is indicated using .
  6. Section headings are indicated using followed by a .
  7. For boldface or italics, use or underscores (or asterisks), respectively.
Bruno
Bruno Bruno