Allow custom content function for code span
Just like the option `$code_block_content_func`, but now for code-span. Can be used to prevent the default `htmlspecialchars` or do some kind of other logic to convert the code to html.
This commit is contained in:
parent
156e56ee03
commit
9fa8f87f20
1 changed files with 8 additions and 1 deletions
|
|
@ -67,6 +67,9 @@ class Markdown implements MarkdownInterface {
|
|||
|
||||
# Optional function for converting code block content to HTML
|
||||
public $code_block_content_func = null;
|
||||
|
||||
# Optional function for converting code span content to HTML.
|
||||
public $code_span_content_func = null;
|
||||
|
||||
# Class attribute to toggle "enhanced ordered list" behaviour
|
||||
# setting this to true will allow ordered lists to start from the index
|
||||
|
|
@ -1045,7 +1048,11 @@ class Markdown implements MarkdownInterface {
|
|||
#
|
||||
# Create a code span markup for $code. Called from handleSpanToken.
|
||||
#
|
||||
$code = htmlspecialchars(trim($code), ENT_NOQUOTES);
|
||||
if ($this->code_span_content_func) {
|
||||
$code = call_user_func($this->code_span_content_func, $code);
|
||||
} else {
|
||||
$code = htmlspecialchars(trim($code), ENT_NOQUOTES);
|
||||
}
|
||||
return $this->hashPart("<code>$code</code>");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue