You appear to be a bot. Output may be restricted
Description
Format a markdown lineThe line may not end in a blank so we append one to make up for the new line character we've stripped off. Now we have to decide about this esc_html() call. There's no point doing it if we're about to add some HTML so obviously we need to esc_html() first then apply the markdown
Wrapper | Becomes |
---|---|
_ | em |
* | em |
__ | strong |
** | strong |
` | code |
{@link xxx } | [bw_link xxx] |
{@see xxx } | [hook .] |
Usage
$string = oikai_format_markdown_line( $line, $echo );
Parameters
- $line
- ( string ) required –
- $echo
- ( bool ) optional default: 1 – whether or not to echo the line
Returns
string the markdown formatted lineSource
File name: oik-shortcodes/shortcodes/oik-api-importer.phpLines:
1 to 19 of 19
function oikai_format_markdown_line( $line, $echo = true ) { $line = str_replace( "[", "[", $line ); $line = paired_replacements( "{@see '", "'}", "[hook ", " .] ", $line ); //bw_trace2( $line, "line", false ); $line = esc_html( $line ); $line .= " "; $line = paired_replacements( "**", "** ", "<strong>", "</strong> ", $line ); $line = paired_replacements( " *", "* ", " <em>", "</em> ", $line ); $line = paired_replacements( "__", "__ ", "<strong>", "</strong> ", $line ); $line = paired_replacements( " _", "_ ", " <em>", "</em> ", $line ); $line = paired_replacements( " `", "` ", " <code>", "</code> ", $line ); $line = paired_replacements( "{@link ", "} ", "[bw_link ", "] ", $line ); bw_trace2( $line, "line", false, BW_TRACE_DEBUG ); $line = bw_do_shortcode( $line ); if ( $echo ) { e( $line ); } return $line; }View on GitHub