Questions answered by this recipe
- How can I generate "pretty" plain text from a wiki page?
MarkdownOutput uses Milian Wolff's Markdownify HTML to Markdown converter to convert a page's HTML to the Markdown syntax.
As an example, take a look at what this page (
Cookbook.MarkdownOutput) looks likeΔ in Markdown.
To install this recipe:
- download markdown-output.zipΔ and extract it to your cookbook directory
- you should end up with a folder named 'markdown-output'
- add the following line to your config file:
- To test, use the provided action "
markdown" to view a page of your wiki (by adding
?action=markdownto the end of the page's url)
The following variables may be set in your config file to configure the way MarkdownOutput works. The values shown are the defaults and the descriptions are mostly taken from Milian Wolff's page.
- Support for PHP Markdown Extra output, which implements some features currently not available with the plain Markdown syntax (tables, definition lists, etc.).
- A boolean which decides whether link definitions shall be displayed after each block element.
- An integer or
FALSEand sets the width to which the outputted Markdown text shall be wordwrapped. This feature is not yet finished!
- A boolean which tells Markdownify whether to keep non-markdownable HTML tags or to discard them.
- [NEW] A boolean which tells Markdownify how to handle non-markdownable HTML attributes. If set to TRUE, the tag (if it is itself markdownable) is processed as normal, and the attributes discarded. If set to FALSE, the tag is not processed, and is left as HTML.
?action=markdown to the end of the url of the page you wish to see in Markdown format.
MarkdownOutput first parses the page's wikimarkup into HTML, then passes it to Markdownify to convert to Markdown. All of the page permissions,
(:if:) statements and everything else is processed as normal. Only the actual page contents are included in the output.
If you have any comments or criticisms about how the output is formatted, you should direct those to Markdownify's author -- MarkdownOutput is really just a shell.
- 2020-08-12 - added
$MarkdownIgnoreForeignAttributesconfig variable —Said Achmiz
- 2017-12-22 - updated to newest version of Markdownify
- 2008-02-15-2 - change handling of page title to now actually check
$TmplDisplay['PageTitleFmt']instead of looking for
(:notitle:)in page markup
- 2008-02-15 - now includes PHP Markdown extra syntax additions by default
- 2008-02-14 - first release
- Jan Erik Moström's post on the pmwiki-users list that started this idea
- Milian Wolff's Markdownify
- Markdown syntax documentation
- PHP Markdown Extra additions to plain Markdown syntax
See discussion at MarkdownOutput-Talk
User notes? : If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.