function MarkdownExtra_Parser::_appendFootnotes_callback in Markdown 6
Same name and namespace in other branches
- 5 markdown.php \MarkdownExtra_Parser::_appendFootnotes_callback()
File
- ./
markdown.php, line 3143
Class
Code
function _appendFootnotes_callback($matches) {
$node_id = $this->fn_id_prefix . $matches[1];
# Create footnote marker only if it has a corresponding footnote *and*
# the footnote hasn't been used by another marker.
if (isset($this->footnotes[$node_id])) {
$num =& $this->footnotes_numbers[$node_id];
if (!isset($num)) {
# Transfer footnote content to the ordered list and give it its
# number
$this->footnotes_ordered[$node_id] = $this->footnotes[$node_id];
$this->footnotes_ref_count[$node_id] = 1;
$num = $this->footnote_counter++;
$ref_count_mark = '';
}
else {
$ref_count_mark = $this->footnotes_ref_count[$node_id] += 1;
}
$attr = " rel=\"footnote\"";
if ($this->fn_link_class != "") {
$class = $this->fn_link_class;
$class = $this
->encodeAttribute($class);
$attr .= " class=\"{$class}\"";
}
if ($this->fn_link_title != "") {
$title = $this->fn_link_title;
$title = $this
->encodeAttribute($title);
$attr .= " title=\"{$title}\"";
}
$attr = str_replace("%%", $num, $attr);
$node_id = $this
->encodeAttribute($node_id);
return "<sup id=\"fnref{$ref_count_mark}:{$node_id}\">" . "<a href=\"#fn:{$node_id}\"{$attr}>{$num}</a>" . "</sup>";
}
return "[^" . $matches[1] . "]";
}