gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.27k stars 10.32k forks source link

Change footnotes rendering from Markdown #13092

Closed markvital closed 4 years ago

markvital commented 5 years ago

I'm using footnotes in Markdown [^1], [^2] etc..

I would like to change back arrow style for each individual footnote from ↩to ^, and postition so it displays at the beginning of the line (example 2), just like on Wikipedia:

Screen Shot 2019-04-03 at 8 23 35 PM

Currently gatsby-transformer-remark produces the following HTML:

<li id="fn-1">
  <p><a href="http://hint.fm/papers/pivotgraph.pdf">Lorem ipsum dolor sit amet</a></p>
  <a href="#fnref-1" class="footnote-backref">↩</a>
</li>

Is there a way to change this HTML, so .footnote-backref is positioned in the beginning of the paragraph?

pieh commented 5 years ago

It seems like we are not doing this directly in gatsby code - it's hardcoded in one of dependency of remark transformer - https://github.com/syntax-tree/mdast-util-to-hast/blob/master/lib/footer.js#L27-L32

You probably can adjust this with css (pretty hacky) to hide auto generated one and prepend ^ with :before pseudo element. But if you would prefer nicer/cleaner solution - you could create remark plugin to modify markdown AST yourself before linked package handle this

markvital commented 5 years ago

@pieh thank you. I've managed to position it at the end of the paragraph with CSS and will use your pseudo element solution for now.

It would be great to have footnotes setting in base Gatsby configuration.

gatsbot[bot] commented 5 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

Thanks for being a part of the Gatsby community! 💪💜

jamessimone commented 5 years ago

@markvital I saw this issue a while back and got interested in creating a fix. At this point I'm fairly satisfied with the functionality. Let me know what you think!

stevanpopo commented 5 years ago

Just the solution I was after. Thanks @jamessimone.

jamessimone commented 5 years ago

@stevanpopo no problem!

markvital commented 5 years ago

@jamessimone sorry, somehow I missed this message. Thank you, the fix is very handy! It saved me a lot of time.

One thing would be great to have is to be able to change position where generated footnotes appear. Right now it can only appear at the bottom of the article and this could be very annoying if you have complex footnotes structure like wikipedia. Let me give you an example:

My footnote section has two sub-sections, like in Wikipedia, linked footnotes and further reading. I want Further Reader to appear below Footnotes. Right now this is not possible. Here is a screenshot which illustrates what I am talking about:

Screen Shot 2019-09-09 at 6 40 18 PM

My markdown looks like this now:

## Sources

### Further Reading
1. Potter, Kristin, et al. ["Methods for presenting statistical information: The box plot."]((http://www.sci.utah.edu/~kpotter/publications/potter-2006-MPSI.pdf)) Visualization of large and unstructured data sets 4 (2006): 97-106, p.100.

### References
[^wickham]: Wickham, Hadley, and Lisa Stryjewski. ["40 years of boxplots."](http://vita.had.co.nz/papers/boxplots.pdf) *Am. Statistician* (2011). [PDF](http://vita.had.co.nz/papers/boxplots.pdf)
[^kampstra]: Kampstra, Peter. ["Beanplot: A boxplot alternative for visual comparison of distributions."](http://dare.ubvu.vu.nl/bitstream/handle/1871/39954/221014.pdf) (2008) p.4. [PDF](http://dare.ubvu.vu.nl/bitstream/handle/1871/39954/221014.pdf)
[^esty]: Esty, Warren W., and Jeffery D. Banfield. ["The box-percentile plot."](http://dx.doi.org/10.18637/jss.v008.i17) *Journal of Statistical Software* 8.17 (2003): 1-14.
[^mcgill]: McGill, Robert, John W. Tukey, and Wayne A. Larsen. ["Variations of box plots."](https://www.tandfonline.com/doi/abs/10.1080/00031305.1978.10479236) *The American Statistician* 32.1 (1978): 12-16.
[^hofmann]: Hofmann, Heike, Hadley Wickham, and Karen Kafadar. ["Value plots: Boxplots for large data."](https://vita.had.co.nz/papers/letter-value-plot.pdf) *Journal of Computational and Graphical Statistics* 26.3 (2017): 469-477.
[^tukey]: Cleveland, William S. *The Collected Works of John W. Tukey: Graphics 1965-1985.* Vol. 5. CRC Press, 1988, p.69. (https://books.google.com/books?id=z_F5Tyt66c0C)
[^hyndman]: Hyndman, Rob J. "Computing and graphing highest density regions." *The American Statistician* 50.2 (1996): 120-126.

I can not change "Further Reading" and "References, otherwise it will look broken

jamessimone commented 5 years ago

@markvital excellent, thank you for the detailed explanation and response. Let me think a little bit about how to arrange the plugin options so as to best meet your use case. I will get back to you in the coming days!

gatsbot[bot] commented 5 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

github-actions[bot] commented 4 years ago

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open! As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

markvital commented 4 years ago

@markvital excellent, thank you for the detailed explanation and response. Let me think a little bit about how to arrange the plugin options so as to best meet your use case. I will get back to you in the coming days!

@jamessimone Is there any update on this?

jamessimone commented 4 years ago

@markvital I don't have an update for you, unfortunately. I have been bogged down by other work and the issue is larger than I had originally anticipated because of the way the AST tree is produced for markdown - each node has a column/line reference for where it should be rendered in relation to the nodes both before and after it. I was unable to gracefully figure out a way to move the footnote markdown below another section. I still have a branch open for it in my plugin, but have been bogged down with contracting work the past few months. It may be that I have time later this month to re-open this issue. I would ask that you paste the contents of your remark from September 9th in a bug on my repo so that I can continue to track this.

markvital commented 4 years ago

@markvital I don't have an update for you, unfortunately. I have been bogged down by other work and the issue is larger than I had originally anticipated because of the way the AST tree is produced for markdown - each node has a column/line reference for where it should be rendered in relation to the nodes both before and after it. I was unable to gracefully figure out a way to move the footnote markdown below another section. I still have a branch open for it in my plugin, but have been bogged down with contracting work the past few months. It may be that I have time later this month to re-open this issue. I would ask that you paste the contents of your remark from September 9th in a bug on my repo so that I can continue to track this.

OK, pasted here