Replies: 1 comment 3 replies
-
Heya! First I’d recommend going with And, I do think that handlers are a good place to solve this, indeed! Then, indeed, handlers and their state do not have access to files. That is because currently transforming an AST from markdown to HTML is not affected by files. To illustrate, a file name or so does not change how ASTs are transformed. I can particularly see a use case for this handler transform being able to emit messages on files though. For example for your handler to emit a warning when an unknown handler is used. How to go about all this depends more on why you want this flag. Can you explain that? |
Beta Was this translation helpful? Give feedback.
-
I developed a rehype plugin that allows users to gate content with container directives...
My plugin looks more or less like this
Within the plugin, I am setting a
has_gated_content
flag in the file metadata to let me know if the markdown includes at least one:::gate
tag.Some things have lead me to think it may be better to implement this logic as a Handler inside remark-rehype, as opposed to a standalone plugin.
My issue / question is, how can I modify the file metadata from within a handler?
So far, my handler looks like this
and it's part of a processor like this
(Note that I have tried to exclude numerous other details which I think are irrelevant.)
Beta Was this translation helpful? Give feedback.
All reactions