Allow cmark --unsafe flag? #46

Open
opened 2026-01-28 17:27:21 +01:00 by barneyh · 5 comments

Hi,
New user of BSSG here and really enjoying thus far. I'm trying to add some custom attributes to my images so that I can utilise some fun JS libraries (https://github.com/sneas/img-comparison-slider) on my site. The requires HTML is this:

<img-comparison-slider>
  <img slot="first" src="before.jpg" />
  <img slot="second" src="after.jpg" />
</img-comparison-slider>

But I can't work out how to generate the required HTML via the .md -> cmark build process, and I keep seeing <!-- raw HTML omitted --> in my output files. I see that passing the --unsafe flag to the cmark command allows the embedded html to pass through. Would it be possible to enable this as a local configuration option perhaps? Or does it present security issues that I'm not aware of?

Cheers,

Hi, New user of BSSG here and really enjoying thus far. I'm trying to add some custom attributes to my images so that I can utilise some fun JS libraries (https://github.com/sneas/img-comparison-slider) on my site. The requires HTML is this: ``` <img-comparison-slider> <img slot="first" src="before.jpg" /> <img slot="second" src="after.jpg" /> </img-comparison-slider> ``` But I can't work out how to generate the required HTML via the .md -> cmark build process, and I keep seeing `<!-- raw HTML omitted -->` in my output files. I see that passing the `--unsafe` flag to the cmark command allows the embedded html to pass through. Would it be possible to enable this as a local configuration option perhaps? Or does it present security issues that I'm not aware of? Cheers,

I solved this by creating an alias to cmark with the unsafe flag always on.

I solved this by creating an alias to cmark with the unsafe flag always on.
Author

Ah, nice workaround! Thanks. Guess I might leave the issue open for a bit in case passing flags to the parsing tools is something worth exploring?

Ah, nice workaround! Thanks. Guess I might leave the issue open for a bit in case passing flags to the parsing tools is something worth exploring?
Author

@mrecondo wrote in #46 (comment):

I solved this by creating an alias to cmark with the unsafe flag always on.

Actually, I can't figure out how to do this on macosx. ./bssg.sh calls a non-interactive shell via /usr/bin/env bash and none my aliases seem to take effect. Any advice?

@mrecondo wrote in https://brew.bsd.cafe/stefano/BSSG/issues/46#issuecomment-323: > I solved this by creating an alias to cmark with the unsafe flag always on. Actually, I can't figure out how to do this on macosx. `./bssg.sh` calls a non-interactive shell via `/usr/bin/env bash` and none my aliases seem to take effect. Any advice?

I haven't used macos for a long time. No idea how to solve this. Sorry

I haven't used macos for a long time. No idea how to solve this. Sorry
Author

Resorted to changing ln 320 from /scripts/build/content.sh from:

if ! html_content=$(echo "$content" | cmark); then

to

if ! html_content=$(echo "$content" | cmark --unsafe); then

hacky and unsustainable but did the job for now.

Resorted to changing ln 320 from `/scripts/build/content.sh` from: ` if ! html_content=$(echo "$content" | cmark); then` to ` if ! html_content=$(echo "$content" | cmark --unsafe); then` hacky and unsustainable but did the job for now.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: stefano/BSSG#46
No description provided.