Closed tmke8 closed 1 year ago
I think we already have it? :NAS:
and :author:
would be the syntax
(we need to teach playground to share links...)
Ohhh, I thought that was only for emojis. Sorry for the noise!
teach the playground to share links
done
Wow that sounds cool if we could do that. Please let me know how Djot would handle situations like this. That would just save me for so much trouble while writing :)
Sendt fra min Mac Mini via Apple Mail
Den 7. jan. 2023 kl. 14.56 skrev Thomas MK @.***>:
When writing papers in Latex, I often define very simple macros for a single word or expression, for which I want to make sure it's always spelled correctly or which I want to be able to change everywhere all at once.
So, for example
\def \NAS {National Academy of Science} \def \author {William {\sc Smith}} I was thinking the same could be done in djot where the substitution is defined externally and then you can reference it from within the djot document. For example, the substitution could be define in the YAML frontmatter, but it doesn't have to be; it just depends on your particular djot implementation/environment.
For the syntax, I was imagining something like @
author
but with @author as a shortcut if the snippet name only contains A-Za-z:
NAS: National Academy of Science author: William Smith
Hi, I'm @author and work at the @NAS. Of course, this could also be done with
author
{=frontmatter} but that's quite verbose.Depending on the djot implementation/environment, there could also be other values that could be referenced, like @creationdate to get a nicely formatted form of the creation date of the document.
— Reply to this email directly, view it on GitHub https://github.com/jgm/djot/issues/182, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGGLXRXFM5RIESFNQYU62B3WRFYZPANCNFSM6AAAAAATT6YMLY. You are receiving this because you are subscribed to this thread.
Click on Filter to see the filter that is being used:
const expansions = {
author: "John Smith",
editor: "Sarah Chen"
}
return {
symb: (el) => {
const expansion = expansions[el.alias];
if (expansion) {
el.tag = "str";
el.text = expansion;
el.alias = undefined;
}
}
}
I will say, though, that I'm not really happy with the current filter API and it will probably change.
Altering elements in place like this is going to lead to stuff that doesn't fit the schema for the AST; it would probably be best to have these functions return a new AST value that replaces the old one.
functions return a new AST value that replaces the old one.
Or array of values, to delete/insert many
Or array of values, to delete/insert many
Yes, that's exactly the interface we have in pandoc.
Hi
Give me some work please
When writing papers in Latex, I often define very simple macros for a single word or expression, for which I want to make sure it's always spelled correctly or which I want to be able to change everywhere all at once.
So, for example
I was thinking the same could be done in djot where the substitution is defined externally and then you can reference it from within the djot document. For example, the substitution could be define in the YAML frontmatter, but it doesn't have to be; it just depends on your particular djot implementation/environment.
For the syntax, I was imagining something like
@`author`
but with@author
as a shortcut if the snippet name only contains A-Za-z:Of course, this could also be done with
`author`{=frontmatter}
but that's quite verbose.Depending on the djot implementation/environment, there could also be other values that could be referenced, like
@creationdate
to get a nicely formatted form of the creation date of the document.