From b62ddeda02fadcd09def9354eb2ef46a7562a106 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Wed, 6 Dec 2017 23:18:29 -0500 Subject: Switch docs to MKDocs (#602) Fixes #601. Merged in 6f87b32 from the md3 branch and did a lot of cleanup. Changes include: * Removed old docs build tool, templates, etc. * Added MkDocs config file, etc. * filename.txt => filename.md * pythonhost.org/Markdown => Python-Markdown.github.io * Markdown lint and other cleanup. * Automate pages deployment in makefile with `mkdocs gh-deploy` Assumes a git remote is set up named "pages". Do git remote add pages https://github.com/Python-Markdown/Python-Markdown.github.io.git ... before running `make deploy` the first time. --- docs/extensions/fenced_code_blocks.md | 116 ++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 docs/extensions/fenced_code_blocks.md (limited to 'docs/extensions/fenced_code_blocks.md') diff --git a/docs/extensions/fenced_code_blocks.md b/docs/extensions/fenced_code_blocks.md new file mode 100644 index 0000000..b7a657e --- /dev/null +++ b/docs/extensions/fenced_code_blocks.md @@ -0,0 +1,116 @@ +title: Fenced Code Blocks Extension + +# Fenced Code Blocks + +## Summary + +The Fenced Code Blocks extension adds a secondary way to define code blocks, +which overcomes a few limitations of the indented code blocks. + +This extension is included in the standard Markdown library. + +## Syntax + +Fenced Code Blocks are defined using the syntax established in +[PHP Markdown Extra][php]. + +[php]: http://www.michelf.com/projects/php-markdown/extra/#fenced-code-blocks + +Thus, the following text (taken from the above referenced PHP documentation): + +```md +This is a paragraph introducing: + +~~~~~~~~~~~~~~~~~~~~ +a one-line code block + ~~~~~~~~~~~~~~~~~~~~ +``` + +Fenced code blocks can have a blank line as the first and/or last line of a +code block and they can also come immediately after a list item without becoming +part of the list. + +!!! warning + + Fenced Code Blocks are only supported at the document root level. + Therefore, they cannot be nested inside lists or blockquotes. + +### Language + +In addition to PHP Extra's syntax, you can define the language of the code +block for use by syntax highlighters etc. The language will be assigned as a +class attribute of the ```` element in the output. Therefore, you should +define the language as you would a CSS class - ``.language``. For consistency +with other markdown syntax, the language can *optionally* be wrapped in curly +brackets: + +```md +~~~~{.python} +# python code +~~~~ + +~~~~.html +

HTML Document

+~~~~ +``` + +The above will output: + +```html +
# python code
+
+ +
<p>HTML Document</p>
+
+``` + +[GitHub][]'s backtick (`\``) syntax is also supported: + +````md +```python +# more python code +``` +```` + +[GitHub]: http://github.github.com/github-flavored-markdown/ + +### Emphasized Lines + +If you would like to have your fenced code blocks highlighted with the +[CodeHilite][] extension, simply enable that extension (remember that +[Pygments][] is its dependency) and the language of your fenced code blocks +will be passed in and highlighted appropriately. + +Similar to the [colon][] syntax of the CodeHilite extension, fenced code blocks +can also have emphasized certain lines of code. + +The lines can be specified with PHP Extra's syntax: + +```md +~~~~{.python hl_lines="1 3"} +# This line is emphasized +# This line isn't +# This line is emphasized +~~~~ +``` + +... or with GitHub's: + +````md +```python hl_lines="1 3" +# This line is emphasized +# This line isn't +# This line is emphasized +``` +```` + +[CodeHilite]: code_hilite.html +[Pygments]: http://pygments.org/ +[colon]: code_hilite.html#colons + +## Usage + +See [Extensions](index.md) for general extension usage, specify +`markdown.extensions.fenced_code` as the name of the extension. + +This extension does not accept any special configuration options. -- cgit v1.2.3