Markdown
Syntax Highlighting
Although code blocks can be rendered by only indenting code snippets with tabs, it is recommended that ``` backticks or ::: colons used for consistency in syntax highlighting colors.
Using the ``` triple backticks:
Python
import antigravity
def main():
antigravity.fly()
if __name__=='__main__':
main()
Javascript
// Looks indented but backticks still inline with paragaraphs
function myFunction() {
document.getElementById("one").innerHTML = "First";
document.getElementById("two").innerHTML = "Second";
// commented line
};
HTML
<figure class="float-left">
<img src="path-to/images/my_image-600x400.png" alt="icon">
</figure>
JSON
{
"id": 10,
"syntax": "JSON",
}
Plain Text
If you prefer just plain text, no <b>Syntax</b> highlighting.
Markdown text for the examples above.
Python
```python
import antigravity
def main():
antigravity.fly()
if __name__=='__main__':
main()
```
Javascript
```javascript
// Looks indented but backticks still inline with paragaraphs
function myFunction() {
document.getElementById("one").innerHTML = "First";
document.getElementById("two").innerHTML = "Second";
// commented line
};
```
HTML
```html
<figure class="float-left">
<img src="path-to/images/my_image-600x400.png" alt="icon">
</figure>
```
JSON
```json
{
"id": 10,
"syntax": "JSON",
}
```
Plain Text
```text
If you prefer just plain text, no <b>Syntax</b> highlighting.
```
Using the ::: triple colons:
import antigravity
def main():
antigravity.fly()
if __name__=='__main__':
main()
Markdown text for the example above.
:::python
import antigravity
def main():
antigravity.fly()
if __name__=='__main__':
main()
Adding line numbers:
If the first line of the indented code block contains #! followed by language like #!python, then line numbers along with the specified language will be used. If the full path is defined, #!/usr/bin/python, then the path will also get included in code block. If it does not contain a path or / then that it will be ignored.
1 2 3 4 5 |
|
Markdown text for the example above.
#!bash
if [[ -z "$string" ]]; then
echo "String is empty"
elif [[ -n "$string" ]]; then
echo "String is not empty"
fi
1 2 3 4 5 6 |
|
Markdown text for the example above
#!/usr/bin/bash
if [[ -z "$string" ]]; then
echo "String is empty"
elif [[ -n "$string" ]]; then
echo "String is not empty"
fi
Markdown text elements
Here are some of the commonly used Markdown text elements for a quick reference.
The a element and external a element examples
The abbr element and an abbr element with title examples
The ACRONYM element example
The b element example
The cite element example
The code element
example
The data element example
The ~~del element~~ example
The dfn element and dfn element with title examples
The em element example
The i element example
The ins element example
The kbd element example
The mark element example
The q element
example
The q element
exampleinside
a q element
The s element example
The samp element example
The small element example
The span element example
The strong element example
The sub element example
The sup element example
The example
The u element example
The var element example
The insert spaces
Markdown text for the examples above.
The [a element](#) and [external a element](https://example.com) examples
The <abbr>abbr element</abbr> and an <abbr title="Abbreviation">abbr</abbr> element with title examples
The <acronym title="A Cowboy Ran One New York Marathon">ACRONYM</acronym> element example
The **b element** example
The <cite>cite element</cite> example
The `code element` example
The <data value="3967381398">data element</data> example
The ~~del element~~ example
The <dfn>dfn element</dfn> and <dfn title="Title text">dfn element with title</dfn> examples
The _em element_ example
The _i element_ example
The <ins>ins element</ins> example
The <kbd>kbd element</kbd> example
The <mark>mark element</mark> example
The <q>q element</q> example
The <q>q element <q>inside</q> a q element</q> example
The <s>s element</s> example
The <samp>samp element</samp> example
The <small>small element</small> example
The <span>span element</span> example
The **strong element** example
The <sub>sub element</sub> example
The <sup>sup element</sup> example
The <time datetime="2005-05-15 19:00">time element</time> example
The <u>u element</u> example
The <var>var element</var> example
The insert spaces
The * * * Horizontal Rule
You can find more examples at Markdown Cheatsheet and Markdown Guide