vaetas / hugo-footnotes-popup

Pure JavaScript plugin to make your footnotes displayed in a panel. Works with footnotes generated from Markdown in Hugo.
https://www.vaetas.cz/posts/hugo-footnotes-popup/
MIT License
25 stars 3 forks source link

‘substring(6,7)’ ? #5

Closed tflo closed 5 years ago

tflo commented 5 years ago

With const index = node.id.substring(6,7); you are just getting the first character of the string.

It happens that I name my footnotes by something semantically more expressive, like for example [^usage] (instead of [^1]).

In these cases your substring implementation will fail. (And also if you have numerical footnote numbers > 9).

So, why not change it to…

const index = node.id.substring(6);

This would take all characters, starting at position 6, but not limited to position 6.

As already said in the other issue post, I’m a JS-ignorant, so, please let me know if/why this would be no good.

vaetas commented 5 years ago

Hello Tom, sorry for late reply, I was busy recently.

You are completely right, current implementation will fail on your given footnotes. It's shame I completely forgot to test these cases.

I will update the code right now. I hope, however, it will not break anything else.

tflo commented 5 years ago

I hope, however, it will not break anything else.

So far, it works fine for me with these types of footnotes:

– Tom