Options passed via unified-engine
are not working
#35
Labels
👍 phase/yes
Post is accepted and can be worked on
unified-engine
are not working
#35
Initial checklist
Affected packages and versions
remark-rehype: 11.0.0; unified-engine: 11.2.0
Link to runnable example
https://codesandbox.io/p/sandbox/remark-rehype-issue-jzrg2s
Steps to reproduce
(I'm running Node 21.2.0 & Yarn 4.0.2, but the sandbox is running 20.9.0 & Yarn 1.22.19 and shows the same issue).
Please use the sandbox linked above.
The markdown input is in
in.md
.Run
yarn example1
in the sandbox terminal. The code being executed is inexample1.js
.The output is written to
out1.html
.Since
allowDangerousHtml: true
is passed to bothremark-rehype
andrehype-stringify
, the raw html in the markdown should appear in the resulting HTML. However, the options are not being handled properly byremark-rehype
. This issue is specific to usingunified-engine
, because it passes an additional parameter with a FileSet to all plugins (https://github.com/unifiedjs/unified-engine/tree/main?tab=readme-ov-file#fileset). This is normally ignored, butremark-rehype
has two optional parametersdestination
andoptions
, so the options are assigned todestination
and the FileSet is assigned tooptions
. As a result, line 151 inremark-rehype/lib/index.js
ignores the actual options (which are indestination
):A workaround is shown by
yarn example2
. The code being executed is inexample2.js
, and the output is written toout2.html
.The key to the workaround is that I've wrapped
remark-rehype
in a function call that reassigns the parameters:This works because now the empty object gets assigned to
destination
and the options get assigned tooptions
. This workaround helps to confirm that the issue is with how options are handled by the combination ofunified-engine
andremark-rehype
.Expected behavior
In
out1.html
, the raw HTML fromin.md
should be included:Actual behavior
In
out1.html
, the raw HTML fromin.md
is not included:Runtime
Other (please specify in steps to reproduce)
Package manager
Other (please specify in steps to reproduce)
OS
Windows
Build and bundle tools
Rollup
The text was updated successfully, but these errors were encountered: