# top##gray|markup:## [#text-style text style] | [#grouping-alignment grouping and alignment] | [#images images] | [#tables-etal tables, code, and math]
##gray|tools:## [#pandoc pandoc]
||~ ||~ [#markdown markdown]||~ [#restructured-text restructured text]||~ [#mediawiki mediawiki]||~ [#asciidoc asciidoc]||~ [#org-mode org-mode]||
||sandbox||[http://daringfireball.net/projects/markdown/dingus daringfireball.net/projects/markdown/dingus] _
_
[http://johnmacfarlane.net/pandoc/try johnmacfarlane.net/pandoc/try]||[http://rst.ninjs.org/ rst.ninjs.org]||[http://en.wikipedia.org/wiki/Wikipedia:Sandbox en.wikipedia.org/wiki/Wikipedia:Sandbox]||[http://asciidoc.wikia.com/wiki/Template:Sandbox asciidoc.wiki.com/wiki/Template:Sandbox]|| ||
||command line tool||$ apt install markdown _
$ markdown foo.txt > foo.html _
_
$ apt install pandoc _
$ pandoc foo.txt -o foo.html||$ pip install rst2html5 _
_
$ rst2html5 foo.rst > foo.html||##gray|//run at root of MediaWiki source tree://## _
_
$ php maintenance/parse.php foo.txt \ _
@< >@> foo.html||$ apt install asciidoc _
$ asciidoc foo.txt|| ||
||autolinks url? _
@< >@||##gray|//no//##||##gray|//yes//##||##gray|//yes//##||##gray|//yes//##||##gray|//yes//##||
||can use html entities?||##gray|//yes; they are passed to output html//##||##gray|//no, the ampersand will be html entity escaped//##||##gray|//yes; they are replaced by UTF-8//##||##gray|//yes; they are passed to output html//##|| ||
||encoding||##gray|markdown //and// pandoc //assume UTF-8 for input and output.//##||##gray|//default output is UTF-8; default input is system dependent//## _
_
$ rst2html5 @@–@@input-encoding=utf-8 \ _
@< >@@@–@@output-encoding=iso8859-1 \ _
@< >@< foo.rst > foo.html||##gray|MediaWiki //specifies UTF-8 in the response header and the HTML document. It handles UTF-8 POST requests, and may handle other encodings correctly.//##||##gray|//assumes UTF-8 for input and output//##|| ||
||link offsite _
@< >@||Website ||@@Website <http://website.com>_@@||@@[http://website.com Website]@@||@@http://website.com@@[Website]||@@[[http://www.google.com][Google]]@@||
||link with url in footnote||##gray|//link://## _
[Website][u1] _
_
##gray|//footnote://## _
[u1]: @@http://website.com@@||##gray|//link://## _
Website_ _
_
##gray|//footnote://## _
.. _Website: @@http://website.com@@|| || || ||
||link onsite||Pipe Trick|| ||@@Pipe Trick@@||link:page.html[Pipe Trick]|| ||
||define anchor||||.. _foo:||##gray|//Headers automatically get anchors. Also://## _
||anchor:foo[]||#+NAME: foo||
||link to anchor||Foo _
_
##gray|//pandoc extension://## _
Foo||##gray|//Links to “_foo”; “foo” is used for text://## _
foo_||@@Foo@@||@<<anchor:foo,Foo>>@||@@[[foo][Foo]]@@||
||comment||<!@@–@@ comment @@–@@>||.. comment _
@< >@another comment _
_
##gray|//blank line terminates comment//##||<!@@–@@ comment @@–@@>||@@//@@ comment||##gray|//whitespace only before number sign://## _
_
comment||
||HTML||##gray|//set off block level html tags with blank lines://## _
_
My Header _
@< >@||@@|my_header|@@ _
_
##gray|//this must exist elsewhere in document://## _
.. |my_header| raw:: html _
_
@< >@foo||[http://en.wikipedia.org/wiki/Help:HTML_in_wikitext some HTML tags are permitted]|| || ||
||||||||||||~ # text-styletext style||
||~ ||~ [#markdown markdown]||~ [#restructured-text restructured text]||~ [#mediawiki mediawiki]||~ [#asciidoc asciidoc]||~ [#org-mode org-mode]||
||//italic text//||italic text _
italic text||italic text||##gray|//two single quotes://## _
‘‘italic text’’||’italic text’ _
italic text||/italic text/||
||bold text||@@bold text@@ _
@@bold text@@||@@bold text@@||##gray|//three single quotes://## _
‘‘‘bold text’’’||bold text||bold text||
||span style="font-variant: small-caps"small caps text/span|| _
small caps text _
|| ||@@{{smallcaps|small caps text}}@@|| || ||
||{{fixed width text}}||@@@@fixed width text@@@@||@@@@fixed width text@@@@||fixed width text||+fixed width text+||~fixed wdith text~||
||underlined text||underlined text|| ||underlined text||[underline]#underlined text#||underlined text||
||–striketrhough text–||strikethough text|| ||strikethough text|| ||+strikethrough text+||
||literal text||*not italics* _
@@*not italics*@@||*not italics*||’’not italics’’||@@+++not italics+++@@|| ||
||superscript2||superscript2|| ||superscript2||superscript2|| ||
||subscript,,2,,||subscript2|| ||subscript2||subscript2|| ||
||##red|font color##||font color|| ||font color||[red]#font color#|| ||
||font size||foo|| ||foo|| || ||
||span w/ class|| _
##gray|//text//## _
||.. role:: foo _
_
:foo:@@@@##gray|//text//##@@@@|| _
##gray|//text//## _
|| || ||
||||||||||||~ # grouping-alignmentgrouping and alignment||
||~ ||~ [#markdown markdown]||~ [#restructured-text restructured text]||~ [#mediawiki mediawiki]||~ [#asciidoc asciidoc]||~ [#org-mode org-mode]||
||line break||##gray|//space, space, newline//## _
_
||##gray|//all lines in paragraph with line breaks must start with pipe://## _
_
@@|@@ the line breaks _
@@|@@ here||||##gray|//space, plus, newline//## _
@< >@+||##gray|//backslash, backslash, newline//## _
_
##gray|//i.e put// @@\@@ //at the end of the line//##||
||horizontal rule||##gray|//three or more asterisks, hyphens, or underscores://## _
@@***@@ _
@@—@@ _
@@___@@||##gray|//four or more punctuation characters set off by blank lines://## _
_
@@—-@@ ||##gray|//four or more hyphens://## _
@@—-@@||##gray|//three or more single quotes//## _
‘‘‘||##gray|//five or more hyphens on a line by themselves://## _
_
@@—–@@||
||document title||##gray|//pandoc extension://## _
% document title||@@==============@@ _
document title _
@@==============@@|| ||@@=@@ document title = _
_
document title _
==============|| ||
||document header||% ##gray|//document title//## _
% John Doe; Jane Roe _
% August 16, 2001 _
||:Date: 2001-08-16 _
:Version: 1 _
:Authors: - John Doe _
@< >@@< >@@< >@@< >@@< >@- Jane Roe|| ||##gray|//document title//## _
============== _
John Doe _
August 16, 2001|| ||
||section header||##gray|//pandoc requires blank line before header, markdown doesn’t://## _
section header _
_
section header _
@@==============@@||##gray|//Other punctuation can be used for title and headers. Whatever punctuation is used must be used consistently in the document. An// n+1 //level section must be contained in an// n //level section.//## _
section header _
@@==============@@||@@=@@section header=||@@==@@ section header == _
_
section header _
@@————–@@||##gray|//no indentation before asterisk://## _
_
* section header||
||subsection header||@@##@@ subsection header _
_
subsection header _
@@—————–@@||subsection header _
@@—————–@@||==subsection header==||=== subsection header === _
_
subsection header _
~~~~~~~~~~~~~~~||##gray|//no indentation before asterisk://## _
_
** subsection header||
||subsubsection header||### subsubsection header||subsubsection header _
@@~~~~~~~~~~~~~~~~~~@@||===subsubsection header===||==== subsubsection header ==== _
_
subsubsection header _
@@@@||##gray|//no indentation before asterisk://## _
_
@@***@@ subusbsection header||
||level 4 header||#### level 4 header||level 4 header _
@@``````````````@@||====level 4 header====|| || ||
||headers automatically anchored?||##gray|//markdown no, pandoc yes//## _
_
##gray|//[#pandoc-header-identifiers pandoc header identifiers] are the same as the header with (1) all punctuation except hyphens, underscores, periods removed, (2) spaces and newlines replaced by hyphens, (3) lowercase, (4) everything before first letter removed//##||##gray|//yes//##||##gray|//yes//##||##gray|//yes, with id attribute on header element//##||##gray|//yes, with id attribute on header element//## _
_
##gray|//example:// ##||
||list item||##gray|//pandoc requires sublists be indented 4 spaces://## _
* list item _
@< >@* sublist item _
_
##gray|//plus signs + or hyphens - may be used in place of asterisks//##||##gray|//sublist must be set off by a blank line://## _
_
- list item _
_
@< >@- sublist item _
_
##gray|//asterisks * or plus signs + may be used in place of hyphens -//##||* list item _
** sublist item||* list item _
** sublist item||+ list item _
@< >@+ sublist item _
@< >@+ sublist item _
_
##gray|//Hyphens and asterisks can also be used for bullets. If asterisks are used, they must be indented to distinguish them from section headers.//##||
||list item with multiple paragraphs||##gray|//pandoc requires 4 space indent://## _
@< >@* 1st list item _
_
@< >@2nd paragraph _
_
@< >@* 2nd list item|| ||* 1st list item2nd paragraph _
* 2nd list item|| ||@@+@@ 1st list item _
_
@< >@2nd paragraph _
_
@@+@@ 2nd list item||
||numbered list item||##gray|//markdown ignores actual numeric values; pandoc uses first value only://## _
1. numbered one _
2. numbered two _
_
##gray|//pandoc supports other formats://## _
1) numbered one _
2) numbered two _
_
i. roman numeral one _
ii. roman numeral two||##gray|//numbers in source are used://## _
1. numbered one _
2. numbered two _
_
1) numbered one _
2 ) numbered two _
_
i) roman numeral one _
ii) roma numberal two||# numbered one _
numbered two||##gray|//error if values in markup are not sequential starting from one://## _
- numbered one _
- numbered two|| ||
||definition list|| _
one _
the 1st cardinal _
two _
the 2nd cardinal _
_
_
##gray|//pandoc extension; 4 spaces after colon://## _
one _
:@< >@@< >@the 1st cardinal _
two _
:@< >@@< >@the 2nd cardinal||one _
@< >@the 1st cardinal _
two _
@< >@the 2nd cardinal||; one : the 1st cardinal _
; two : the 2nd cardinal||one:: _
@< >@the 1st cardinal _
two:: _
@< >@the 2nd cardinal|| ||
||block quote||@@>@@ Four score and twenty _
@@>@@ years ago… _
_
##gray|//pandoc also has lazy block quotes://## _
_
@@>@@ Four score and twenty _
years ago… _
_
##gray|//pandoc requires blank line before a block quote//##||Main body text. _
_
@< >@Four score and twenty _
@< >@years ago… _
_
More main body text.|| _
Four score and twenty _
years ago… _
||@@*@@ _
Four score and twenty _
years ago… _
@@*@@||#+BEGIN_QUOTE _
Four score and twenty _
years ago… _
#+END_QUOTE||
||div w/ class|| _
##gray|//markup//## _
|| || _
##gray|//markup//## _
|| || ||
||||||||||||~ # imagesimages||
||~ ||~ [#markdown markdown]||~ [#restructured-text restructured text]||~ [#mediawiki mediawiki]||~ [#asciidoc asciidoc]||~ [#org-mode org-mode]||
||image _
@< >@||||.. image:: foo.jpg||File:foo.jpg||image:foo.jpg[]||@@foo.jpg@@||
||image link||
||.. image:: foo.jpg _
@< >@:target: @@http://foo.com@@||link=@@http://foo.com@@||image:foo.jpg[link=”@@http://foo.com@@"]|| ||
||image with alt||
||.. image:: foo.jpg _
@< >@:alt: Foo||alt=Foo||image:foo.jpg[Foo]|| ||
||image size||##gray|//height can also be specified; height proportionate if not://## _
||##gray|//height can also be specified; height proportionate if not://## _ _
.. image:: foo.jpg _
@< >@:width: 300px||##gray|//specify width; height will be proportionate://## _
300px||##gray|//specify width; height will be proportionate://## _
image:foo.jpg[width="300px”]|| ||
||||||||||||~ # tables-etaltables, code, and math||
||~ ||~ [#markdown markdown]||~ [#restructured-text restructured text]||~ [#mediawiki mediawiki]||~ [#asciidoc asciidoc]||~ [#org-mode org-mode]||
||table|| _
AB _
12 _
34 _
_
_
##gray|//pandoc extensions://## _
A@< >@B _
@@–@@ @@–@@ _
1@< >@2 _
3@< >@4 _
_
##gray|//pandoc extension://## _
@@+—+—+@@ _
| A | B | _
@@+—+—+@@ _
| 1 | 2 | _
@@+—+—+@@ _
| 3 | 4 | _
@@+—+—+@@||@@== ==@@ _
A@< >@B _
@@== ==@@ _
1@< >@2 _
3@< >@4 _
@@== ==@@ _
_
@@+—+—+@@ _
| A | B | _
@@+===+===+@@ _
| 1 | 2 | _
@@+—+—+@@ _
| 3 | 4 | _
@@+—+—+@@||{|border="1” _
!A!!B _
|- _
|1@@||@@2 _
|- _
|3@@||@@4 _
|} _
_
##gray|//one cell per row of markup://## _
{|border="1” _
!A _
!B _
|- _
|1 _
|2 _
|- _
|3 _
|4 _
|}||[width="20%”, options="header”] _
|=== _
|A|B _
|1|2 _
|3|4 _
|===||@@|@@A|B| _
|-+-| _
|1|2| _
|3|4@@|@@||
||multiple column cell|| _
title _
12 _
||@@+——-+@@ _
| title | _
+===+===+ _
| 1 | 2 | _
@@+—+—+@@||{|border="1” _
!colspan="2”|title _
|- _
@@|1||2@@ _
|}||[width="20%”, options="header”] _
|=== _
2+|title _
|1|2 _
|===|| ||
||cell alignment|| _
left _
center _
right _
|| ||{|border="1” _
@@|align="left”|left@@ _
@@|align="center”|center@@ _
@@|align="right”|right@@ _
|}|| || ||
||pre-formatted fixed-width block with no need to escape markup or < and &||##gray|//set off from surrounding blocks with blank lines and indent each line at least 4 spaces://## _
_
@< >@int add(int a, int b) { _
@< >@@< >@return (a+b); _
@< >@} _
@< >@ _
_
##gray|//pandoc [#pandoc-delimited-code-block delimited code block] uses 3 or more tildes or backticks://## _
~~~ _
int add(int a, int b) { _
@< >@return (a+b); _
} _
~~~||##gray|//If the preceding paragraph ends with two colons, it renders as a single colon. Two colons on a line by themselves are removed. Preformatted text is indented.//## _
:: _
_
@< >@int add(int a, int b) { _
@< >@@< >@return (a+b); _
@< >@}|| _
int add(int a, int b) { _
@< >@return (a+b); _
} _
||@@—-@@ _
int add(int a, int b) { _
@< >@return (a+b); _
} _
@@—-@@||#+BEGIN_EXAMPLE _
int add(int a, int b) { _
return (a+b); _
} _
#+END_EXAMPLE||
||highlighted code||##gray|//pandoc extension://## _
~~~c _
int add(int a, int b) { _
@< >@return (a+b); _
} _
~~~||##gray|//Adds classes, but a style sheet is necessary to get the colors://## _
.. code-block:: c _
_
@< >@int add(int a, int b) { _
@< >@@< >@return (a+b); _
@< >@}|| _
int add(int a, int b) { _
@< >@return (a+b); _
} _
||##gray|source-hightlight //must be installed://## _
[source,c] _
@@—-@@ _
int add(int a, int b) { _
@< >@return (a+b); _
} _
@@—-@@|| ||
||languages which can be highlighted||##gray|//lists the supported languages://## _
$ pandoc @@–@@version||$ pygmentize -L lexers ||[http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi 100+ languages]||[http://www.gnu.org/software/src-highlite/source-highlight.html#Supported-languages 150+ languages]|| ||
||latex math||##gray|//pandoc extension://## _
_
$ \int_0^\pi \cos (x) dx $||.. math:: _
_
\int0^\pi \cos (x) dx||\int0^\pi \cos (x) dx|| || ||
||~ ##EFEFEF|@@_____________@@##||~ ##EFEFEF|@@________________________________________@@##||~ ##EFEFEF|@@_____________________________________@@##||~ ##EFEFEF|@@_____________________________________@@##||~ ##EFEFEF|@@_____________________________________@@##||~ ##EFEFEF|@@________________________________________@@##||
# markdown + [#top Markdown]
[http://daringfireball.net/projects/markdown/syntax Markdown]
Markdown was developed in 2004, initially in Perl. It is used by Tumblr, Stackoverflow, GitHub, and Reddit. Here is a [http://daringfireball.net/projects/markdown/dingus sandbox].
On Ubuntu you can install a script which converts Markdown to HTML with the following command:
code sudo apt install markdown /code
The command line script converts Markdown to HTML. Invoke it like this:
code $ markdown foo.md > foo.html /code
# pandoc + [#top Pandoc]
[http://johnmacfarlane.net/pandoc/README.html Pandoc User’s Guide] [http://johnmacfarlane.net/pandoc/README.html#pandocs-markdown Pandoc’s Markdown]
There are installers for [http://code.google.com/p/pandoc/downloads/list Windows and Mac]. On Ubuntu Pandoc can be installed with
code sudo apt install pandoc /code
Pandoc can read Markdown, LaTeX, HTML, and a few other formats. It can output HTML, RTF, MediaWiki Syntax, groff man page format, Emacs Org-Mode, AsciiDoc, EPub, GNU Texinfo, Word docx, Slidy, and some other formats.
Pandoc’s version of Markdown has extensions. Using the extensions avoids HTML and makes it easier for Pandoc to target other formats.
Converting Markdown to HTML:
code $ pandoc foo.txt -o foo.html /code
Converting HTML to Markdown:
code pandoc -s -r html http://hyperpolyglot.org/lightweight-markup -o lightweight-markup.txt /code
++ pdf from markdown
//A tool such as pdflatex must be in the search path://
code $ pandoc foo.txt -o foo.pdf /code
++ epub from markdown
code $ pandoc foo.txt -o foo.epub /code
++ word document from markdown
code $ pandoc foo.txt -o foo.docx /code
++ man page from markdown
[http://manpages.ubuntu.com/manpages/precise/man7/groff_man.7.html groff_man(7)] ##gray|(ubuntu.com)##
The markup used for man pages is described in groff_man(7).
code $ cat > foo.1.md % FOO(1) Foo User Manual % John Smith % November 8, 2012
NAME
foo - a command line tool
SYNOPSIS
foo [file]…
DESCRIPTION
Foo performs an operation on files specified on the command line. If no files are specified the operation is performed on stdin.
SEE ALSO
bar (1).
$ pandoc -s -w man foo.1.md -o foo.1 /code
++ slideshow from markdown
code $ cat > gnomes.txt
Business Plan
- collect underpants
- ?
- profit
Phase 1: Collect Underpants
3:30 AM is the optimal time.
Phase 2: ?
Details TBD
Phase 3: Profit
Financial results will be discussed in the earnings call.
$ pandoc gnomes.txt -s –webtex -i -t slidy -o gnomes.html /code
# restructured-text + [#top reStructuredText]
[http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html reStructuredText Markup Specification]
//pydoc// and //rst2html5//
code $ sudo pip install sphinx /code
# mediawiki + [#top MediaWiki]
[http://www.mediawiki.org/wiki/Help:Formatting MediaWiki Syntax]
MediaWiki powers Wikipedia. The source code is freely available.
Wikipedia was launched in January 2001. The site initially used wiki software implemented in Perl called UseModWiki. In January 2002 the site switched to custom software written in PHP. The PHP code was rewritten for scalability in July 2002. It was given the name MediaWiki in 2003 and was eventually open sourced.
UseModWiki had a spare set of markup which did not expand much on the markup used by Wiki Base, the original wiki software used by WikiWikiWeb.
||~ ||~ http://c2.com/cgi/wiki?TextFormattingRules Wiki Base||~ http://www.usemod.com/cgi-bin/wiki.pl?TextFormattingRules UseModWiki||~ MediaWiki (2002)||~ Markdown (2004)|| ||##darkblue|link##||CamelCase||CamelCase _ @@Double Bracket@@||@@Double Bracket@@||Single Bracket|| ||//italic//||’’italic’’||’’italic’’||’’italic’’||italic|| ||bold||’’’bold’’’||’’’bold’’’||’’’bold’’’||@@bold@@|| ||horizontal rule||@@—-@@||@@—-@@||@@—-@@||@@—@@|| ||top level header||##gray|//none//##||##gray|//none//##||=top level header=||# top level header|| ||second level header||##gray|//none//##||##gray|//none//##||==second level header==||## second level header|| ||bullet list item||* list item||* list item||* list item||* list item|| ||numbered list item||##gray|//none//##||# list item||# list item||1. list item|| ||image||##gray|//can be URL://## _ foo.jpg||##gray|//can be URL://## _ foo.jpg||@@File:foo.jpg@@ _ ##gray|//MediaWiki permits raw URL images _ like its predecessors but the feature _ is turned off on Wikipedia//##|||| ||table||##gray|//none//##||##gray|//added in 2003://## _ @@||A||B||@@ _ @@||1||2||@@||{| _ !A!!B _ |- _ |1@@||@@2 _ |}|| _ AB _ 12 _ ||
For those who like to experiment, here are sandboxes for [http://c2.com/cgi/wiki?WikiWikiSandbox Wiki Base] and [http://www.usemod.com/cgi-bin/wiki.pl?SandBox UseModWiki].
In Wiki Base the way to prevent a camel case word from becoming a link was to insert six single quotes into the word like this: C’’’’’’amelCase. The odd markup was not intentional. The six single quotes actually parse as a bold empty string.
UseModWiki had a feature called “free links” which was attractive to the founders of Wikipedia. It permitted page titles to have spaces, commas, periods, or hyphens in them. These pages could be linked with double brackets: e.g. @@Los Angeles@@. In the URL the spaces are replaced with underscores. UseModWiki is case insensitive but MediaWiki is case sensitive except for the first letter.
# asciidoc + [#top AsciiDoc]
[http://www.methods.co.nz/asciidoc/userguide.html AsciiDoc User Guide] [http://www.w3.org/Talks/Tools/Slidy2/#(1) HTML Slidy: Slide Shows in HTML and XHTML]
AsciiDoc can be installed by a variety of package managers. On Ubuntu:
code sudo apt install asciidoc /code
On a Mac with MacPorts:
code sudo port install asciidoc /code
AsciiDoc documents have a {{.txt}} suffix by default. The following command will create a file called {{foo.html}}:
++ slideshow
code $ asciidoc -b slidy foo.txt /code
# org-mode + [#top Org-mode]
[http://orgmode.org/org.html The Org Manual]