Closed akrawitz closed 2 months ago
Hey!
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
Hi! This was marked as ready to be worked on! Note that while this is ready to be worked on, nothing is said about priority: it may take a while for this to be solved.
Is this something you can and want to work on?
Team: please use the area/*
(to describe the scope of the change), platform/*
(if this is related to a specific one), and semver/*
and type/*
labels to annotate this. If this is first-timers friendly, add good first issue
and if this could use help, add help wanted
.
Hi! This was closed. Team: If this was fixed, please add phase/solved
. Otherwise, please add one of the no/*
labels.
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
. Runyarn example1
in the sandbox terminal. The code being executed is inexample1.js
. The output is written toout1.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 wrappedremark-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