FutureOSS Docs一切皆为插件的开发者工具运行时框架https://oss-runtime.dev/zh_CNMarkdown Tutorialhttps://oss-runtime.dev/blog/posts/markdown-tutorial/https://oss-runtime.dev/blog/posts/markdown-tutorial/A simple example of a Markdown blog post.Mon, 20 Jan 2025 00:00:00 GMT<h1>Markdown Tutorial</h1> <p>A markdown example shows how to write a markdown file. This document integrates core syntax and extensions (GMF).</p> <ul> <li><a href="#block-elements">Block Elements</a> <ul> <li><a href="#paragraphs-and-line-breaks">Paragraphs and Line Breaks</a></li> <li><a href="#headers">Headers</a></li> <li><a href="#blockquotes">Blockquotes</a></li> <li><a href="#lists">Lists</a></li> <li><a href="#code-blocks">Code Blocks</a></li> <li><a href="#horizontal-rules">Horizontal Rules</a></li> <li><a href="#table">Table</a></li> </ul> </li> <li><a href="#span-elements">Span Elements</a> <ul> <li><a href="#links">Links</a></li> <li><a href="#emphasis">Emphasis</a></li> <li><a href="#code">Code</a></li> <li><a href="#images">Images</a></li> <li><a href="#strikethrough">Strikethrough</a></li> </ul> </li> <li><a href="#miscellaneous">Miscellaneous</a> <ul> <li><a href="#automatic-links">Automatic Links</a></li> <li><a href="#backslash-escapes">Backslash Escapes</a></li> </ul> </li> <li><a href="#inline-html">Inline HTML</a></li> </ul> <h2>Block Elements</h2> <h3>Paragraphs and Line Breaks</h3> <h4>Paragraphs</h4> <p>HTML Tag: <code>&lt;p&gt;</code></p> <p>One or more blank lines. (A blank line is a line containing nothing but <strong>spaces</strong> or <strong>tabs</strong> is considered blank.)</p> <p>Code:</p> <pre><code>This will be inline. This is second paragraph. </code></pre> <p>Preview:</p> <hr /> <p>This will be inline.</p> <p>This is second paragraph.</p> <hr /> <h4>Line Breaks</h4> <p>HTML Tag: <code>&lt;br /&gt;</code></p> <p>End a line with <strong>two or more spaces</strong>.</p> <p>Code:</p> <pre><code>This will be not inline. </code></pre> <p>Preview:</p> <hr /> <p>This will be not<br /> inline.</p> <hr /> <h3>Headers</h3> <p>Markdown supports two styles of headers, Setext and atx.</p> <h4>Setext</h4> <p>HTML Tags: <code>&lt;h1&gt;</code>, <code>&lt;h2&gt;</code></p> <p>“Underlined” using <strong>equal signs (=)</strong> as <code>&lt;h1&gt;</code> and <strong>dashes (-)</strong> as <code>&lt;h2&gt;</code> in any number.</p> <p>Code:</p> <pre><code>This is an H1 ============= This is an H2 ------------- </code></pre> <p>Preview:</p> <hr /> <h1>This is an H1</h1> <h2>This is an H2</h2> <hr /> <h4>atx</h4> <p>HTML Tags: <code>&lt;h1&gt;</code>, <code>&lt;h2&gt;</code>, <code>&lt;h3&gt;</code>, <code>&lt;h4&gt;</code>, <code>&lt;h5&gt;</code>, <code>&lt;h6&gt;</code></p> <p>Uses 1-6 <strong>hash characters (#)</strong> at the start of the line, corresponding to <code>&lt;h1&gt;</code> - <code>&lt;h6&gt;</code>.</p> <p>Code:</p> <pre><code># This is an H1 ## This is an H2 ###### This is an H6 </code></pre> <p>Preview:</p> <hr /> <h1>This is an H1</h1> <h2>This is an H2</h2> <h6>This is an H6</h6> <hr /> <p>Optionally, you may “close” atx-style headers. The closing hashes <strong>don’t need to match</strong> the number of hashes used to open the header.</p> <p>Code:</p> <pre><code># This is an H1 # ## This is an H2 ## ### This is an H3 ###### </code></pre> <p>Preview:</p> <hr /> <h1>This is an H1</h1> <h2>This is an H2</h2> <h3>This is an H3</h3> <hr /> <h3>Blockquotes</h3> <p>HTML Tag: <code>&lt;blockquote&gt;</code></p> <p>Markdown uses email-style <strong>&gt;</strong> characters for blockquoting. It looks best if you hard wrap the text and put a &gt; before every line.</p> <p>Code:</p> <pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, &gt; consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. &gt; Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. &gt; &gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse &gt; id sem consectetuer libero luctus adipiscing. </code></pre> <p>Preview:</p> <hr /> <blockquote> <p>This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p> <p>Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing.</p> </blockquote> <hr /> <p>Markdown allows you to be lazy and only put the &gt; before the first line of a hard-wrapped paragraph.</p> <p>Code:</p> <pre><code>&gt; This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. &gt; Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing. </code></pre> <p>Preview:</p> <hr /> <blockquote> <p>This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p> </blockquote> <blockquote> <p>Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing.</p> </blockquote> <hr /> <p>Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by adding additional levels of &gt;.</p> <p>Code:</p> <pre><code>&gt; This is the first level of quoting. &gt; &gt; &gt; This is nested blockquote. &gt; &gt; Back to the first level. </code></pre> <p>Preview:</p> <hr /> <blockquote> <p>This is the first level of quoting.</p> <blockquote> <p>This is nested blockquote.</p> </blockquote> <p>Back to the first level.</p> </blockquote> <hr /> <p>Blockquotes can contain other Markdown elements, including headers, lists, and code blocks.</p> <p>Code:</p> <pre><code>&gt; ## This is a header. &gt; &gt; 1. This is the first list item. &gt; 2. This is the second list item. &gt; &gt; Here's some example code: &gt; &gt; return shell_exec("echo $input | $markdown_script"); </code></pre> <p>Preview:</p> <hr /> <blockquote> <h2>This is a header.</h2> <ol> <li>This is the first list item.</li> <li>This is the second list item.</li> </ol> <p>Here's some example code:</p> <pre><code>return shell_exec("echo $input | $markdown_script"); </code></pre> </blockquote> <hr /> <h3>Lists</h3> <p>Markdown supports ordered (numbered) and unordered (bulleted) lists.</p> <h4>Unordered</h4> <p>HTML Tag: <code>&lt;ul&gt;</code></p> <p>Unordered lists use <strong>asterisks (*)</strong>, <strong>pluses (+)</strong>, and <strong>hyphens (-)</strong>.</p> <p>Code:</p> <pre><code>* Red * Green * Blue </code></pre> <p>Preview:</p> <hr /> <ul> <li>Red</li> <li>Green</li> <li>Blue</li> </ul> <hr /> <p>is equivalent to:</p> <p>Code:</p> <pre><code>+ Red + Green + Blue </code></pre> <p>and:</p> <p>Code:</p> <pre><code>- Red - Green - Blue </code></pre> <h4>Ordered</h4> <p>HTML Tag: <code>&lt;ol&gt;</code></p> <p>Ordered lists use numbers followed by periods:</p> <p>Code:</p> <pre><code>1. Bird 2. McHale 3. Parish </code></pre> <p>Preview:</p> <hr /> <ol> <li>Bird</li> <li>McHale</li> <li>Parish</li> </ol> <hr /> <p>It’s possible to trigger an ordered list by accident, by writing something like this:</p> <p>Code:</p> <pre><code>1986. What a great season. </code></pre> <p>Preview:</p> <hr /> <ol> <li>What a great season.</li> </ol> <hr /> <p>You can <strong>backslash-escape (\)</strong> the period:</p> <p>Code:</p> <pre><code>1986\. What a great season. </code></pre> <p>Preview:</p> <hr /> <p>1986. What a great season.</p> <hr /> <h4>Indented</h4> <h5>Blockquote</h5> <p>To put a blockquote within a list item, the blockquote’s &gt; delimiters need to be indented:</p> <p>Code:</p> <pre><code>* A list item with a blockquote: &gt; This is a blockquote &gt; inside a list item. </code></pre> <p>Preview:</p> <hr /> <ul> <li> <p>A list item with a blockquote:</p> <blockquote> <p>This is a blockquote inside a list item.</p> </blockquote> </li> </ul> <hr /> <h5>Code Block</h5> <p>To put a code block within a list item, the code block needs to be indented twice — <strong>8 spaces</strong> or <strong>two tabs</strong>:</p> <p>Code:</p> <pre><code>* A list item with a code block: &lt;code goes here&gt; </code></pre> <p>Preview:</p> <hr /> <ul> <li> <p>A list item with a code block:</p> <pre><code>&lt;code goes here&gt; </code></pre> </li> </ul> <hr /> <h5>Nested List</h5> <p>Code:</p> <pre><code>* A * A1 * A2 * B * C </code></pre> <p>Preview:</p> <hr /> <ul> <li>A <ul> <li>A1</li> <li>A2</li> </ul> </li> <li>B</li> <li>C</li> </ul> <hr /> <h3>Code Blocks</h3> <p>HTML Tag: <code>&lt;pre&gt;</code></p> <p>Indent every line of the block by at least <strong>4 spaces</strong> or <strong>1 tab</strong>.</p> <p>Code:</p> <pre><code>This is a normal paragraph: This is a code block. </code></pre> <p>Preview:</p> <hr /> <p>This is a normal paragraph:</p> <pre><code>This is a code block. </code></pre> <hr /> <p>A code block continues until it reaches a line that is not indented (or the end of the article).</p> <p>Within a code block, <strong><em>ampersands (&amp;)</em></strong> and angle <strong>brackets (&lt; and &gt;)</strong> are automatically converted into HTML entities.</p> <p>Code:</p> <pre><code> &lt;div class="footer"&gt; &amp;copy; 2004 Foo Corporation &lt;/div&gt; </code></pre> <p>Preview:</p> <hr /> <pre><code>&lt;div class="footer"&gt; &amp;copy; 2004 Foo Corporation &lt;/div&gt; </code></pre> <hr /> <p>Following sections Fenced Code Blocks and Syntax Highlighting are extensions, you can use the other way to write the code block.</p> <h4>Fenced Code Blocks</h4> <p>Just wrap your code in <code>```</code> (as shown below) and you won't need to indent it by four spaces.</p> <p>Code:</p> <pre><code>Here's an example: ``` function test() { console.log("notice the blank line before this function?"); } ``` </code></pre> <p>Preview:</p> <hr /> <p>Here's an example:</p> <pre><code>function test() { console.log("notice the blank line before this function?"); } </code></pre> <hr /> <h4>Syntax Highlighting</h4> <p>In your fenced block, add an optional language identifier and we'll run it through syntax highlighting (<a href="https://github.com/github/linguist/blob/master/lib/linguist/languages.yml">Support Languages</a>).</p> <p>Code:</p> <pre><code>```ruby require 'redcarpet' markdown = Redcarpet.new("Hello World!") puts markdown.to_html ``` </code></pre> <p>Preview:</p> <hr /> <pre><code>require 'redcarpet' markdown = Redcarpet.new("Hello World!") puts markdown.to_html </code></pre> <hr /> <h3>Horizontal Rules</h3> <p>HTML Tag: <code>&lt;hr /&gt;</code> Places <strong>three or more hyphens (-), asterisks (*), or underscores (_)</strong> on a line by themselves. You may use spaces between the hyphens or asterisks.</p> <p>Code:</p> <pre><code>* * * *** ***** - - - --------------------------------------- ___ </code></pre> <p>Preview:</p> <hr /> <hr /> <hr /> <hr /> <hr /> <hr /> <hr /> <hr /> <h3>Table</h3> <p>HTML Tag: <code>&lt;table&gt;</code></p> <p>It's an extension.</p> <p>Separates column by <strong>pipe (|)</strong> and header by <strong>dashes (-)</strong>, and uses <strong>colon (:)</strong> for alignment.</p> <p>The outer <strong>pipes (|)</strong> and alignment are optional. There are <strong>3 delimiters</strong> each cell at least for separating header.</p> <p>Code:</p> <pre><code>| Left | Center | Right | |:-----|:------:|------:| |aaa |bbb |ccc | |ddd |eee |fff | A | B ---|--- 123|456 A |B --|-- 12|45 </code></pre> <p>Preview:</p> <hr /> <table> <thead> <tr> <th>Left</th> <th>Center</th> <th>Right</th> </tr> </thead> <tbody> <tr> <td>aaa</td> <td>bbb</td> <td>ccc</td> </tr> <tr> <td>ddd</td> <td>eee</td> <td>fff</td> </tr> </tbody> </table> <table> <thead> <tr> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td>123</td> <td>456</td> </tr> </tbody> </table> <table> <thead> <tr> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td>12</td> <td>45</td> </tr> </tbody> </table> <hr /> <h2>Span Elements</h2> <h3>Links</h3> <p>HTML Tag: <code>&lt;a&gt;</code></p> <p>Markdown supports two style of links: inline and reference.</p> <h4>Inline</h4> <p>Inline link format like this: <code>[Link Text](URL "Title")</code></p> <p>Title is optional.</p> <p>Code:</p> <pre><code>This is [an example](http://example.com/ "Title") inline link. [This link](http://example.net/) has no title attribute. </code></pre> <p>Preview:</p> <hr /> <p>This is <a href="http://example.com/">an example</a> inline link.</p> <p><a href="http://example.net/">This link</a> has no title attribute.</p> <hr /> <p>If you’re referring to a local resource on the same server, you can use relative paths:</p> <p>Code:</p> <pre><code>See my [About](/about/) page for details. </code></pre> <p>Preview:</p> <hr /> <p>See my <a href="/about/">About</a> page for details.</p> <hr /> <h4>Reference</h4> <p>You could predefine link references. Format like this: <code>[id]: URL "Title"</code></p> <p>Title is also optional. And the you refer the link, format like this: <code>[Link Text][id]</code></p> <p>Code:</p> <pre><code>[id]: http://example.com/ "Optional Title Here" This is [an example][id] reference-style link. </code></pre> <p>Preview:</p> <hr /> <p>This is <a href="http://example.com/">an example</a> reference-style link.</p> <hr /> <p>That is:</p> <ul> <li>Square brackets containing the link identifier (<strong>not case sensitive</strong>, optionally indented from the left margin using up to three spaces);</li> <li>followed by a colon;</li> <li>followed by one or more spaces (or tabs);</li> <li>followed by the URL for the link;</li> <li>The link URL may, optionally, be surrounded by angle brackets.</li> <li>optionally followed by a title attribute for the link, enclosed in double or single quotes, or enclosed in parentheses.</li> </ul> <p>The following three link definitions are equivalent:</p> <p>Code:</p> <pre><code>[foo]: http://example.com/ "Optional Title Here" [foo]: http://example.com/ 'Optional Title Here' [foo]: http://example.com/ (Optional Title Here) [foo]: &lt;http://example.com/&gt; "Optional Title Here" </code></pre> <p>Uses an empty set of square brackets, the link text itself is used as the name.</p> <p>Code:</p> <pre><code>[Google]: http://google.com/ [Google][] </code></pre> <p>Preview:</p> <hr /> <p><a href="http://google.com/">Google</a></p> <hr /> <h3>Emphasis</h3> <p>HTML Tags: <code>&lt;em&gt;</code>, <code>&lt;strong&gt;</code></p> <p>Markdown treats <strong>asterisks (*)</strong> and <strong>underscores (_)</strong> as indicators of emphasis. <strong>One delimiter</strong> will be <code>&lt;em&gt;</code>; *<em>double delimiters</em> will be <code>&lt;strong&gt;</code>.</p> <p>Code:</p> <pre><code>*single asterisks* _single underscores_ **double asterisks** __double underscores__ </code></pre> <p>Preview:</p> <hr /> <p><em>single asterisks</em></p> <p><em>single underscores</em></p> <p><strong>double asterisks</strong></p> <p><strong>double underscores</strong></p> <hr /> <p>But if you surround an * or _ with spaces, it’ll be treated as a literal asterisk or underscore.</p> <p>You can backslash escape it:</p> <p>Code:</p> <pre><code>\*this text is surrounded by literal asterisks\* </code></pre> <p>Preview:</p> <hr /> <p>*this text is surrounded by literal asterisks*</p> <hr /> <h3>Code</h3> <p>HTML Tag: <code>&lt;code&gt;</code></p> <p>Wraps it with <strong>backtick quotes (`)</strong>.</p> <p>Code:</p> <pre><code>Use the `printf()` function. </code></pre> <p>Preview:</p> <hr /> <p>Use the <code>printf()</code> function.</p> <hr /> <p>To include a literal backtick character within a code span, you can use <strong>multiple backticks</strong> as the opening and closing delimiters:</p> <p>Code:</p> <pre><code>``There is a literal backtick (`) here.`` </code></pre> <p>Preview:</p> <hr /> <p><code>There is a literal backtick (`) here.</code></p> <hr /> <p>The backtick delimiters surrounding a code span may include spaces — one after the opening, one before the closing. This allows you to place literal backtick characters at the beginning or end of a code span:</p> <p>Code:</p> <pre><code>A single backtick in a code span: `` ` `` A backtick-delimited string in a code span: `` `foo` `` </code></pre> <p>Preview:</p> <hr /> <p>A single backtick in a code span: <code>`</code></p> <p>A backtick-delimited string in a code span: <code>`foo`</code></p> <hr /> <h3>Images</h3> <p>HTML Tag: <code>&lt;img /&gt;</code></p> <p>Markdown uses an image syntax that is intended to resemble the syntax for links, allowing for two styles: inline and reference.</p> <h4>Inline</h4> <p>Inline image syntax looks like this: <code>![Alt text](URL "Title")</code></p> <p>Title is optional.</p> <p>Code:</p> <pre><code>![Alt text](/path/to/img.jpg) ![Alt text](/path/to/img.jpg "Optional title") </code></pre> <p>Preview:</p> <hr /> <p><img src="https://s2.loli.net/2024/08/20/5fszgXeOxmL3Wdv.webp" alt="Alt text" /></p> <p><img src="https://s2.loli.net/2024/08/20/5fszgXeOxmL3Wdv.webp" alt="Alt text" title="Optional title" /></p> <hr /> <p>That is:</p> <ul> <li>An exclamation mark: !;</li> <li>followed by a set of square brackets, containing the alt attribute text for the image;</li> <li>followed by a set of parentheses, containing the URL or path to the image, and an optional title attribute enclosed in double or single quotes.</li> </ul> <h4>Reference</h4> <p>Reference-style image syntax looks like this: <code>![Alt text][id]</code></p> <p>Code:</p> <pre><code>[img id]: https://s2.loli.net/2024/08/20/5fszgXeOxmL3Wdv.webp "Optional title attribute" ![Alt text][img id] </code></pre> <p>Preview:</p> <hr /> <p><img src="https://s2.loli.net/2024/08/20/5fszgXeOxmL3Wdv.webp" alt="Alt text" title="Optional title attribute" /></p> <hr /> <h3>Strikethrough</h3> <p>HTML Tag: <code>&lt;del&gt;</code></p> <p>It's an extension.</p> <p>GFM adds syntax to strikethrough text.</p> <p>Code:</p> <pre><code>~~Mistaken text.~~ </code></pre> <p>Preview:</p> <hr /> <p><s>Mistaken text.</s></p> <hr /> <h2>Miscellaneous</h2> <h3>Automatic Links</h3> <p>Markdown supports a shortcut style for creating “automatic” links for URLs and email addresses: simply surround the URL or email address with angle brackets.</p> <p>Code:</p> <pre><code>&lt;http://example.com/&gt; &lt;address@example.com&gt; </code></pre> <p>Preview:</p> <hr /> <p><a href="http://example.com/">http://example.com/</a></p> <p><a href="mailto:address@example.com">address@example.com</a></p> <hr /> <p>GFM will autolink standard URLs.</p> <p>Code:</p> <pre><code>https://github.com/emn178/markdown </code></pre> <p>Preview:</p> <hr /> <p>https://github.com/emn178/markdown</p> <hr /> <h3>Backslash Escapes</h3> <p>Markdown allows you to use backslash escapes to generate literal characters which would otherwise have special meaning in Markdown’s formatting syntax.</p> <p>Code:</p> <pre><code>\*literal asterisks\* </code></pre> <p>Preview:</p> <hr /> <p>*literal asterisks*</p> <hr /> <p>Markdown provides backslash escapes for the following characters:</p> <p>Code:</p> <pre><code>\ backslash ` backtick * asterisk _ underscore {} curly braces [] square brackets () parentheses # hash mark + plus sign - minus sign (hyphen) . dot ! exclamation mark </code></pre> <h2>Inline HTML</h2> <p>For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.</p> <p>Code:</p> <pre><code>This is a regular paragraph. &lt;table&gt; &lt;tr&gt; &lt;td&gt;Foo&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; This is another regular paragraph. </code></pre> <p>Preview:</p> <hr /> <p>This is a regular paragraph.</p> <p>&lt;table&gt; &lt;tr&gt; &lt;td&gt;Foo&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt;</p> <p>This is another regular paragraph.</p> <hr /> <p>Note that Markdown formatting syntax is <strong>not processed within block-level HTML tags</strong>.</p> <p>Unlike block-level HTML tags, Markdown syntax is <strong>processed within span-level tags</strong>.</p> <p>Code:</p> <pre><code>&lt;span&gt;**Work**&lt;/span&gt; &lt;div&gt; **No Work** &lt;/div&gt; </code></pre> <p>Preview:</p> <hr /> <p>&lt;span&gt;<strong>Work</strong>&lt;/span&gt;</p> <p>&lt;div&gt; <strong>No Work</strong> &lt;/div&gt;</p> <hr /> Markdown Mermaidhttps://oss-runtime.dev/blog/posts/markdown-mermaid/https://oss-runtime.dev/blog/posts/markdown-mermaid/A simple example of a Markdown blog post with Mermaid.Sun, 01 Oct 2023 00:00:00 GMT<h1>Complete Guide to Markdown with Mermaid Diagrams</h1> <p>This article demonstrates how to create various complex diagrams using Mermaid in Markdown documents, including flowcharts, sequence diagrams, Gantt charts, class diagrams, and state diagrams.</p> <h2>Flowchart Example</h2> <p>Flowcharts are excellent for representing processes or algorithm steps.</p> <pre><code>graph TD A[Start] --&gt; B{Condition Check} B --&gt;|Yes| C[Process Step 1] B --&gt;|No| D[Process Step 2] C --&gt; E[Subprocess] D --&gt; E subgraph E [Subprocess Details] E1[Substep 1] --&gt; E2[Substep 2] E2 --&gt; E3[Substep 3] end E --&gt; F{Another Decision} F --&gt;|Option 1| G[Result 1] F --&gt;|Option 2| H[Result 2] F --&gt;|Option 3| I[Result 3] G --&gt; J[End] H --&gt; J I --&gt; J </code></pre> <h2>Sequence Diagram Example</h2> <p>Sequence diagrams show interactions between objects over time.</p> <pre><code>sequenceDiagram participant User participant WebApp participant Server participant Database User-&gt;&gt;WebApp: Submit Login Request WebApp-&gt;&gt;Server: Send Auth Request Server-&gt;&gt;Database: Query User Credentials Database--&gt;&gt;Server: Return User Data Server--&gt;&gt;WebApp: Return Auth Result alt Auth Successful WebApp-&gt;&gt;User: Show Welcome Page WebApp-&gt;&gt;Server: Request User Data Server-&gt;&gt;Database: Get User Preferences Database--&gt;&gt;Server: Return Preferences Server--&gt;&gt;WebApp: Return User Data WebApp-&gt;&gt;User: Load Personalized Interface else Auth Failed WebApp-&gt;&gt;User: Show Error Message WebApp-&gt;&gt;User: Prompt Re-entry end </code></pre> <h2>Gantt Chart Example</h2> <p>Gantt charts are perfect for displaying project schedules and timelines.</p> <pre><code>gantt title Website Development Project Timeline dateFormat YYYY-MM-DD axisFormat %m/%d section Design Phase Requirements Analysis :a1, 2023-10-01, 7d UI Design :a2, after a1, 10d Prototype Creation :a3, after a2, 5d section Development Phase Frontend Development :b1, 2023-10-20, 15d Backend Development :b2, after a2, 18d Database Design :b3, after a1, 12d section Testing Phase Unit Testing :c1, after b1, 8d Integration Testing :c2, after b2, 10d User Acceptance Testing :c3, after c2, 7d section Deployment Production Deployment :d1, after c3, 3d Launch :milestone, after d1, 0d </code></pre> <h2>Class Diagram Example</h2> <p>Class diagrams show the static structure of a system, including classes, attributes, methods, and their relationships.</p> <pre><code>classDiagram class User { +String username +String password +String email +Boolean active +login() +logout() +updateProfile() } class Article { +String title +String content +Date publishDate +Boolean published +publish() +edit() +delete() } class Comment { +String content +Date commentDate +addComment() +deleteComment() } class Category { +String name +String description +addArticle() +removeArticle() } User "1" -- "*" Article : writes User "1" -- "*" Comment : posts Article "1" -- "*" Comment : has Article "1" -- "*" Category : belongs to </code></pre> <h2>State Diagram Example</h2> <p>State diagrams show the sequence of states an object goes through during its life cycle.</p> <pre><code>stateDiagram-v2 [*] --&gt; Draft Draft --&gt; UnderReview : submit UnderReview --&gt; Draft : reject UnderReview --&gt; Approved : approve Approved --&gt; Published : publish Published --&gt; Archived : archive Published --&gt; Draft : retract state Published { [*] --&gt; Active Active --&gt; Hidden : temporarily hide Hidden --&gt; Active : restore Active --&gt; [*] Hidden --&gt; [*] } Archived --&gt; [*] </code></pre> <h2>Pie Chart Example</h2> <p>Pie charts are ideal for displaying proportions and percentage data.</p> <pre><code>pie title Website Traffic Sources Analysis "Search Engines" : 45.6 "Direct Access" : 30.1 "Social Media" : 15.3 "Referral Links" : 6.4 "Other Sources" : 2.6 </code></pre> <h2>Conclusion</h2> <p>Mermaid is a powerful tool for creating various types of diagrams in Markdown documents. This article demonstrated how to use flowcharts, sequence diagrams, Gantt charts, class diagrams, state diagrams, and pie charts. These diagrams can help you express complex concepts, processes, and data structures more clearly.</p> <p>To use Mermaid, simply specify the mermaid language in a code block and describe the diagram using concise text syntax. Mermaid will automatically convert these descriptions into beautiful visual diagrams.</p> <p>Try using Mermaid diagrams in your next technical blog post or project documentation - they will make your content more professional and easier to understand!</p> Markdown Examplehttps://oss-runtime.dev/blog/posts/markdown/https://oss-runtime.dev/blog/posts/markdown/A simple example of a Markdown blog post.Sun, 01 Oct 2023 00:00:00 GMT<h1>An h1 header</h1> <p>Paragraphs are separated by a blank line.</p> <p>2nd paragraph. <em>Italic</em>, <strong>bold</strong>, and <code>monospace</code>. Itemized lists look like:</p> <ul> <li>this one</li> <li>that one</li> <li>the other one</li> </ul> <p>Note that --- not considering the asterisk --- the actual text content starts at 4-columns in.</p> <blockquote> <p>Block quotes are written like so.</p> <p>They can span multiple paragraphs, if you like.</p> </blockquote> <p>Use 3 dashes for an em-dash. Use 2 dashes for ranges (ex., "it's all in chapters 12--14"). Three dots ... will be converted to an ellipsis. Unicode is supported. ☺</p> <h2>An h2 header</h2> <p>Here's a numbered list:</p> <ol> <li>first item</li> <li>second item</li> <li>third item</li> </ol> <p>Note again how the actual text starts at 4 columns in (4 characters from the left side). Here's a code sample:</p> <pre><code># Let me re-iterate ... for i in 1 .. 10 { do-something(i) } </code></pre> <p>As you probably guessed, indented 4 spaces. By the way, instead of indenting the block, you can use delimited blocks, if you like:</p> <pre><code>define foobar() { print "Welcome to flavor country!"; } </code></pre> <p>(which makes copying &amp; pasting easier). You can optionally mark the delimited block for Pandoc to syntax highlight it:</p> <pre><code>import time # Quick, count to ten! for i in range(10): # (but not *too* quick) time.sleep(0.5) print i </code></pre> <h3>An h3 header</h3> <p>Now a nested list:</p> <ol> <li> <p>First, get these ingredients:</p> <ul> <li>carrots</li> <li>celery</li> <li>lentils</li> </ul> </li> <li> <p>Boil some water.</p> </li> <li> <p>Dump everything in the pot and follow this algorithm:</p> <pre><code>find wooden spoon uncover pot stir cover pot balance wooden spoon precariously on pot handle wait 10 minutes goto first step (or shut off burner when done) </code></pre> <p>Do not bump wooden spoon or it will fall.</p> </li> </ol> <p>Notice again how text always lines up on 4-space indents (including that last line which continues item 3 above).</p> <p>Here's a link to <a href="http://foo.bar">a website</a>, to a <a href="local-doc.html">local doc</a>, and to a <a href="#an-h2-header">section heading in the current doc</a>. Here's a footnote [^1].</p> <p>[^1]: Footnote text goes here.</p> <p>Tables can look like this:</p> <p>size material color</p> <hr /> <p>9 leather brown 10 hemp canvas natural 11 glass transparent</p> <p>Table: Shoes, their sizes, and what they're made of</p> <p>(The above is the caption for the table.) Pandoc also supports multi-line tables:</p> <hr /> <p>keyword text</p> <hr /> <p>red Sunsets, apples, and other red or reddish things.</p> <p>green Leaves, grass, frogs and other things it's not easy being.</p> <hr /> <p>A horizontal rule follows.</p> <hr /> <p>Here's a definition list:</p> <p>apples : Good for making applesauce. oranges : Citrus! tomatoes : There's no "e" in tomatoe.</p> <p>Again, text is indented 4 spaces. (Put a blank line between each term/definition pair to spread things out more.)</p> <p>Here's a "line block":</p> <p>| Line one | Line too | Line tree</p> <p>and images can be specified like so:</p> <p>Inline math equations go in like so: $\omega = d\phi / dt$. Display math should get its own line and be put in in double-dollarsigns:</p> <p>$$I = \int \rho R^{2} dV$$</p> <p>And note that you can backslash-escape any punctuation characters which you wish to be displayed literally, ex.: `foo`, *bar*, etc.</p> Include Video in the Postshttps://oss-runtime.dev/blog/posts/video/https://oss-runtime.dev/blog/posts/video/This post demonstrates how to include embedded video in a blog post.Mon, 01 Aug 2022 00:00:00 GMT<p>Just copy the embed code from YouTube or other platforms, and paste it in the markdown file.</p> <pre><code>--- title: Include Video in the Post published: 2023-10-19 // ... --- &lt;iframe width="100%" height="468" src="https://www.youtube.com/embed/5gIf0_xpFPI?si=N1WTorLKL0uwLsU_" title="YouTube video player" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt; </code></pre> <h2>YouTube</h2> <p>&lt;iframe width="100%" height="468" src="https://www.youtube.com/embed/5gIf0_xpFPI?si=N1WTorLKL0uwLsU_" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen&gt;&lt;/iframe&gt;</p> <h2>Bilibili</h2> <p>&lt;iframe width="100%" height="468" src="//player.bilibili.com/player.html?bvid=BV1fK4y1s7Qf&amp;p=1&amp;autoplay=0" scrolling="no" border="0" frameborder="no" framespacing="0" allowfullscreen="true" &amp;autoplay=0&gt; &lt;/iframe&gt;</p>