Hey everyone, I would like to know if it is possible to support an extended markdown format like obsidian comments

I saw the 0.137.1 version of create an embedded comment shortcode in #13011, I would like to know if it is possible to support an extended markdown format like obsidian comments.

This is an %%inline%% comment.

%%
This is a block comment.

Block comments can span multiple lines.
%%

Lastly, I’m the developer of the FixIt theme, and I imagine this would be easy to do using regular expressions in the theme, but I’d prefer Hugo provide this extended syntax.

A little attempt:

{{- /* Comments for Markdown */ -}}
{{- $content = replaceRE "%%(.|\n)*?%%" "" $content -}}
{{- $content = replace $content "<p></p>" ""  -}}

Looks like you are searchin for the passthru extension.

2 Likes

Sorry, I still have a question. How can I distinguish different delimiters?

Use the passthrough extension to preserve raw Markdown within delimited snippets of text. This was initially developed to support LaTeX mixed with Markdown, specifically mathematical expressions and equations.

If you use this extension for any other purpose (e.g., comments) you will not be able to use it for math.

If I were you I would not use the passthrough extension for this.

I don’t want to give up the Mathematical formula Server-side rendering. and I would not use the passthrough extension for this.

Back to the topic, I’m wondering if users will be able to configure custom extra markdown formats via hugo-goldmark-extensions in the future?

You can only use the extensions that’s compiled into Hugo.

We have been talking about allowing to configure multiple passthrough setups, which is a good idea and I suspect it will eventually happen.

3 Likes