Replies: 2 comments
-
I should add if there is a clever of achieving this by gluing existing plugins together, I'm all ears. |
Beta Was this translation helpful? Give feedback.
-
Hi Mark! This has to do with HTML right. Elements and stuff. So yes: rehype/hast/html is where that is. Working from an example is indeed a good idea. There are many different examples. I’d recommend going through the stuff we maintain first, as it’s most often up to date. See also https://unifiedjs.com/learn/guide/create-a-rehype-plugin/. Also consider that there are many building blocks you can use. Importantly: https://github.com/syntax-tree/hast-util-find-and-replace. What I don’t quite understand in your Before Transformation / Post Transformation example, is where those terms are coming from? In what format are they stored? Is it names mapped to links (URL + title)? Is it one big YAML file for 150 terms? |
Beta Was this translation helpful? Give feedback.
-
I'm trying to replicate a glossary tool from WP where the tool scans all blog posts and replaces words/phrases with markdown/html links to their respective glossary entries.
I would like some help trying to figure out how to create a glossary. On our existing WordPress site we use a plugin: https://www.cminds.com/wordpress-plugins-library/tooltipglossary/ that scans all of our blog posts and replaces text with a link to the same word or an alias.
The people in the Astro Community suggest I try creating a Remark or Rehype plugin. (Rehype was expected to be easier).
My glossary contains entries with names (and aliases). In this example, I will pretend there are only two entries:
In reality, there are 150+ entries.
My plugin-to-be would scan the glossary entries to build a dictionary. Then it would iterate over all the blog entries, replacing any instances of each name/alias with a link to the same.
// Before Transformation
One of the more frequently asked questions in my Scrum workshops is around the difference between Definition of Done and Acceptance Criteria, and how they relate to User Stories.
// Post Transformation
One of the more frequently asked questions in my Scrum workshops is around the difference between Definition of Done and Acceptance Criteria, and how they relate to User Stories.
--
Like many I find it easier to work from example, especially since JavaScript/TypeScript aren't native languages for me.
What existing plugin would make a good jumping-off point? I assume cloning something like: https://github.com/lin-stephanie/rehype-callouts (which has a good test suite) is the way to go.
Do any existing plugins need to load data from files that should stored for the runtime of the plugin? It seems silly to rescan 150+ glossary files when they will be used 300+ times.
Key questions:
Beta Was this translation helpful? Give feedback.
All reactions