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

Insert   before footnote numbers #96

Closed
kaushalmodi opened this issue Nov 3, 2017 · 8 comments
Closed

Insert   before footnote numbers #96

kaushalmodi opened this issue Nov 3, 2017 · 8 comments

Comments

@kaushalmodi
Copy link
Owner

This is a cool feature someone thought of on the Hugo discourse forum. Should be easy to implement.


https://discourse.gohugo.io/t/is-it-possible-to-enforce-the-footnote-number-to-render-on-same-line-as-preceding-symbol/9085

For the following markdown:

A line with a footnote.[^target]

[^target]: The footnote text

, depending on the line width, the period may be rendered at the end of a line and the footnote >number on the next line.

One solution to keep the footnote number on the same line as the period is to manually insert a span >with no-wrapping whitespace:

A line with a <span style="with-space: nowrap">footnote.[^terminal]</span>

[^target]: The footnote text

Probably, would be simple to always insert &nbsp; before the footnote number if it ends up at EOL.

@kaushalmodi
Copy link
Owner Author

Ideally should be fixed in blackfriday: russross/blackfriday#405

@kaushalmodi
Copy link
Owner Author

OK, need to make that regexp less strict.. the footnote ref could even be in the middle of the line, and depending on the screen width, we could end up with that footnote ref at the BOL of the next line.. So, need to always make the footnote ref stick to the word before it using &nbsp;.

@kamar535
Copy link

kamar535 commented Nov 7, 2017

Sorry for causing any trouble. It turned out this was only an issue with a specific Hugo theme, see https://discourse.gohugo.io/t/is-it-possible-to-enforce-the-footnote-number-to-render-on-same-line-as-preceding-symbol/9085/14

@kaushalmodi
Copy link
Owner Author

@kamar535 No trouble at all. Your question helped me add a new feature to ox-hugo :)

@kamar535
Copy link

kamar535 commented Nov 7, 2017

@kaushalmodi But the feature is not needed since it was a mere CSS issue and inserting a &nbsp; serves no purpose.

@kaushalmodi
Copy link
Owner Author

kaushalmodi commented Nov 7, 2017

No, the issue is real.

Paste the below in your markdown file:

a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a [^fn:1] . B b b.

ab a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a [^fn:1] . B b b.

abc a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a [^fn:1] . B b b.
abcd a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a [^fn:1] . B b b.

abcde a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a [^fn:1] . B b b.


[^fn:1]: First footnote

and then change the browser window width so that the footnote ref wraps to the next line.. you will see the problem.

image


Fix

Here's the fixed version of that that ox-hugo creates:

a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a&nbsp;[^fn:1]. B b b.

ab a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a&nbsp;[^fn:1]. B b b.

abc a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a&nbsp;[^fn:1]. B b b.
abcd a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a&nbsp;[^fn:1]. B b b.

abcde a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a a
a a a&nbsp;[^fn:1]. B b b.


[^fn:1]: First footnote

Now try the same with the fixed version.

Here's what it looks after that fix:

image

@kamar535
Copy link

kamar535 commented Nov 7, 2017

Aha. By habit I never put any white space before any [^fn] I either do foo bar[^fn:1] baz., foo bar baz.[^fn:1] so I never thought about it is an issue. But yes, this might actually be handy in the cases where there is white space before the [^fn:n].

@kaushalmodi
Copy link
Owner Author

Agree. I also never put a space before the fn ref or the period. But reading your question there made me think of all the pathological cases that could result in the wrapping to happen in that unwanted manner. As I am developing this package for mass consumption, I might as well not leave any room for surprises :).

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

No branches or pull requests

2 participants