Difference between revisions of "Convert text documents with Pandoc"
Jump to navigation
Jump to search
(Created page with "400px|right https://pandoc.org/ pandoc is a "universal document converter" which converts from one markup language to another. In this guide, we...") |
|||
Line 12: | Line 12: | ||
<pre>echo "<h1>Hello Pandoc</h1><p>from html to markdown</p>" | pandoc -f html -t markdown</pre> | <pre>echo "<h1>Hello Pandoc</h1><p>from html to markdown</p>" | pandoc -f html -t markdown</pre> | ||
=== | === Example 2: Convert a mediawiki file to HTML=== | ||
* Save the content of a wiki page on to a plain-text file, example: <code>page.wiki</code> | * Save the content of a wiki page on to a [[plain-text]] file, example: <code>page.wiki</code> | ||
* convert: | * convert: | ||
<pre>pandoc page.wiki -f mediawiki -t html -o page.html</pre> | <pre>pandoc page.wiki -f mediawiki -t html -o page.html</pre> | ||
=== Common pandoc arguments=== | === Common pandoc arguments=== |
Revision as of 13:30, 6 October 2021
pandoc is a "universal document converter" which converts from one markup language to another.
In this guide, we try converting downloaded wiki pages (plain text in the .wiki format) to HTML files.
More extensive documentation is available at Pandoc’s Manual or through the command line by typing
man pandoc
Example 1: Convert an HTML string to Markdown
echo "<h1>Hello Pandoc</h1><p>from html to markdown</p>" | pandoc -f html -t markdown
Example 2: Convert a mediawiki file to HTML
- Save the content of a wiki page on to a plain-text file, example:
page.wiki
- convert:
pandoc page.wiki -f mediawiki -t html -o page.html
Common pandoc arguments
-f - option standing for “from”, is followed by the input format;
-t - option standing for “to”, is followed by the output format;
-s - option standing for “standalone”, produces output with an appropriate header and footer;
-o - option for file output;
page.wiki - mediawiki input filename
Changing the default template
pandoc --from markdown --to html5 --print-default-template=html5 > template.html pandoc --from markdown --to html5 --template template.html input.md -o output.html