Skip to content

Commit

Permalink
By default balance tags before HTML is converted to markdown. (Adds f…
Browse files Browse the repository at this point in the history
…ilter to prevent this behaviour). Ref #47.
  • Loading branch information
stephenharris committed May 27, 2014
1 parent 2fa8a24 commit afd2964
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions wp-markdown.php
Expand Up @@ -519,13 +519,22 @@ function admin_footers_script(){


/**
* Converts HTML into markdown
* Converts HTML into markdown.
*
* @param string $html
* @return string markdown
* Optionally you can specify where it should first balance the tags in the
* given HTML {@see balanceTags}.
*
* @uses balanceTags
* @param string $html The HTML to convert to markdown
* @param bool $balance_tags If true, balances HTML tags. Default true.
* @return string The generated markdown
*/
function wpmarkdown_html_to_markdown( $html ){
function wpmarkdown_html_to_markdown( $html, $balance_tags = true ){
$md = new Markdownify_Extra;
$balance_tags = apply_filters( 'wp_markdown_balance_tags', $balance_tags );
if( $balance_tags ){
$html = force_balance_tags( $html );
}
$markdown = $md->parseString( $html );
return $markdown;
}
Expand Down

0 comments on commit afd2964

Please sign in to comment.