A new Riff-radio.org site with a static approach.

quickstart.rst 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. .. title: A reStructuredText Primer
  2. .. slug: quickstart
  3. .. date: 2012-03-30 23:00:00 UTC-03:00
  4. .. tags:
  5. .. link:
  6. .. description:
  7. :Author: Richard Jones
  8. :Version: $Revision: 5801 $
  9. :Copyright: This document has been placed in the public domain.
  10. .. class:: alert alert-info pull-left
  11. .. contents::
  12. The text below contains links that look like "(quickref__)". These
  13. are relative links that point to the `Quick reStructuredText`_ user
  14. reference. If these links don't work, please refer to the `master
  15. quick reference`_ document.
  16. __
  17. .. _Quick reStructuredText: ../quickref/
  18. .. _master quick reference:
  19. https://docutils.sourceforge.io/docs/user/rst/quickref.html
  20. .. Note:: This document is an informal introduction to
  21. reStructuredText. The `What Next?`_ section below has links to
  22. further resources, including a formal reference.
  23. Structure
  24. ---------
  25. From the outset, let me say that "Structured Text" is probably a bit
  26. of a misnomer. It's more like "Relaxed Text" that uses certain
  27. consistent patterns. These patterns are interpreted by a HTML
  28. converter to produce "Very Structured Text" that can be used by a web
  29. browser.
  30. The most basic pattern recognised is a **paragraph** (quickref__).
  31. That's a chunk of text that is separated by blank lines (one is
  32. enough). Paragraphs must have the same indentation -- that is, line
  33. up at their left edge. Paragraphs that start indented will result in
  34. indented quote paragraphs. For example::
  35. This is a paragraph. It's quite
  36. short.
  37. This paragraph will result in an indented block of
  38. text, typically used for quoting other text.
  39. This is another one.
  40. Results in:
  41. This is a paragraph. It's quite
  42. short.
  43. This paragraph will result in an indented block of
  44. text, typically used for quoting other text.
  45. This is another one.
  46. __ ../quickref/#paragraphs
  47. Text styles
  48. -----------
  49. (quickref__)
  50. __ ../quickref/#inline-markup
  51. Inside paragraphs and other bodies of text, you may additionally mark
  52. text for *italics* with "``*italics*``" or **bold** with
  53. "``**bold**``". This is called "inline markup".
  54. If you want something to appear as a fixed-space literal, use
  55. "````double back-quotes````". Note that no further fiddling is done
  56. inside the double back-quotes -- so asterisks "``*``" etc. are left
  57. alone.
  58. If you find that you want to use one of the "special" characters in
  59. text, it will generally be OK -- reStructuredText is pretty smart.
  60. For example, this lone asterisk * is handled just fine, as is the
  61. asterisk in this equation: 5*6=30. If you actually
  62. want text \*surrounded by asterisks* to **not** be italicised, then
  63. you need to indicate that the asterisk is not special. You do this by
  64. placing a backslash just before it, like so "``\*``" (quickref__), or
  65. by enclosing it in double back-quotes (inline literals), like this::
  66. ``*``
  67. __ ../quickref/#escaping
  68. .. Tip:: Think of inline markup as a form of (parentheses) and use it
  69. the same way: immediately before and after the text being marked
  70. up. Inline markup by itself (surrounded by whitespace) or in the
  71. middle of a word won't be recognized. See the `markup spec`__ for
  72. full details.
  73. __ https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup
  74. Lists
  75. -----
  76. Lists of items come in three main flavours: **enumerated**,
  77. **bulleted** and **definitions**. In all list cases, you may have as
  78. many paragraphs, sublists, etc. as you want, as long as the left-hand
  79. side of the paragraph or whatever aligns with the first line of text
  80. in the list item.
  81. Lists must always start a new paragraph -- that is, they must appear
  82. after a blank line.
  83. **enumerated** lists (numbers, letters or roman numerals; quickref__)
  84. __ ../quickref/#enumerated-lists
  85. Start a line off with a number or letter followed by a period ".",
  86. right bracket ")" or surrounded by brackets "( )" -- whatever you're
  87. comfortable with. All of the following forms are recognised::
  88. 1. numbers
  89. A. upper-case letters
  90. and it goes over many lines
  91. with two paragraphs and all!
  92. a. lower-case letters
  93. 3. with a sub-list starting at a different number
  94. 4. make sure the numbers are in the correct sequence though!
  95. I. upper-case roman numerals
  96. i. lower-case roman numerals
  97. (1) numbers again
  98. 1) and again
  99. Results in (note: the different enumerated list styles are not
  100. always supported by every web browser, so you may not get the full
  101. effect here):
  102. 1. numbers
  103. A. upper-case letters
  104. and it goes over many lines
  105. with two paragraphs and all!
  106. a. lower-case letters
  107. 3. with a sub-list starting at a different number
  108. 4. make sure the numbers are in the correct sequence though!
  109. I. upper-case roman numerals
  110. i. lower-case roman numerals
  111. (1) numbers again
  112. 1) and again
  113. **bulleted** lists (quickref__)
  114. __ ../quickref/#bullet-lists
  115. Just like enumerated lists, start the line off with a bullet point
  116. character - either "-", "+" or "*"::
  117. * a bullet point using "*"
  118. - a sub-list using "-"
  119. + yet another sub-list
  120. - another item
  121. Results in:
  122. * a bullet point using "*"
  123. - a sub-list using "-"
  124. + yet another sub-list
  125. - another item
  126. **definition** lists (quickref__)
  127. __ ../quickref/#definition-lists
  128. Unlike the other two, the definition lists consist of a term, and
  129. the definition of that term. The format of a definition list is::
  130. what
  131. Definition lists associate a term with a definition.
  132. *how*
  133. The term is a one-line phrase, and the definition is one or more
  134. paragraphs or body elements, indented relative to the term.
  135. Blank lines are not allowed between term and definition.
  136. Results in:
  137. what
  138. Definition lists associate a term with a definition.
  139. *how*
  140. The term is a one-line phrase, and the definition is one or more
  141. paragraphs or body elements, indented relative to the term.
  142. Blank lines are not allowed between term and definition.
  143. Preformatting (code samples)
  144. ----------------------------
  145. (quickref__)
  146. __ ../quickref/#literal-blocks
  147. To just include a chunk of preformatted, never-to-be-fiddled-with
  148. text, finish the prior paragraph with "``::``". The preformatted
  149. block is finished when the text falls back to the same indentation
  150. level as a paragraph prior to the preformatted block. For example::
  151. An example::
  152. Whitespace, newlines, blank lines, and all kinds of markup
  153. (like *this* or \this) is preserved by literal blocks.
  154. Lookie here, I've dropped an indentation level
  155. (but not far enough)
  156. no more example
  157. Results in:
  158. An example::
  159. Whitespace, newlines, blank lines, and all kinds of markup
  160. (like *this* or \this) is preserved by literal blocks.
  161. Lookie here, I've dropped an indentation level
  162. (but not far enough)
  163. no more example
  164. Note that if a paragraph consists only of "``::``", then it's removed
  165. from the output::
  166. ::
  167. This is preformatted text, and the
  168. last "::" paragraph is removed
  169. Results in:
  170. ::
  171. This is preformatted text, and the
  172. last "::" paragraph is removed
  173. Sections
  174. --------
  175. (quickref__)
  176. __ ../quickref/#section-structure
  177. To break longer text up into sections, you use **section headers**.
  178. These are a single line of text (one or more words) with adornment: an
  179. underline alone, or an underline and an overline together, in dashes
  180. "``-----``", equals "``======``", tildes "``~~~~~~``" or any of the
  181. non-alphanumeric characters ``= - ` : ' " ~ ^ _ * + # < >`` that you
  182. feel comfortable with. An underline-only adornment is distinct from
  183. an overline-and-underline adornment using the same character. The
  184. underline/overline must be at least as long as the title text. Be
  185. consistent, since all sections marked with the same adornment style
  186. are deemed to be at the same level::
  187. Chapter 1 Title
  188. ===============
  189. Section 1.1 Title
  190. -----------------
  191. Subsection 1.1.1 Title
  192. ~~~~~~~~~~~~~~~~~~~~~~
  193. Section 1.2 Title
  194. -----------------
  195. Chapter 2 Title
  196. ===============
  197. This results in the following structure, illustrated by simplified
  198. pseudo-XML::
  199. <section>
  200. <title>
  201. Chapter 1 Title
  202. <section>
  203. <title>
  204. Section 1.1 Title
  205. <section>
  206. <title>
  207. Subsection 1.1.1 Title
  208. <section>
  209. <title>
  210. Section 1.2 Title
  211. <section>
  212. <title>
  213. Chapter 2 Title
  214. (Pseudo-XML uses indentation for nesting and has no end-tags. It's
  215. not possible to show actual processed output, as in the other
  216. examples, because sections cannot exist inside block quotes. For a
  217. concrete example, compare the section structure of this document's
  218. source text and processed output.)
  219. Note that section headers are available as link targets, just using
  220. their name. To link to the Lists_ heading, I write "``Lists_``". If
  221. the heading has a space in it like `text styles`_, we need to quote
  222. the heading "```text styles`_``".
  223. Document Title / Subtitle
  224. `````````````````````````
  225. The title of the whole document is distinct from section titles and
  226. may be formatted somewhat differently (e.g. the HTML writer by default
  227. shows it as a centered heading).
  228. To indicate the document title in reStructuredText, use a unique adornment
  229. style at the beginning of the document. To indicate the document subtitle,
  230. use another unique adornment style immediately after the document title. For
  231. example::
  232. ================
  233. Document Title
  234. ================
  235. ----------
  236. Subtitle
  237. ----------
  238. Section Title
  239. =============
  240. ...
  241. Note that "Document Title" and "Section Title" above both use equals
  242. signs, but are distinct and unrelated styles. The text of
  243. overline-and-underlined titles (but not underlined-only) may be inset
  244. for aesthetics.
  245. Images
  246. ------
  247. (quickref__)
  248. __ ../quickref/#directives
  249. To include an image in your document, you use the ``image`` directive__.
  250. For example::
  251. .. image:: /images/nikola.png
  252. results in:
  253. .. image:: /images/nikola.png
  254. The ``/images/nikola.png`` part indicates the filename of the image
  255. you wish to appear in the document. There's no restriction placed on
  256. the image (format, size etc). If the image is to appear in HTML and
  257. you wish to supply additional information, you may::
  258. .. image:: /images/nikola.png
  259. :height: 100
  260. :width: 200
  261. :scale: 50
  262. :alt: alternate text
  263. See the full `image directive documentation`__ for more info.
  264. __ https://docutils.sourceforge.io/docs/ref/rst/directives.html
  265. __ https://docutils.sourceforge.io/docs/ref/rst/directives.html#images
  266. What Next?
  267. ----------
  268. This primer introduces the most common features of reStructuredText,
  269. but there are a lot more to explore. The `Quick reStructuredText`_
  270. user reference is a good place to go next. For complete details, the
  271. `reStructuredText Markup Specification`_ is the place to go [#]_.
  272. Users who have questions or need assistance with Docutils or
  273. reStructuredText should post a message to the Docutils-users_ mailing
  274. list.
  275. .. [#] If that relative link doesn't work, try the master document:
  276. https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html.
  277. .. _reStructuredText Markup Specification:
  278. https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html
  279. .. _Docutils-users: https://docutils.sourceforge.io/docs/user/mailing-lists.html#docutils-users
  280. .. _Docutils project web site: https://docutils.sourceforge.io/