diff options
author | Mario Vavti <mario@mariovavti.com> | 2018-10-30 22:16:37 +0100 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2018-10-30 22:16:37 +0100 |
commit | c622ba84b9aadd4377ce5ea283121ac27726ea83 (patch) | |
tree | 6bf654cacf080a12c7b4151840d94a9db5e3d8c2 /include/markdown.php | |
parent | 0b371c8103b49a1bc9cde99fc13dabc330e9936c (diff) | |
download | volse-hubzilla-c622ba84b9aadd4377ce5ea283121ac27726ea83.tar.gz volse-hubzilla-c622ba84b9aadd4377ce5ea283121ac27726ea83.tar.bz2 volse-hubzilla-c622ba84b9aadd4377ce5ea283121ac27726ea83.zip |
really fix html2markdown() - when using environment, we must set the defaults
Diffstat (limited to 'include/markdown.php')
-rw-r--r-- | include/markdown.php | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/include/markdown.php b/include/markdown.php index 0947afeff..e7b57c3ee 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -288,10 +288,20 @@ function bb_to_markdown($Text, $options = []) { function html2markdown($html,$options = []) { $markdown = ''; - $internal_errors = libxml_use_internal_errors(true); + if(! $options) { + $options = [ + 'header_style' => 'setext', // Set to 'atx' to output H1 and H2 headers as # Header1 and ## Header2 + 'suppress_errors' => true, // Set to false to show warnings when loading malformed HTML + 'strip_tags' => false, // Set to true to strip tags that don't have markdown equivalents. N.B. Strips tags, not their content. Useful to clean MS Word HTML output. + 'bold_style' => '**', // DEPRECATED: Set to '__' if you prefer the underlined style + 'italic_style' => '*', // DEPRECATED: Set to '_' if you prefer the underlined style + 'remove_nodes' => '', // space-separated list of dom nodes that should be removed. example: 'meta style script' + 'hard_break' => false, // Set to true to turn <br> into `\n` instead of ` \n` + 'list_item_style' => '-', // Set the default character for each <li> in a <ul>. Can be '-', '*', or '+' + ]; + } - $environment = new Environment($options); - $environment->createDefaultEnvironment(); + $environment = Environment::createDefaultEnvironment($options); $environment->addConverter(new TableConverter()); $converter = new HtmlConverter($environment); @@ -301,8 +311,6 @@ function html2markdown($html,$options = []) { logger("Invalid HTML. HTMLToMarkdown library threw an exception."); } - libxml_use_internal_errors($internal_errors); - return $markdown; } |