📚 Add directive to show list of abbreviations across pages - #2985
📚 Add directive to show list of abbreviations across pages#2985haroldcampbell wants to merge 4 commits into
Conversation
|
|
Disclosure: OpenAI's CodexCLI was used to help with the development of this directive. I'm happy to share the prompts/specs if folks are interested. |
|
Also see #2979 which should make it easier to gather frontmatter in these types of plugins. |
|
@stefanv do you think I makes sense to get that multi doc metadata PR in before finishing this one? |
|
In the meantime - @haroldcampbell can you add user facing docs for this so that it's easier to understand the UX and so that users can discover this? |
|
This getmdast magic is new to me, but yes: I think if we can get all front matter included in what we provide plugins (which that PR does), it would avoid some shenanigans in this one. |
|
@stefanv is the call to the If it is I can explore a different way to get the abbreviations in the |
| projectSlug, | ||
| mdastPost.slug, | ||
| ); | ||
| abbreviationsListTransform(mdast, { |
There was a problem hiding this comment.
We should check this — I think there's a race condition here implying that we need another sync point.
This is also true for the ToC transform I think.
Actually.... it might be fine — we read mdast only to get the custom placeholder node, which is not modified after referencing.
|
@choldgraf, I've added user facing docs for the directive. Specifically, to the following files:
Can you have a look and let me know if this works? |
The PR add an
{abbreviations}block-directive that renders a list of known abbreviations. Abbreviations will be collected from theproject.abbreviationsin themyst.ymland from thefrontmatterof all the pages in the site.The abbreviations as sorted alphabetically. As implemented, page-level abbreviations override project abbreviations when duplicated duplicate keys. The implementation adds the directive without replacing the existing inline abbreviation mechanism.
Usage
Support was also added for common directive options
:label:and:class:. Which allows you to write:Tests
I've included a test case in
mystmd/packages/mystmd/tests/abbreviations-directivewith aREADME.mdImplementation
Given a
myst.ymlwith the following (seemystmd/packages/mystmd/tests/abbreviations-directive):...and a page with the following frontmatter (e.g.
page-3.md):You'd get the following
mdastCloses #1098