Skip to content

Commit

Permalink
Made fn_backlink_text user-configurable, added U+FE0E to prevent iOS …
Browse files Browse the repository at this point in the history
…emoji display
  • Loading branch information
okdana committed Oct 16, 2015
1 parent 37a75bf commit e244a9e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Michelf/MarkdownExtra.php
Expand Up @@ -32,6 +32,12 @@ class MarkdownExtra extends \Michelf\Markdown {
public $fn_link_class = "footnote-ref";
public $fn_backlink_class = "footnote-backref";

# Text to be displayed within footnote backlinks. The default is '↩'; the
# U+FE0E on the end is a Unicode variant selector used to prevent iOS from
# displaying the arrow character as an emoji. Note: This value is inserted
# as raw HTML, so dangerous/special characters must be pre-escaped!
public $fn_backlink_text = '↩︎';

# Class name for table cell alignment (%% replaced left/center/right)
# For instance: 'go-%%' becomes 'go-left' or 'go-right' or 'go-center'
# If empty, the align attribute is used instead of a class name.
Expand Down Expand Up @@ -1475,6 +1481,7 @@ protected function appendFootnotes($text) {
$title = $this->encodeAttribute($title);
$attr .= " title=\"$title\"";
}
$backlink_text = $this->fn_backlink_text;
$num = 0;

while (!empty($this->footnotes_ordered)) {
Expand All @@ -1494,9 +1501,9 @@ protected function appendFootnotes($text) {
$note_id = $this->encodeAttribute($note_id);

# Prepare backlink, multiple backlinks if multiple references
$backlink = "<a href=\"#fnref:$note_id\"$attr>&#8617;</a>";
$backlink = "<a href=\"#fnref:$note_id\"$attr>$backlink_text</a>";
for ($ref_num = 2; $ref_num <= $ref_count; ++$ref_num) {
$backlink .= " <a href=\"#fnref$ref_num:$note_id\"$attr>&#8617;</a>";
$backlink .= " <a href=\"#fnref$ref_num:$note_id\"$attr>$backlink_text</a>";
}
# Add backlink to last paragraph; create new paragraph if needed.
if (preg_match('{</p>$}', $footnote)) {
Expand Down

0 comments on commit e244a9e

Please sign in to comment.