Skip to content

feature: Render footnotes #241

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

Closed
einarpersson opened this issue Nov 27, 2024 · 4 comments
Closed

feature: Render footnotes #241

einarpersson opened this issue Nov 27, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@einarpersson
Copy link

Is your feature request related to a problem? Please describe.

I use footnotes in my notes and it would be nice if it would be rendered by this wonderful plugin.

To quote this post:

For a little while now I’ve been using footnotes in Obsidian. I think they’re a bit of a “hidden feature”. They’re in the documentation, but for some reason I rarely see people use them.
...
[using footnotes] allows your ideas to flow out of you more naturally, and you don’t have to worry about restructuring your note to fit previous modes of thought.

Also note that Github now supports footnotes in their markdown, so this is not "just Obsidian".

It would be a great addition imho which shouldn't be too hard to implement, I think?

Thanks again for a great plugin!

Describe the solution you'd like

Sam[^1] is almost two years old.

## Footnotes
[^1]: Sam is my son 

should be rendered as

Sam⁽¹⁾ is almost two years old.

## Footnotes
⁽¹⁾: Sam is my son 

Paranthesis have to be used instead of brackets as (to my knowledge) you can't use brackets in superscript utf8 (or?). But I think paranthesis are alright.

Describe alternatives you've considered

Just having it as is.

Additional information

  • Perhaps there are some configuration options, but as a first step I propose just implementing the above.

  • Note that the main obstacle with footnotes is creating / formatting / maintaining them, but this is not the scope of this plugin. There are other plugins that can help with that.

  • Note: Only caret symbols [^....] should be rendered this way, as to not interfer with other things

@einarpersson einarpersson added the enhancement New feature or request label Nov 27, 2024
MeanderingProgrammer added a commit that referenced this issue Nov 27, 2024
## Details

Request: #241

When the contents of a link starts with the ^ symbol we'll now assume
this is related to a footnote. When the footnote pattern is spotted we
replace the link contents with a superscript equivalent when possible.
There are some interesting gaps in the superscript glyphs, I do not know
why they exist, but they exist for parens, 0-9, most of a-z, and also
most of A-Z but both character sets have at least one missing glyph.

This behavior can be disabled by setting `link.footnote.superscript` to `false`.

Since the translation between base character and superscript is not
based on a shared offset or anything easy like that we maintain a
complete mapping of base character to superscript. If there are any
missing characters in the mapping then we skip doing any sort of
superscript rendering.
@MeanderingProgrammer
Copy link
Owner

Thank you for the kind words, glad you are enjoying the plugin!

Added this feature here: 634acd5

LMK if this is what you had in mind!

@einarpersson
Copy link
Author

That was quick! Yes that was what I was asking for. Thanks a lot!

@einarpersson
Copy link
Author

einarpersson commented Nov 28, 2024

Hi - sorry for reopening this. It works well, but after playing around with it a bit I'm wondering, if it is not too much hassle, if you could either remove the paranthesis or add a config / option for that. The paranthesis adds unnecessary spacing which I guess is due to monospace font.

image

Just having the superscript would also make it less noisy

MeanderingProgrammer added a commit that referenced this issue Dec 1, 2024
## Details

Request: #241

Rather than surrounding footnotes in parenthesis by default the prefix
and suffix are now configurable properties. The default behavior has
changed in that nothing is added by default. To get the previous behavior
users can set the following:

```lua
require('render-markdown').setup({
    link = {
        footnote = { prefix = '(', suffix = ')' },
    },
})
```
@MeanderingProgrammer
Copy link
Owner

MeanderingProgrammer commented Dec 1, 2024

Sure, updated the behavior here: 1b5d117

The prefix and suffix are now configurable for footnotes. By default both are set to the empty string. I agree that monospaced fonts make the superscripts look strange in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants