markdown-dita-syntax-reference.dita 14 KB

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