Hi,
I can’t get inline footnotes to work in DT 4.4.1 on Golden Gate 27.0.1.
Please see the screenshot below. The inset preview is of the same file in BBEdit, where the inline footnote does work.
The Help suggests that this should work, so is this a bug, or am I doing something wrong?
Thanks!
Just adding a space after inline and it will show up
1 Like
Thanks for the quick replies, @cgrunenberg and @gul-iMac!
That’s a bit of a shame because other editors (and Marked) do accept single-word inline footnotes (see the BBEdit preview in my screenshot) and I’ve never had to think about it before. Is this new behaviour with the (excellent) DT Markdown parser – I don’t recall it being a problem in earlier versions?
In any case, please could I ask for single-word inline footnotes to be catered for in a future version? (It’s a relatively minor point, I know, but it would be useful for compatibility with other editors.)
Thanks!
Thank you for the link. The issue seems to be that the reference (or Fletcher Penney’s own documentation) doesn’t define what to do with a single word inline reference – you’ll note that all their examples are for multiple words, which is not the same thing as requiring a space for a single word…
Marked, BBEdit, IA Writer, and others do allow the single word note, and until the recent introduction of DT’s own Markdown, so did DT (as far as I remember…). I have over 16,000 markdown documents in DT, and an unknown proportion of those have single word footnotes… and I can’t think of a way in DT to find out which ones!
But leaving that aside, not needing the space seems to me to be a more flexible solution, given that it’s so widely used elsewhere, and a change wouldn’t break notes that do include the space. So if it can be incorporated into an update at some point, that would be great.
I don’t know how to find single word inline footnotes either (and I do not like footnotes when I read something, but that’s neither here nor there).
A script could add the space before the closing bracket, but that requires more than a simple replace operation: The code would need to check if a single word footnote has a reference later or not. Feasible, but more complex than I’d care to write right now.
As to the rest of your arguments: The editors are not the issue here, but the rendering. And MD is (unfortunately) not a single standard. EG, GitHub does not allow for inline references in their dialect. And that one has, I think, a larger following than BBEdit 
Here’s JavaScript code that modifies the currently selected records so that one-word inline footnotes without references at the end get appended a space – [^inline] becomes [^inline ]. It is only rudimentarily tested, though (works with your example). And since the code is hand-crafted, it might contain errors.
To test: make copies of some MD documents, select all of those copies and then run the script. Verify that the copies look as they should afterwards and behave as they’re supposed to.
All this is just a workaround in case you can’t or don’t want to wait for a fix in DT.
function replaceFunction(match, part1, offset, txt) {
if (! ((new RegExp(`\\[\\^${part1}\\]:\\s+`)).test(txt))) {
/* this footnote is not referenced, append a space */
return `[^${part1} ]`;
} else {
/* this one is referenced, don't touch it */
return match;
}
}
(() => {
const app = Application("DEVONthink")
const records = app.selectedRecords();
records.filter(r => r.recordType() === 'markdown').forEach(r => {
const txt = r.plainText().replaceAll(/\[\^(\w+?)\]/g,replaceFunction);
r.plainText = txt;
})
})()
The regular expression in the main part looks for
- an opening bracket (`[')
- followed by a caret (
\^)
- followed by at least one word character (
\w+?)
- followed by a closing bracket (`])
It will thus match any single word footnote in the text. For each match, the replacerFunction is called. It uses another (dynamic) regular expression to check if the word just found is referenced in the text. If not, the function returns a the word with a space appended. Otherwise, it just returns the original complete match, i.e. the footnote.
1 Like
Thank you for taking the time to do this – I appreciate it very much.
I shall give it a go!
The next release will support this
2 Likes
Hi @cgrunenberg
I see that 4.4.2 allows single word inline footnotes now!
I only asked for this four days ago, so to see a fix appear so quickly is outstanding customer responsiveness.
I know it fitted in nicely with the release schedule, and may not have been a very difficult fix, but the fact that you took time to slot it in so quickly, instead of putting it at the end of a long list, is very impressive, and very welcome.
Thank you!
6 Likes