markdown-dita-syntax-reference.dita 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE topic PUBLIC "-//OASIS//DTD DITA Topic//EN" "topic.dtd">
  3. <!-- This file is part of the DITA Open Toolkit project. See the accompanying LICENSE file for applicable license. -->
  4. <topic id="markdown-dita-syntax-reference">
  5. <title>Markdown DITA syntax reference</title>
  6. <titlealts>
  7. <navtitle>Markdown DITA syntax</navtitle>
  8. </titlealts>
  9. <shortdesc>Markdown DITA uses
  10. <xref keyref="commonmark"/> as the underlying markup language.</shortdesc>
  11. <prolog>
  12. <metadata>
  13. <keywords>
  14. <indexterm>Pandoc</indexterm>
  15. <indexterm end="lwdita"/>
  16. <indexterm>UTF</indexterm>
  17. <indexterm>DITA<indexterm>specializations</indexterm></indexterm>
  18. <indexterm>Markdown</indexterm>
  19. <indexterm>CommonMark</indexterm>
  20. </keywords>
  21. </metadata>
  22. </prolog>
  23. <body>
  24. <p>Markdown DITA files must be UTF-8 encoded.</p>
  25. <section id="titles-and-document-structure">
  26. <title>Titles and document structure</title>
  27. <p>Each header level will generate a topic and associated title:</p>
  28. <codeblock outputclass="language-markdown" xml:space="preserve"># Topic title
  29. ## Nested topic title</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;topic id="topic_title"&gt;
  30. &lt;title&gt;Topic title&lt;/title&gt;
  31. &lt;topic id="nested_topic_title"&gt;
  32. &lt;title&gt;Nested topic title&lt;/title&gt;
  33. &lt;/topic&gt;
  34. &lt;/topic&gt;</codeblock>
  35. <p>Pandoc
  36. <xref format="html#extension-header_attributes" href="http://pandoc.org/MANUAL.html#extension-header_attributes"
  37. scope="external">header_attributes</xref> can be used to define <codeph>id</codeph> or
  38. <codeph>outputclass</codeph> attributes:</p><codeblock outputclass="language-markdown" xml:space="preserve"># Topic title {#carrot .juice}</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;topic id="carrot" outputclass="juice"&gt;
  39. &lt;title&gt;Topic title&lt;/title&gt;</codeblock>
  40. <p>If topic ID is not defined using header_attributes, the ID is generated from title contents.</p>
  41. <p>Pandoc
  42. <xref format="html#extension-pandoc_title_block"
  43. href="http://pandoc.org/MANUAL.html#extension-pandoc_title_block" scope="external">pandoc_title_block</xref>
  44. extension can be used to group multiple level 1 headers under a common
  45. title:</p><codeblock outputclass="language-markdown" xml:space="preserve">% Common title
  46. # Topic title
  47. # Second title</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;topic id="common_title"&gt;
  48. &lt;title&gt;Common title&lt;/title&gt;
  49. &lt;topic id="topic_title"&gt;
  50. &lt;title&gt;Topic title&lt;/title&gt;
  51. &lt;/topic&gt;
  52. &lt;topic id="second_title"&gt;
  53. &lt;title&gt;Second title&lt;/title&gt;
  54. &lt;/topic&gt;
  55. &lt;/topic&gt;</codeblock></section>
  56. <section id="topic-content">
  57. <title>Topic content</title>
  58. <p>In LwDITA compatible documents (MDITA) the first paragraph is treated as a <codeph>shortdesc</codeph> element.
  59. In generic Markdown documents all paragraphs appear inside the <codeph>body</codeph> element.</p></section>
  60. <section id="specialization-types">
  61. <title>Specialization types</title>
  62. <p>The following class values in
  63. <xref format="html#extension-header_attributes" href="http://pandoc.org/MANUAL.html#extension-header_attributes"
  64. scope="external">header_attributes</xref> have a special meaning on level 1 headers:</p>
  65. <ul>
  66. <li>
  67. <p><codeph>concept</codeph></p></li>
  68. <li>
  69. <p><codeph>task</codeph></p></li>
  70. <li>
  71. <p><codeph>reference</codeph></p></li>
  72. </ul>
  73. <p>They can be used to change the Markdown DITA topic type to one of the built-in structural specialization
  74. types.</p><codeblock outputclass="language-markdown" xml:space="preserve"># Task {.task}
  75. Context
  76. 1. Command
  77. Info.</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;task id="task"&gt;
  78. &lt;title&gt;Task &lt;/title&gt;
  79. &lt;taskbody&gt;
  80. &lt;context&gt;
  81. &lt;p&gt;Context&lt;/p&gt;
  82. &lt;/context&gt;
  83. &lt;steps&gt;
  84. &lt;step&gt;
  85. &lt;cmd&gt;Command&lt;/cmd&gt;
  86. &lt;info&gt;
  87. &lt;p&gt;Info.&lt;/p&gt;
  88. &lt;/info&gt;
  89. &lt;/step&gt;
  90. &lt;/steps&gt;
  91. &lt;/taskbody&gt;
  92. &lt;/task&gt;</codeblock></section>
  93. <section id="sections">
  94. <title>Sections</title>
  95. <p>The following class values in
  96. <xref format="html#extension-header_attributes" href="http://pandoc.org/MANUAL.html#extension-header_attributes"
  97. scope="external">header_attributes</xref> have a special meaning on header levels other than 1:</p>
  98. <ul>
  99. <li>
  100. <p><codeph>section</codeph></p></li>
  101. <li>
  102. <p><codeph>example</codeph></p></li>
  103. </ul>
  104. <p>They are used to generate
  105. <xref format="html" href="http://docs.oasis-open.org/dita/v1.2/os/spec/langref/section.html" scope="external"
  106. ><codeph>section</codeph></xref> and
  107. <xref format="html" href="http://docs.oasis-open.org/dita/v1.2/os/spec/langref/example.html" scope="external"
  108. ><codeph>example</codeph></xref>
  109. elements:</p><codeblock outputclass="language-markdown" xml:space="preserve"># Topic title
  110. ## Section title {.section}
  111. ## Example title {.example}</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;topic id="topic_title"&gt;
  112. &lt;title&gt;Topic title&lt;/title&gt;
  113. &lt;body&gt;
  114. &lt;section&gt;
  115. &lt;title&gt;Section title&lt;/title&gt;
  116. &lt;/section&gt;
  117. &lt;example&gt;
  118. &lt;title&gt;Example title&lt;/title&gt;
  119. &lt;/example&gt;
  120. &lt;/body&gt;
  121. &lt;/topic&gt;</codeblock></section>
  122. <section id="links">
  123. <title>Links</title>
  124. <p>The format of local link targets is detected based on file extension. The following extensions are treated as
  125. DITA files:</p>
  126. <table outputclass="table-hover" frame="none" colsep="0" rowsep="1">
  127. <tgroup cols="2">
  128. <colspec/>
  129. <colspec/>
  130. <thead>
  131. <row>
  132. <entry>extension</entry>
  133. <entry>format</entry>
  134. </row>
  135. </thead>
  136. <tbody>
  137. <row>
  138. <entry><codeph>.dita</codeph></entry>
  139. <entry><codeph>dita</codeph></entry>
  140. </row>
  141. <row>
  142. <entry><codeph>.xml</codeph></entry>
  143. <entry><codeph>dita</codeph></entry>
  144. </row>
  145. <row>
  146. <entry><codeph>.md</codeph></entry>
  147. <entry><codeph>markdown</codeph></entry>
  148. </row>
  149. <row>
  150. <entry><codeph>.markdown</codeph></entry>
  151. <entry><codeph>markdown</codeph></entry>
  152. </row>
  153. </tbody>
  154. </tgroup>
  155. </table>
  156. <p>All other link targets use <codeph>format</codeph> from file extension and are treated as non-DITA files.
  157. Absolute links targets are treated as external scope
  158. links:</p><codeblock outputclass="language-markdown" xml:space="preserve">[Markdown](test.md)
  159. [DITA](test.dita)
  160. [HTML](test.html)
  161. [External](http://www.example.com/test.html)</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;xref href="test.md"&gt;Markdown&lt;/xref&gt;
  162. &lt;xref href="test.dita"&gt;DITA&lt;/xref&gt;
  163. &lt;xref href="test.html" format="html"&gt;HTML&lt;/xref&gt;
  164. &lt;xref href="http://www.example.com/test.html" format="html" scope="external"&gt;External&lt;/xref&gt;</codeblock></section>
  165. <section id="images">
  166. <title>Images</title>
  167. <div outputclass="div-index">
  168. <indexterm>images<indexterm>Markdown</indexterm></indexterm>
  169. </div>
  170. <p>Images used in inline content will result in inline placement. If a block level image contains a title, it will
  171. be treated as an image wrapped in
  172. figure:</p><codeblock outputclass="language-markdown" xml:space="preserve">An inline ![Alt](test.jpg).
  173. ![Alt](test.jpg)
  174. ![Alt](test.jpg "Title")</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;p&gt;An inline &lt;image href="test.jpg"&gt;&lt;alt&gt;Alt&lt;/alt&gt;&lt;/image&gt;.&lt;/p&gt;
  175. &lt;image href="test.jpg" placement="break"&gt;
  176. &lt;alt&gt;Alt&lt;/alt&gt;
  177. &lt;/image&gt;
  178. &lt;fig&gt;
  179. &lt;title&gt;Title&lt;/title&gt;
  180. &lt;image href="test.jpg"&gt;
  181. &lt;alt&gt;Alt&lt;/alt&gt;
  182. &lt;/image&gt;
  183. &lt;/fig&gt;</codeblock></section>
  184. <section id="key-references">
  185. <title>Key references</title>
  186. <p>Key reference can be used with
  187. <xref format="html" href="http://spec.commonmark.org/0.18/#shortcut-reference-link" scope="external">shortcut
  188. reference
  189. links</xref>:</p><codeblock outputclass="language-markdown" xml:space="preserve">[key]
  190. ![image-key]</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;xref keyref="key"/&gt;
  191. &lt;image keyref="image-key"/&gt;</codeblock></section>
  192. <section id="inline">
  193. <title>Inline</title>
  194. <p>The following inline elements are
  195. supported:</p><codeblock outputclass="language-markdown" xml:space="preserve">**bold**
  196. *italic*
  197. `code`
  198. ~~strikethrough~~</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;b&gt;bold&lt;/b&gt;
  199. &lt;i&gt;italic&lt;/i&gt;
  200. &lt;codeph&gt;code&lt;/codeph&gt;
  201. &lt;ph status="deleted"&gt;strikethrough&lt;/ph&gt;</codeblock></section>
  202. <section id="lists">
  203. <title>Lists</title>
  204. <p>Unordered can be marked up with either hyphen or ampersand:</p><codeblock outputclass="language-markdown" xml:space="preserve">* one
  205. * two
  206. - three
  207. - four</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;ul&gt;
  208. &lt;li&gt;one&lt;/li&gt;
  209. &lt;li&gt;two
  210. &lt;ul&gt;
  211. &lt;li&gt;three&lt;/li&gt;
  212. &lt;li&gt;four&lt;/li&gt;
  213. &lt;/ul&gt;
  214. &lt;/li&gt;
  215. &lt;/ul&gt;</codeblock>
  216. <p>Ordered can be marked up with either number or number sign, followed by a period:</p><codeblock outputclass="language-markdown" xml:space="preserve">1. one
  217. 2. two
  218. #. three
  219. #. four</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;ol&gt;
  220. &lt;li&gt;one&lt;/li&gt;
  221. &lt;li&gt;two
  222. &lt;ol&gt;
  223. &lt;li&gt;three&lt;/li&gt;
  224. &lt;li&gt;four&lt;/li&gt;
  225. &lt;/ul&gt;
  226. &lt;/li&gt;
  227. &lt;/ul&gt;</codeblock>
  228. <p>Definition lists use the
  229. <xref format="html" href="http://michelf.com/projects/php-markdown/extra/#def-list" scope="external">PHP
  230. Markdown Extra</xref> format:</p><codeblock outputclass="language-markdown" xml:space="preserve">Term
  231. : Definition.</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;dl&gt;
  232. &lt;delentry&gt;
  233. &lt;dt&gt;Term&lt;/dt&gt;
  234. &lt;dd&gt;Defintion.&lt;/dd&gt;
  235. &lt;/delentry&gt;
  236. &lt;/dl&gt;</codeblock>
  237. <p>Each definition entry must have only one term and contain only inline content.</p></section>
  238. <section id="tables">
  239. <title>Tables</title>
  240. <div outputclass="div-index">
  241. <indexterm>tables<indexterm>Markdown</indexterm></indexterm>
  242. </div>
  243. <p>Tables use
  244. <xref format="html" href="http://fletcherpenney.net/multimarkdown/" scope="external">MultiMarkdown</xref> table
  245. extension format:</p><codeblock outputclass="language-markdown" xml:space="preserve">| First Header | Second Header | Third Header |
  246. | ------------ | :-----------: | -----------: |
  247. | Content | *Long Cell* ||
  248. | Content | **Cell** | Cell |</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;table&gt;
  249. &lt;tgroup cols="3"&gt;
  250. &lt;colspec colname="col1"/&gt;
  251. &lt;colspec colname="col2" align="center"/&gt;
  252. &lt;colspec colname="col3" align="right"/&gt;
  253. &lt;thead&gt;
  254. &lt;row&gt;
  255. &lt;entry&gt;First Header &lt;/entry&gt;
  256. &lt;entry&gt;Second Header &lt;/entry&gt;
  257. &lt;entry&gt;Third Header &lt;/entry&gt;
  258. &lt;/row&gt;
  259. &lt;/thead&gt;
  260. &lt;tbody&gt;
  261. &lt;row&gt;
  262. &lt;entry&gt;Content &lt;/entry&gt;
  263. &lt;entry namest="col2" nameend="col3"&gt;&lt;i&gt;Long Cell&lt;/i&gt;&lt;/entry&gt;
  264. &lt;/row&gt;
  265. &lt;row&gt;
  266. &lt;entry&gt;Content &lt;/entry&gt;
  267. &lt;entry&gt;&lt;b&gt;Cell&lt;/b&gt;&lt;/entry&gt;
  268. &lt;entry&gt;Cell &lt;/entry&gt;
  269. &lt;/row&gt;
  270. &lt;/tbody&gt;
  271. &lt;/tgroup&gt;
  272. &lt;/table&gt;</codeblock>
  273. <p>Table cells may only contain inline content and column spans; block content and row spans are not supported by
  274. Markdown DITA.</p></section>
  275. <section id="metadata">
  276. <title>Metadata</title>
  277. <div outputclass="div-index">
  278. <indexterm>metadata<indexterm>Lightweight DITA</indexterm></indexterm>
  279. <indexterm>metadata<indexterm>Markdown</indexterm></indexterm>
  280. <indexterm>Pandoc</indexterm>
  281. </div>
  282. <p>
  283. <xref format="html" href="http://www.yaml.org/" scope="external">YAML</xref> metadata block as defined in Pandoc
  284. <xref format="html#extension-yaml_metadata_block"
  285. href="http://pandoc.org/MANUAL.html#extension-yaml_metadata_block" scope="external"
  286. >pandoc_metadata_block</xref> can be used to specify different metadata elements. The supported elements
  287. are:</p>
  288. <ul>
  289. <li>
  290. <p><codeph>author</codeph></p></li>
  291. <li>
  292. <p><codeph>source</codeph></p></li>
  293. <li>
  294. <p><codeph>publisher</codeph></p></li>
  295. <li>
  296. <p><codeph>permissions</codeph></p></li>
  297. <li>
  298. <p><codeph>audience</codeph></p></li>
  299. <li>
  300. <p><codeph>category</codeph></p></li>
  301. <li>
  302. <p><codeph>keyword</codeph></p></li>
  303. <li>
  304. <p><codeph>resourceid</codeph></p></li>
  305. </ul>
  306. <p>Unrecognized keys are output using <codeph>data</codeph>
  307. element.</p><codeblock outputclass="language-markdown" xml:space="preserve">---
  308. author:
  309. - Author One
  310. - Author Two
  311. source: Source
  312. publisher: Publisher
  313. permissions: Permissions
  314. audience: Audience
  315. category: Category
  316. keyword:
  317. - Keyword1
  318. - Keyword2
  319. resourceid:
  320. - Resourceid1
  321. - Resourceid2
  322. workflow: review
  323. ---
  324. # Sample with YAML header</codeblock><codeblock outputclass="language-xml" xml:space="preserve">&lt;title&gt;Sample with YAML header&lt;/title&gt;
  325. &lt;prolog&gt;
  326. &lt;author&gt;Author One&lt;/author&gt;
  327. &lt;author&gt;Author Two&lt;/author&gt;
  328. &lt;source&gt;Source&lt;/source&gt;
  329. &lt;publisher&gt;Publisher&lt;/publisher&gt;
  330. &lt;permissions view="Permissions"/&gt;
  331. &lt;metadata&gt;
  332. &lt;audience audience="Audience"/&gt;
  333. &lt;category&gt;Category&lt;/category&gt;
  334. &lt;keywords&gt;
  335. &lt;keyword&gt;Keyword1&lt;/keyword&gt;
  336. &lt;keyword&gt;Keyword2&lt;/keyword&gt;
  337. &lt;/keywords&gt;
  338. &lt;/metadata&gt;
  339. &lt;resourceid appid="Resourceid1"/&gt;
  340. &lt;resourceid appid="Resourceid2"/&gt;
  341. &lt;data name="workflow" value="review"/&gt;
  342. &lt;/prolog&gt;</codeblock></section>
  343. </body>
  344. </topic>