1 /******************************************************************************
5 * Copyright (C) 1997-2015 by Dimitri van Heesch.
7 * Permission to use, copy, modify, and distribute this software and its
8 * documentation under the terms of the GNU General Public License is hereby
9 * granted. No representations are made about the suitability of this software
10 * for any purpose. It is provided "as is" without express or implied warranty.
11 * See the GNU General Public License for more details.
13 * Documents produced by Doxygen are derivative works derived from the
14 * input used in their production; they are not affected by this license.
17 /*! \page markdown Markdown support
22 was introduced in doxygen version 1.8.0. It is a plain text formatting
23 syntax written by John Gruber, with the following underlying design goal:
25 > The design goal for Markdown's formatting syntax is to
26 > make it as readable as possible. The idea is that a Markdown-formatted
27 > document should be publishable as-is, as plain text, without
28 > looking like it's been marked up with tags or formatting instructions.
29 > While Markdown's syntax has been influenced by several existing
30 > text-to-HTML filters, the single biggest source of inspiration
31 > for Markdown's syntax is the format of plain text email.
33 In the \ref markdown_std "next section" the standard Markdown features
34 are briefly discussed. The reader is referred to the [Markdown site][markdown]
37 Some enhancements were made, for instance [PHP Markdown Extra][mdextra], and
38 [GitHub flavored Markdown][github]. The section \ref markdown_extra discusses
39 the extensions that doxygen supports.
41 Finally section \ref markdown_dox discusses some specifics for doxygen's
42 implementation of the Markdown standard.
44 [markdown]: http://daringfireball.net/projects/markdown/
45 [mdextra]: https://michelf.ca/projects/php-markdown/extra/
46 [github]: https://github.github.com/github-flavored-markdown/
48 \section markdown_std Standard Markdown
50 \subsection md_para Paragraphs
52 Even before doxygen had Markdown support it supported the same way
53 of paragraph handling as Markdown: to make a paragraph you just separate
54 consecutive lines of text by one or more blank lines.
58 Here is text for one paragraph.
60 We continue with more text in another paragraph.
62 \subsection md_headers Headers
64 Just like Markdown, doxygen supports two types of headers
66 Level 1 or 2 headers can be made as the follows
68 This is a level 1 header
69 ========================
71 This is a level 2 header
72 ------------------------
74 A header is followed by a line containing only ='s or -'s.
75 Note that the exact amount of ='s or -'s is not important as long as
76 there are at least two.
78 Alternatively, you can use #'s at the start of a line to make a header.
79 The number of #'s at the start of the line determines the level (up to 6 levels are supported).
80 You can end a header by any number of #'s.
84 # This is a level 1 header
86 ### This is level 3 header #######
88 \subsection md_blockquotes Block quotes
90 Block quotes can be created by starting each line with one or more >'s,
91 similar to what is used in text-only emails.
93 > This is a block quote
94 > spanning multiple lines
96 Lists and code blocks (see below) can appear inside a quote block.
97 Quote blocks can also be nested.
99 Note that doxygen requires that you put a space after the (last) > character
100 to avoid false positives, i.e. when writing
105 the second line will not be seen as a block quote.
107 \subsection md_lists Lists
109 Simple bullet lists can be made by starting a line with -, +, or *.
113 More text for this item.
117 + another nested item.
120 List items can span multiple paragraphs (if each paragraph starts with
121 the proper indentation) and lists can be nested.
122 You can also make a numbered list like so
127 Make sure to also read \ref mddox_lists for doxygen specifics.
129 \subsection md_codeblock Code Blocks
131 Preformatted verbatim blocks can be created by indenting
132 each line in a block of text by at least 4 extra spaces
134 This a normal paragraph
138 We continue with a normal paragraph again.
140 Doxygen will remove the mandatory indentation from the code block.
141 Note that you cannot start a code block in the middle of a paragraph
142 (i.e. the line preceding the code block must be empty).
144 See section \ref mddox_code_blocks for more info how doxygen handles
145 indentation as this is slightly different than standard Markdown.
147 \subsection md_rulers Horizontal Rulers
149 A horizontal ruler will be produced for lines containing at least three or more
150 hyphens, asterisks, or underscores. The line may also include any amount of whitespace.
157 Note that using asterisks in comment blocks does not work. See
158 \ref mddox_stars for details.
160 \subsection md_emphasis Emphasis
162 To emphasize a text fragment you start and end the fragment with an underscore or star.
163 Using two stars or underscores will produce strong emphasis.
169 * _single underscores_
171 * **double asterisks**
173 * __double underscores__
175 See section \ref mddox_emph_spans for more info how doxygen handles
176 emphasis spans slightly different than standard Markdown.
178 \subsection md_codespan code spans
180 To indicate a span of code, you should wrap it in backticks (`). Unlike code blocks,
181 code spans appear inline in a paragraph. An example:
183 Use the `printf()` function.
185 To show a literal backtick inside a code span use double backticks, i.e.
187 To assign the output of command `ls` to `var` use ``var=`ls```.
189 See section \ref mddox_code_spans for more info how doxygen handles
190 code spans slightly different than standard Markdown.
192 \subsection md_links Links
194 Doxygen supports both styles of make links defined by Markdown: *inline* and *reference*.
196 For both styles the link definition starts with the link text delimited by [square
199 \subsubsection md_inlinelinks Inline Links
201 For an inline link the link text is followed by a URL and an optional link title which
202 together are enclosed in a set of regular parenthesis.
203 The link title itself is surrounded by quotes.
207 [The link text](http://example.net/)
208 [The link text](http://example.net/ "Link title")
209 [The link text](/relative/path/to/index.html "Link title")
210 [The link text](somefile.html)
212 In addition doxygen provides a similar way to link a documented entity:
214 [The link text](@ref MyClass)
216 \subsubsection md_reflinks Reference Links
218 Instead of putting the URL inline, you can also define the link separately
219 and then refer to it from within the text.
221 The link definition looks as follows:
223 [link name]: http://www.example.com "Optional title"
225 Instead of double quotes also single quotes or parenthesis can
226 be used for the title part.
228 Once defined, the link looks as follows
230 [link text][link name]
232 If the link text and name are the same, also
240 can be used to refer to the link.
241 Note that the link name matching is not case sensitive
242 as is shown in the following example:
244 I get 10 times more traffic from [Google] than from
247 [google]: http://google.com/ "Google"
248 [yahoo]: http://search.yahoo.com/ "Yahoo Search"
249 [msn]: http://search.msn.com/ "MSN Search"
251 Link definitions will not be visible in the output.
253 Like for inline links doxygen also supports \@ref inside a link definition:
255 [myclass]: @ref MyClass "My class"
257 \subsection md_images Images
259 Markdown syntax for images is similar to that for links.
260 The only difference is an additional ! before the link text.
264 ![Caption text](/path/to/img.jpg)
265 ![Caption text](/path/to/img.jpg "Image title")
266 ![Caption text][img def]
269 [img def]: /path/to/img.jpg "Optional Title"
271 Also here you can use \@ref to link to an image:
273 ![Caption text](@ref image.png)
276 [img def]: @ref image.png "Caption text"
278 The caption text is optional.
280 \subsection md_autolink Automatic Linking
282 To create a link to an URL or e-mail address Markdown supports the following
285 <http://www.example.com>
286 <https://www.example.com>
287 <ftp://www.example.com>
288 <mailto:address@example.com>
289 <address@example.com>
291 Note that doxygen will also produce the links without the angle brackets.
293 \section markdown_extra Markdown Extensions
295 \subsection md_toc Table of Contents
297 Doxygen supports a special link marker `[TOC]` which can be placed in a page
298 to produce a table of contents at the start of the page, listing all sections.
300 Note that using `[TOC]` is the same as using a
301 \ref cmdtableofcontents "\\tableofcontents" command.
303 \subsection md_tables Tables
305 Of the features defined by "Markdown Extra" is support for
306 <a href="https://michelf.ca/projects/php-markdown/extra/#table">simple tables</a>:
308 A table consists of a header line, a separator line, and at least one
309 row line. Table columns are separated by the pipe (|) character.
313 First Header | Second Header
314 ------------- | -------------
315 Content Cell | Content Cell
316 Content Cell | Content Cell
318 which will produce the following table:
320 First Header | Second Header
321 ------------- | -------------
322 Content Cell | Content Cell
323 Content Cell | Content Cell
325 Column alignment can be controlled via one or two colons
326 at the header separator line:
328 | Right | Center | Left |
329 | ----: | :----: | :---- |
331 | 1000 | 1000 | 1000 |
333 which will look as follows:
335 | Right | Center | Left |
336 | ----: | :----: | :---- |
338 | 1000 | 1000 | 1000 |
340 Additionally, column and row spans are supported. Using a caret ("^")
341 in a cell indicates that the cell above should span rows. Sequences
342 of carets may be used for any number of row spans. For example:
344 | Right | Center | Left |
345 | ----: | :----: | :---- |
349 which will look as follows:
351 | Right | Center | Left |
352 | ----: | :----: | :---- |
356 Column spans are supported by means of directly adjacent vertical bars
357 ("|"). Each additional vertical bar indicates an additional column to
358 be spanned. To put it another way, a single vertical bar indicates a
359 single column span, two vertical bars indicates a 2 columns span, and
362 | Right | Center | Left |
363 | ----: | :----: | :---- |
367 which will look as follows:
369 | Right | Center | Left |
370 | ----: | :----: | :---- |
374 For more complex tables in doxygen please have a look at: \ref tables
376 \subsection md_fenced Fenced Code Blocks
378 Another feature defined by "Markdown Extra" is support for
379 <a href="https://michelf.ca/projects/php-markdown/extra/#fenced-code-blocks">
380 fenced code blocks</a>:
382 A fenced code block does not require indentation, and is
383 defined by a pair of "fence lines". Such a line consists of 3 or
384 more tilde (~) characters on a line. The end of the block should have the
385 same number of tildes. Here is an example:
388 This is a paragraph introducing:
390 ~~~~~~~~~~~~~~~~~~~~~
391 a one-line code block
392 ~~~~~~~~~~~~~~~~~~~~~
394 By default the output is the same as for a normal code block.
396 For languages supported by doxygen you can also make the code block
397 appear with syntax highlighting. To do so you need to
398 indicate the typical file extension that corresponds to the
399 programming language after the opening fence. For highlighting according
400 to the Python language for instance, you would need to write the following:
415 and for C you would write:
418 int func(int a,int b) { return a*b; }
424 int func(int a,int b) { return a*b; }
427 The curly braces and dot are optional by the way.
429 Another way to denote fenced code blocks is to use 3 or more backticks (```):
432 also a fenced code block
435 \subsection md_header_id Header Id Attributes
437 Standard Markdown has no support for labeling headers, which
438 is a problem if you want to link to a section.
440 PHP Markdown Extra allows you to label a header by adding
441 the following to the header
446 ## Header 2 ## {#labelid2}
448 To link to a section in the same comment block you can use
450 [Link text](#labelid)
452 to link to a section in general, doxygen allows you to use \@ref
454 [Link text](@ref labelid)
456 Note this only works for the headers of level 1 to 4.
458 \section markdown_dox Doxygen specifics
460 Even though doxygen tries to following the Markdown standard as closely as
461 possible, there are couple of deviation and doxygen specifics additions.
463 \subsection md_page_header Including Markdown files as pages
465 Doxygen can process files with Markdown formatting.
466 For this to work the extension for such a file should
467 be `.md` or `.markdown` (see
468 \ref cfg_extension_mapping "EXTENSION_MAPPING" if your Markdown files have
469 a different extension, and use `md` as the name of the parser).
470 Each file is converted to a page (see the \ref cmdpage "page" command for
473 By default the name and title of the page are derived from the file name.
474 If the file starts with a level 1 header however, it is used as the title
475 of the page. If you specify a label for the
476 header (as shown in \ref md_header_id) doxygen will use that as the
479 If the label is called `index` or `mainpage` doxygen will put the
480 documentation on the front page (`index.html`).
482 Here is an example of a file `README.md` that will appear as the main page
483 when processed by doxygen:
485 My Main Page {#mainpage}
488 Documentation that will appear on the main page
490 If a page has a label you can link to it using \ref cmdref "\@ref" as
491 is shown above. To refer to a markdown page without
492 such label you can simple use the file name of the page, e.g.
494 See [the other page](other.md) for more info.
496 \subsection md_html_blocks Treatment of HTML blocks
498 Markdown is quite strict in the way it processes block-level HTML:
500 > block-level HTML elements — e.g.
501 > `<div>`, `<table>`, `<pre>`, `<p>`, etc. —
502 > must be separated from surrounding content by blank lines,
503 > and the start and end tags of the block should not be indented
504 > with tabs or spaces.
506 Doxygen does not have this requirement, and will also process
507 Markdown formatting inside such HTML blocks. The only exception is
508 `<pre>` blocks, which are passed untouched (handy for ASCII art).
510 Doxygen will not process Markdown formatting inside verbatim or code blocks,
511 and in other sections that need to be processed without changes
512 (for instance formulas or inline dot graphs).
514 \subsection mddox_code_blocks Code Block Indentation
516 Markdown allows both a single tab or 4 spaces to start a code block.
517 Since doxygen already replaces tabs by spaces before doing Markdown
518 processing, the effect will only be same if TAB_SIZE in the config file
519 has been set to 4. When it is set to a higher value spaces will be
520 present in the code block. A lower value will prevent a single tab to be
521 interpreted as the start of a code block.
523 With Markdown any block that is indented by 4 spaces (and 8 spaces
524 inside lists) is treated as a code block. This indentation amount
525 is absolute, i.e. counting from the start of the line.
527 Since doxygen comments can appear at any indentation level
528 that is required by the programming language, it
529 uses a relative indentation instead. The amount of
530 indentation is counted relative to the preceding paragraph.
531 In case there is no preceding paragraph (i.e. you want to start with a
532 code block), the minimal amount of indentation of the whole comment block
533 is used as a reference.
535 In most cases this difference does not result in different output.
536 Only if you play with the indentation of paragraphs the difference
547 In this case Markdown will put the word code in a code block,
548 whereas doxygen will treat it as normal text, since although the absolute
549 indentation is 4, the indentation with respect to the previous paragraph
552 Note that list markers are not counted when determining the
563 For Item1 the indentation is 4 (when treating the list marker as whitespace),
564 so the next paragraph "More text..." starts at the same indentation level
565 and is therefore not seen as a code block.
567 \subsection mddox_emph_spans Emphasis limits
569 Unlike standard Markdown, doxygen will not touch internal underscores or
570 stars, so the following will appear as-is:
574 Furthermore, a `*` or `_` only starts an emphasis if
575 - it is followed by an alphanumerical character, and
576 - it is preceded by a space, newline, or one the following characters `<{([,:;`
579 - it is not followed by an alphanumerical character, and
580 - it is not preceded by a space, newline, or one the following characters `({[<=+-\@`
582 Lastly, the span of the emphasis is limited to a single paragraph.
585 \subsection mddox_code_spans Code Spans Limits
587 Note that unlike standard Markdown, doxygen leaves the following untouched.
589 A `cool' word in a `nice' sentence.
591 In other words; a single quote cancels the special treatment of a code span
592 wrapped in a pair of backtick characters. This extra restriction was
593 added for backward compatibility reasons.
595 \subsection mddox_lists Lists Extensions
597 With Markdown two lists separated by an empty line are joined together into
598 a single list which can be rather unexpected and many people consider it to
599 be a bug. Doxygen, however, will make two separate lists as you would expect.
609 With Markdown the actual numbers you use to mark the list have no
610 effect on the HTML output Markdown produces. I.e. standard Markdown treats the
611 following as one list with 3 numbered items:
617 Doxygen however requires that the numbers used as marks are in
618 strictly ascending order, so the above example would produce 3 lists
619 with one item. An item with an equal or lower number than
620 the preceding item, will start a new list. For example:
634 Historically doxygen has an additional way to create numbered
635 lists by using `-#` markers:
640 \subsection mddox_stars Use of asterisks
642 Special care has to be taken when using *'s in a comment block
643 to start a list or make a ruler.
645 Doxygen will strip off any leading *'s from the comment before doing
646 Markdown processing. So although the following works fine
655 When you remove the leading *'s doxygen will strip the other stars
656 as well, making the list disappear!
658 Rulers created with *'s will not be visible at all. They only work
661 \subsection mddox_limits Limits on markup scope
663 To avoid that a stray * or _ matches something many paragraphs later,
664 and shows everything in between with emphasis, doxygen limits the scope
665 of a * and _ to a single paragraph.
667 For a code span, between the starting and ending backtick only two
668 new lines are allowed.
670 Also for links there are limits; the link text, and link title each can
671 contain only one new line, the URL may not contain any newlines.
673 \section markdown_debug Debugging of problems
675 When doxygen parses the source code it first extracts the comments blocks,
676 then passes these through the Markdown preprocessor. The output of the
677 Markdown preprocessing consists of text with \ref cmd_intro "special commands"
678 and \ref htmlcmds "HTML commands".
679 A second pass takes the output of the Markdown preprocessor and
680 converts it into the various output formats.
682 During Markdown preprocessing no errors are produced. Anything that
683 does not fit the Markdown syntax is simply passed on as-is. In the subsequent
684 parsing phase this could lead to errors, which may not always be obvious
685 as they are based on the intermediate format.
687 To see the result after Markdown processing you can run doxygen with the
688 `-d Markdown` option. It will then print each comment block before and
689 after Markdown processing.
692 Go to the <a href="lists.html">next</a> section or return to the
693 <a href="index.html">index</a>.