MarkdownOutput

Summary: Presents a wiki page in Markdown format instead of HTML
Version: 2023-10-10
Prerequisites: PmWiki 2.2.0-beta series, untested on 2.1.27 and earlier
Status: beta
Maintainer:

Questions answered by this recipe

  • How can I generate "pretty" plain text from a wiki page?

Description

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:
    include_once("$FarmD/cookbook/markdown-output/markdown-output.php");
  • To test, use the provided action "markdown" to view a page of your wiki (by adding ?action=markdown to the end of the page's url)

Configuration

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.

$MarkdownExtra = TRUE;
Support for PHP Markdown Extra output, which implements some features currently not available with the plain Markdown syntax (tables, definition lists, etc.).
$MarkdownLinksAfterEachParagraph = FALSE;
A boolean which decides whether link definitions shall be displayed after each block element.
$MarkdownBodyWidth = FALSE;
An integer or FALSE and sets the width to which the outputted Markdown text shall be wordwrapped. This feature is not yet finished!
$MarkdownKeepHTML = FALSE;
A boolean which tells Markdownify whether to keep non-markdownable HTML tags or to discard them.
$MarkdownIgnoreForeignAttributes = FALSE;
[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.

Usage

Add ?action=markdown to the end of the url of the page you wish to see in Markdown format.

Notes

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.

Release Notes

  • 2023-10-10 - fixed bug due to hyperlinked images —Said Achmiz
  • 2020-08-12 - added $MarkdownIgnoreForeignAttributes config 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

See Also

Contributors

Comments

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.