Text::Markdown::Discount
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

543 lines
12 KiB

  1. .TH MARKDOWN 6
  2. .SH NAME
  3. Markdown \- text formatting syntax
  4. .SH DESCRIPTION
  5. Markdown
  6. is a text markup syntax for machine conversion to
  7. the more complex
  8. .SM HTML
  9. or
  10. .SM XHTML
  11. markup languages.
  12. It is intended to be easy to read and to write, with
  13. emphasis on readability.
  14. A Markdown-formatted document should be publishable as-is,
  15. in plain text, without the formatting distracting the reader.
  16. .PP
  17. The biggest source of inspiration for Markdown's
  18. syntax is the format of plain text email. The markup is comprised entirely
  19. of punctuation characters, chosen so as to look like what they mean.
  20. Asterisks around a word look like
  21. .IR *emphasis* .
  22. Markdown lists look like lists. Even
  23. blockquotes look like quoted passages of text, assuming the reader has
  24. used email.
  25. .PP
  26. .SS Block Elements
  27. .TF W
  28. .PD
  29. .TP
  30. Paragraphs and Line Breaks
  31. A paragraph is one or more consecutive lines of text, separated
  32. by one or more blank lines. (A blank line is any line that looks like a
  33. blank line -- a line containing nothing but spaces or tabs is considered
  34. blank.) Normal paragraphs should not be indented with spaces or tabs.
  35. .IP
  36. Lines may be freely broken for readability; Markdown
  37. does not translate source line breaks to
  38. .B <br />
  39. tags. To request generation of
  40. .B <br />
  41. in the output, end a line with two or more spaces, then a newline.
  42. .TP
  43. Headings
  44. Headings can be marked in two ways, called
  45. .I setext
  46. and
  47. .IR atx .
  48. .IP
  49. Setext-style headings are
  50. ``underlined'' using equal signs (for first-level
  51. headings) and dashes (for second-level headings).
  52. .IP
  53. Atx-style headings use 1-6 hash characters at the start of the line,
  54. corresponding to
  55. .SM HTML
  56. .BR <h^(1-6)^> .
  57. Optional closing hashes may follow
  58. the heading text.
  59. .TP
  60. Blockquotes
  61. Lines beginning with
  62. .B >
  63. are output in blockquotes.
  64. Blockquotes can be nested
  65. by multiple levels of
  66. .BR >> .
  67. Blockquotes can contain other Markdown elements, including
  68. headings, lists, and code blocks.
  69. .TP
  70. Lists
  71. Markdown supports ordered (numbered) and unordered (bulleted) lists.
  72. List markers typically start at the left margin, but may be indented by
  73. up to three spaces.
  74. List markers must be followed by one or more spaces
  75. or a tab, then the list item text.
  76. A newline terminates each list item.
  77. .IP
  78. Unordered lists use asterisks, pluses, and hyphens interchangeably as
  79. list markers.
  80. .IP
  81. Ordered lists use integers followed by periods as list markers.
  82. The order of the integers is not interpreted,
  83. but the list should begin with
  84. .BR 1 .
  85. .IP
  86. If list items are separated by blank lines, Markdown will wrap each list
  87. item in
  88. .B <p>
  89. tags in the
  90. .SM HTML
  91. output.
  92. .IP
  93. List items may consist of multiple paragraphs.
  94. Each subsequent
  95. paragraph within a list item must be indented by either 4 spaces
  96. or one tab.
  97. To put a blockquote within a list item, the blockquote's
  98. .B >
  99. marker needs to be indented.
  100. To put a code block within a list item, the code block needs
  101. to be indented
  102. .I twice
  103. -- 8 spaces or two tabs.
  104. .TP
  105. Code Blocks
  106. To produce a code block, indent every line of the
  107. block by at least 4 spaces or 1 tab.
  108. A code block continues until it reaches a line that is not indented.
  109. .IP
  110. Rather than forming normal paragraphs, the lines
  111. of a code block are interpreted literally.
  112. Regular Markdown syntax is not processed within code blocks.
  113. Markdown wraps a code block in both
  114. .B <pre>
  115. and
  116. .B <code>
  117. tags.
  118. One level of indentation -- 4
  119. spaces or 1 tab -- is removed from each line of the code block in
  120. the output.
  121. .TP
  122. Horizontal Rules
  123. Produce a horizontal rule tag
  124. .RB ( <hr\ /> )
  125. by placing three or
  126. more hyphens, asterisks, or underscores on a line by themselves.
  127. .SS Span Elements
  128. .TF W
  129. .PD
  130. .TP
  131. Links
  132. Markdown supports two styles of links:
  133. .I inline
  134. and
  135. .IR reference .
  136. In both styles, the link text is delimited by square brackets
  137. .RB ( [] ).
  138. To create an inline link, use a set of regular parentheses immediately
  139. after the link text's closing square bracket.
  140. Inside the parentheses,
  141. put the link URL, along with an optional
  142. title for the link surrounded in double quotes.
  143. For example:
  144. .IP
  145. .EX
  146. An [example](http://example.com/ "Title") inline link.
  147. .EE
  148. .IP
  149. Reference-style links use a second set of square brackets, inside
  150. which you place a label of your choosing to identify the link:
  151. .IP
  152. .EX
  153. An [example][id] reference-style link.
  154. .EE
  155. .IP
  156. The label is then assigned a value on its own line, anywhere in the document:
  157. .IP
  158. .EX
  159. [id]: http://example.com/ "Optional Title"
  160. .EE
  161. .IP
  162. Link label names may consist of letters, numbers, spaces, and
  163. punctuation.
  164. Labels are not case sensitive.
  165. An empty label bracket
  166. set after a reference-style link implies the link label is equivalent to
  167. the link text.
  168. A URL value can then be assigned to the link by referencing
  169. the link text as the label name.
  170. .TP
  171. Emphasis
  172. Markdown treats asterisks
  173. .RB ( * )
  174. and underscores
  175. .RB ( _ )
  176. as indicators of emphasis.
  177. Text surrounded with single asterisks or underscores
  178. will be wrapped with an
  179. .SM HTML
  180. .B <em>
  181. tag.
  182. Double asterisks or underscores generate an
  183. .SM HTML
  184. .B <strong>
  185. tag.
  186. .TP
  187. Code
  188. To indicate a span of code, wrap it with backtick quotes
  189. .RB ( ` ).
  190. Unlike a code block, a code span indicates code within a
  191. normal paragraph.
  192. To include a literal backtick character within a code span, you can use
  193. multiple backticks as the opening and closing delimiters:
  194. .IP
  195. .EX
  196. ``There is a literal backtick (`) here.``
  197. .EE
  198. .TP
  199. Images
  200. Markdown image syntax is intended to resemble that
  201. for links, allowing for two styles, once again
  202. .I inline
  203. and
  204. .IR reference .
  205. The syntax is as for each respective style of link, described above, but
  206. prefixed with an exclamation mark character
  207. .RB ( ! ).
  208. Inline image syntax looks like this:
  209. .IP
  210. .EX
  211. ![Alt text](/path/to/img.jpg "Optional title")
  212. .EE
  213. .IP
  214. That is:
  215. An exclamation mark;
  216. followed by a set of square brackets containing the `alt'
  217. attribute text for the image;
  218. followed by a set of parentheses containing the URL or path to
  219. the image, and an optional `title' attribute enclosed in double
  220. or single quotes.
  221. .IP
  222. Reference-style image syntax looks like this:
  223. .IP
  224. .EX
  225. ![Alt text][id]
  226. .EE
  227. .IP
  228. Where
  229. .I id
  230. is a label used as for reference-style URL links, described above.
  231. .SS Convenience
  232. .TF W
  233. .PD
  234. .TP
  235. Automatic Links
  236. There is a shortcut style for creating ``automatic''
  237. links for URLs and email addresses.
  238. Surround the URL
  239. or address with angle brackets.
  240. .TP
  241. Backslash Escapes
  242. Use backslash escapes to generate literal
  243. characters which would otherwise have special meaning in Markdown's
  244. formatting syntax.
  245. .TP
  246. Inline HTML
  247. For markup that is not covered by Markdown's
  248. syntax, simply use the
  249. .SM HTML
  250. directly.
  251. The only restrictions are that block-level
  252. .SM HTML
  253. elements --
  254. .BR <div> ,
  255. .BR <table> ,
  256. .BR <pre> ,
  257. .BR <p> ,
  258. etc. -- must be separated from surrounding
  259. content by blank lines, and the start and end tags of the block should
  260. not be indented with tabs or spaces. Markdown formatting syntax is
  261. not processed within block-level
  262. .SM HTML
  263. tags.
  264. .IP
  265. Span-level
  266. .SM HTML
  267. tags -- e.g.
  268. .BR <span> ,
  269. .BR <cite> ,
  270. or
  271. .B <del>
  272. -- can be
  273. used anywhere in a Markdown
  274. paragraph, list item, or heading.
  275. It is permitted to use
  276. .SM HTML
  277. tags instead of Markdown formatting; e.g.
  278. .SM HTML
  279. .B <a>
  280. or
  281. .B <img>
  282. tags instead of Markdown's
  283. link or image syntax.
  284. Unlike block-level
  285. .SM HTML
  286. tags, Markdown
  287. syntax
  288. .I is
  289. processed within the elements of span-level tags.
  290. .TP
  291. Automatic Special Character Escapes
  292. To be displayed literally in a user agent, the characters
  293. .B <
  294. and
  295. .B &
  296. must appear as escaped entities in
  297. .SM HTML
  298. source, e.g.
  299. .B &lt;
  300. and
  301. .BR &amp; .
  302. Markdown
  303. allows natural use of these characters, taking care of
  304. the necessary escaping.
  305. The ampersand part of a directly-used
  306. .SM HTML
  307. entity remains unchanged; otherwise it will be translated
  308. into
  309. .BR &amp; .
  310. Inside code spans and blocks, angle brackets and
  311. ampersands are always encoded automatically.
  312. This makes it easy to use Markdown to write about
  313. .SM HTML
  314. code.
  315. .PP
  316. .SS Smarty Pants
  317. The
  318. .IR markdown (1)
  319. utility transforms a few plain text symbols into their typographically-fancier
  320. .SM HTML
  321. entity equivalents.
  322. These are extensions to the standard Markdown syntax.
  323. .TF W
  324. .PD
  325. .TP
  326. Punctuation
  327. Input single- and double-quotes are transformed
  328. into ``curly'' quote entities in the output (e.g.,
  329. .B 'text'
  330. becomes
  331. .BR &lsquo;text&rsquo; ).
  332. Input double-dashes
  333. .RB ( -- )
  334. and triple-dashes become en- and em-dashes, respectively,
  335. while a series of three dots
  336. .RB ( ... )
  337. in the input becomes an ellipsis entity
  338. .RB ( &hellip; )
  339. in the
  340. .SM HTML
  341. output.
  342. .TP
  343. Symbols
  344. Three other transformations replace the common plain-text shorthands
  345. .BR (c) ,
  346. .BR (r) ,
  347. and
  348. .BR (tm)
  349. from the input with their respective
  350. .SM HTML
  351. entities. (As in
  352. .B (c)
  353. becoming
  354. .BR &copy; ,
  355. the Copyright symbol entity.)
  356. .TP
  357. Fractions
  358. A small set of plain-text shorthands for fractions is recognized.
  359. .B 1/4
  360. becomes
  361. .BR &frac14; ,
  362. for example. These fraction notations are replaced with their
  363. .SM HTML
  364. entity equivalents:
  365. .BR 1/4 ,
  366. .BR 1/2 ,
  367. .BR 3/4 .
  368. .B 1/4th
  369. and
  370. .B 3/4ths
  371. are replaced with their entity and the indicated ordinal suffix letters.
  372. .PP
  373. Like the basic Markdown syntax, none of the ``Smarty Pants'' extensions are processed
  374. inside code blocks or spans.
  375. .PP
  376. .SS Discount Extensions
  377. .IR Markdown (1)
  378. recognizes some extensions to the Markdown format,
  379. many of them adopted or adapted from other Markdown
  380. interpreters or document formatting systems.
  381. .TF W
  382. .PD
  383. .TP
  384. Pandoc Headers
  385. If
  386. .I markdown
  387. was configured with
  388. .BR --enable-pandoc-header ,
  389. the markdown source can have a 3-line Pandoc header in the format of
  390. .IP
  391. .EX
  392. % Title
  393. % Author
  394. % Date
  395. .EE
  396. .IP
  397. whose data is available to the
  398. .IR mkd_doc_title ,
  399. .IR mkd_doc_author ,
  400. and
  401. .I mkd_doc_date
  402. (in
  403. .IR markdown (2))
  404. functions.
  405. .TP
  406. Embedded Stylesheets
  407. Stylesheets may be defined and modified in a
  408. .B <style>
  409. block. A style block is parsed like any other block-level
  410. .SM HTML;
  411. .B <style>
  412. starting on column 1, raw
  413. .SM HTML
  414. (or, in this case,
  415. .SM CSS \)
  416. following it, and either ending with a
  417. .B </style>
  418. at the end of the line or at the beginning of a subsequent line.
  419. .IP
  420. Style blocks apply to the entire document regardless of where they are defined.
  421. .TP
  422. Image Dimensions
  423. Image specification has been extended with an argument describing image dimensions:
  424. .BI = height x width.
  425. For an image 400 pixels high and 300 wide, the new syntax is:
  426. .IP
  427. .EX
  428. ![Alt text](/path/to/image.jpg =400x300 "Title")
  429. .EE
  430. .TP
  431. Pseudo-Protocols
  432. Pseudo-protocols that may replace the common
  433. .B http:
  434. or
  435. .B mailto:
  436. have been added to the link syntax described above.
  437. .IP
  438. .BR abbr :
  439. Text following is used as the
  440. .B title
  441. attribute of an
  442. .B abbr
  443. tag wrapping the link text. So
  444. .B [LT](abbr:Link Text)
  445. gives
  446. .B <abbr title="Link Text">LT</abbr>.
  447. .IP
  448. .BR id :
  449. The link text is marked up and written to the output, wrapped with
  450. .B <a id=text following>
  451. and
  452. .BR </a> .
  453. .IP
  454. .BR class :
  455. The link text is marked up and written to the output, wrapped with
  456. .B <span class=text following>
  457. and
  458. .BR </span> .
  459. .IP
  460. .BR raw :
  461. Text following is written to the output with no further processing.
  462. The link text is discarded.
  463. .TP
  464. Alphabetic Lists
  465. If
  466. .I markdown
  467. was configured with
  468. .BR --enable-alpha-list ,
  469. .IP
  470. .EX
  471. a. this
  472. b. is
  473. c. an alphabetic
  474. d. list
  475. .EE
  476. .IP
  477. yields an
  478. .SM HTML
  479. .B ol
  480. ordered list.
  481. .TP
  482. Definition Lists
  483. If configured with
  484. .BR --enable-dl-tag ,
  485. markup for definition lists is enabled. A definition list item is defined as
  486. .IP
  487. .EX
  488. =term=
  489. definition
  490. .EE
  491. .TP
  492. Tables
  493. Tables are specified with a pipe
  494. .RB ( | )
  495. and dash
  496. .RB ( - )
  497. marking. The markdown text
  498. .IP
  499. .EX
  500. header0|header1
  501. -------|-------
  502. textA|textB
  503. textC|textD
  504. .EE
  505. .IP
  506. will produce an
  507. .SM HTML
  508. .B table
  509. of two columns and three rows.
  510. A header row is designated by ``underlining'' with dashes.
  511. Declare a column's alignment by affixing a colon
  512. .RB ( : )
  513. to the left or right end of the dashes underlining its header.
  514. In the output, this
  515. yields the corresponding value for the
  516. .B align
  517. attribute on each
  518. .B td
  519. cell in the column.
  520. A colon at both ends of a column's header dashes indicates center alignment.
  521. .TP
  522. Relaxed Emphasis
  523. If configured with
  524. .BR --relaxed-emphasis ,
  525. the rules for emphasis are changed so that a single
  526. .B _
  527. will not count as an emphasis character in the middle of a word.
  528. This is useful for documenting some code where
  529. .B _
  530. appears frequently, and would normally require a backslash escape.
  531. .PD
  532. .SH SEE ALSO
  533. .IR markdown (1),
  534. .IR markdown (2)
  535. .PP
  536. http://daringfireball.net/projects/markdown/syntax/,
  537. ``Markdown: Syntax''.
  538. .PP
  539. http://daringfireball.net/projects/smartypants/,
  540. ``Smarty Pants''.
  541. .PP
  542. http://michelf.com/projects/php-markdown/extra/#table,
  543. ``PHP Markdown Extra: Tables''.