You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(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 in example1.js.
The output is written to out1.html.
Since allowDangerousHtml: true is passed to both remark-rehype and rehype-stringify, the raw html in the markdown should appear in the resulting HTML. However, the options are not being handled properly by remark-rehype. This issue is specific to using unified-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, but remark-rehype has two optional parameters destination and options, so the options are assigned to destination and the FileSet is assigned to options. As a result, line 151 in remark-rehype/lib/index.js ignores the actual options (which are in destination):
A workaround is shown by yarn example2. The code being executed is in example2.js, and the output is written to out2.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 to options. This workaround helps to confirm that the issue is with how options are handled by the combination of unified-engine and remark-rehype.
Expected behavior
In out1.html, the raw HTML from in.mdshould be included:
Ah, right. It could be interesting to see if the previous majors of those plugins had the same problem or not. They had more handling around the parameters.
I’d say for a solution there also needs to be better handling in this project, remark-rehype, around a given file set
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: