Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the footnote backlink glyph to be changed #247

Closed
bdesham opened this issue Apr 24, 2015 · 21 comments
Closed

Allow the footnote backlink glyph to be changed #247

bdesham opened this issue Apr 24, 2015 · 21 comments
Assignees
Labels

Comments

@bdesham
Copy link

@bdesham bdesham commented Apr 24, 2015

Kramdown uses “” (U+21A9) to link from footnotes back to the main text. Under OS X 10.10.3 and iOS 8.3, though, this character appears in Emoji form (↩️, if your browser supports it). Like John Gruber, I’d like to replace the bare U+21A9 with the two-character sequence U+21A9 U+FE0E, which will force it to render in “text style”. (That’s what I did in the the first sentence of this paragraph.)

Would it be possible to add a configuration option so that kramdown uses ↩︎ as its footnote backlink “character”? Alternately, it might make sense just to make this sequence the default; I’d guess that more people prefer the old style symbol to the emoji symbol.

(This feature request is copied from this Stack Overflow question.)

@gettalong gettalong self-assigned this Apr 24, 2015
@bdesham
Copy link
Author

@bdesham bdesham commented Apr 24, 2015

If you want to go the “change the symbol by default” route, pull request #248 does that.

Loading

@gettalong
Copy link
Owner

@gettalong gettalong commented Apr 24, 2015

I'm sorry that Apple decided to do some bad things. However, if I follow the reasoning I would need to replace, for example, the digit "2" with the sequence "\u0032\uFE0E" because Apple might decide to display the "2" character as emoji... See http://www.unicode.org/Public/UCD/latest/ucd/StandardizedVariants.html

So your reasoning for introducing a new option doesn't quite convince me. If Apple introduced the bug, it should fix it.

However, since this is a real problem for you at this moment, you can change the default output of the HTML converter in one of two ways:

  • Post-process the output, which in your use case would look like Kramdown::Document.new(text).to_html.gsub(/\u21a9/, "\u21a9\ufe0e")
  • Create a new custom HTML converter that creates the HTML output you want by default.

Loading

@gettalong
Copy link
Owner

@gettalong gettalong commented Apr 24, 2015

Btw. this is how it is supposed to look like in my opinion, ie. the standard codepoint rendered normally and the one with the emoji variant rendered as emoji (browser is Firefox):

screenshot from 2015-04-24 17 16 45

Loading

@bdesham
Copy link
Author

@bdesham bdesham commented Apr 24, 2015

I agree that the non-emoji form should be the default for symbols that were present in Unicode before emoji were added. My feature request was pragmatic, not idealistic 😄

Loading

@ole
Copy link

@ole ole commented Jun 21, 2015

I’d just like to add my vote to this request. I understand @gettalong’s reasoning to blame Apple for this and to not change the default, but beside the variation selector I imagine there are many valid reasons why someone would like to change the string that is used as the footnote backlink. For example, someone might not like the arrow symbol at all and prefer a text link like "Go back".

I’d love it if this was a configuration option.

Loading

@gettalong
Copy link
Owner

@gettalong gettalong commented Jun 21, 2015

The way to change the default HTML output of kramdown is to subclass the HTML converter and change what you need. If you are not directly using kramdown but via another library or application it is their job to provide output customizability.

If I provide an option for changing the footnote backlink, I would also need to provide other options for customizing other, static parts of the HTML output (or more correctly, if someone asked for such an option there would be no good reason not to implement it because of the precedent) - and these options can lead to performance penalties.

If I find a good way (I'm open for suggestions!) to handle such cases, this may change in the next major version.

Loading

@bdesham
Copy link
Author

@bdesham bdesham commented Jun 21, 2015

Are there really many other “static parts of the HTML output”? I mean, the vast majority of the HTML output is dictated by HTML’s syntactic and semantic constraints; the backlink indicator is the only one I can think of that’s more or less arbitrary.

(You could argue that we use ↩︎ out of convention, but in that case we should add the text-mode selector so that the display remains the same even as browsers change how they render things.)

Loading

@gettalong
Copy link
Owner

@gettalong gettalong commented Jun 22, 2015

@bdesham Actually, you are right, there aren't that many static parts - I should have looked at the code first (this is what happens when you don't work with your own code for some time ;-).

The only static parts are in the TOC and footnote output. So if we can agree that the overall output of those two can only be changed by subclassing and not by an option, we could add an option for the footnote backlink.

However, there is a big but: What should be allowed? I guess the option may just contain text, no formatting because otherwise there could be script injection problems. - Any thoughts?

Loading

@gettalong gettalong reopened this Jun 22, 2015
@ole
Copy link

@ole ole commented Jun 22, 2015

Sounds great to me (but I’m biased because I like the option to customize the footnote backlink). I also think text only for the content is a good strategy.

Loading

@bdesham
Copy link
Author

@bdesham bdesham commented Jun 22, 2015

Cool. I agree that restricting the backlink text to be text (no HTML tags) is a good idea. (I guess someone could conceivably want to use an image, either as an img or an svg, but special-casing those seems like it wouldn’t be worth the effort.)

Loading

@gettalong
Copy link
Owner

@gettalong gettalong commented Jul 1, 2015

Implemented and will be in the next version.

Loading

@gettalong gettalong closed this Jul 1, 2015
@ole
Copy link

@ole ole commented Jul 1, 2015

Awesome, thanks!

Loading

gettalong added a commit that referenced this issue Jul 1, 2015
This option allows changing the backlink used when generating
footnotes with the HTML converter.

Fixes #247, also see #261
@bdesham
Copy link
Author

@bdesham bdesham commented Jul 1, 2015

I’m happy to hear it! 👍

Loading

@kylebarbour
Copy link

@kylebarbour kylebarbour commented Jul 30, 2015

It would be nice to be able to suppress this altogether, e.g. with

    {::options footnote_backlink="" /}

or some such. At present, this sort of works, but it adds

    <a href="#fnref:NUMBER" class="reversefootnote"></a></p>

to everything. Not a huge deal, but thought I'd mention it.

Thank you!

Loading

@martynchamberlin
Copy link
Contributor

@martynchamberlin martynchamberlin commented Apr 3, 2016

I'm still not seeing the ability to change the back button. I think most of us would just like to keep it as it is but force Safari to not convert it to an emoji. It's also a shame Apple makes the emoji for this look like iOS 6-.

Any ideas when we'll have this feature in Kramdown?

Loading

@ole
Copy link

@ole ole commented Apr 4, 2016

@martynchamberlin The feature is definitely there. I’ve been using it successfully since August 2015. It looks like this in my Middleman config:

config[:markdown] = {
  :smartypants => true,
  :auto_ids => true,
  :footnote_backlink => "&#x21A9;&#xFE0E;"
}

Loading

@martynchamberlin
Copy link
Contributor

@martynchamberlin martynchamberlin commented Apr 4, 2016

Ah thank you @ole! I just had to add this to my _config.yml file:

kramdown:
  footnote_backlink: '&#8617;&#65038;'

Bingo. Emojis are gone from iOS now.

Loading

@fladd
Copy link

@fladd fladd commented Mar 11, 2017

Firefox on MacOS, as well as Android both render ↩︎ as (different) emoji. Is there a way to suppress emoji rendering on any device?

A screenshot from Firefox:
image

Loading

@martynchamberlin
Copy link
Contributor

@martynchamberlin martynchamberlin commented Mar 11, 2017

@fladd My code above should do the trick for you. Add this to your _config.yml file:

kramdown:
  footnote_backlink: '&#8617;&#65038;'

Visually it's exactly the same as ↩︎ on Chrome etc but it removes the emoji aspect on FF macOS etc.

Loading

@fladd
Copy link

@fladd fladd commented Mar 11, 2017

@martynchamberlin The problem is that MacOS and Android ignore the ︎ addition and always show the emoji.

Loading

@martynchamberlin
Copy link
Contributor

@martynchamberlin martynchamberlin commented Mar 11, 2017

Odd. Care to share a link? I'll take a look. My solution works for me.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants