-
-
Notifications
You must be signed in to change notification settings - Fork 8k
markup/goldmark: Enhance footnote extension with auto-prefixing option #13982
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
markup/goldmark: Enhance footnote extension with auto-prefixing option #13982
Conversation
I was initially concerned that the footnote links would change if the page path changed, as the document ID is derived from it. However, I realized this is already the case whenever you insert a new footnote before an existing one—the numbering shifts, and the links change. Given that content changes are much more frequent than path changes, I believe this is an acceptable trade-off. And how often does one link to a footnote in another document? Never, or close to it. |
I have never seen it. |
I have verified that this is true and will add some test cases. |
I have done this, and everything works fine, but having two IDs in the var id string
var filename string
var path string
if p.f != nil {
id = p.f.UniqueID()
filename = p.f.Filename()
path = p.f.Path()
} else {
path = p.Path()
}
cpp, err := cp.New(
converter.DocumentContext{
Document: doc,
DocumentLookup: documentLookup,
DocumentID: id,
DocumentName: path,
Filename: filename,
},
) to this var filename string
var path string
if p.f != nil {
filename = p.f.Filename()
path = p.f.Path()
} else {
path = p.Path()
}
cpp, err := cp.New(
converter.DocumentContext{
Document: doc,
DocumentLookup: documentLookup,
DocumentID: hashing.XxHashFromStringHexEncoded(p.Path()),
DocumentName: path,
Filename: filename,
},
) As you noted, |
b114129
to
ea6c4d5
Compare
@bep Please see my previous comment when you have a moment. |
Yes, that was how I imagined it in tthe first place, so please do. |
3810ab9
to
affacb2
Compare
This commit introduces a new option, enableAutoIDPrefix, to the Goldmark footnote extension. When enabled, it prepends a unique prefix to footnote IDs, preventing clashes when multiple documents are rendered together. This prefix is unique to each logical path, which means that the prefix is not unique across content dimensions such as language. This change also refactors the extension's configuration from a boolean to a struct. Closes gohugoio#8045
affacb2
to
a5e2a38
Compare
This commit introduces a new option,
enableAutoIDPrefix
, to the Goldmark footnote extension. When enabled, it prepends a unique prefix to footnote IDs, preventing clashes when multiple documents are rendered together. This prefix is unique to each logical path, which means that the prefix is not unique across content dimensions such as language. This change also refactors the extension's configuration from a boolean to a struct.Closes #8045