Skip to content

Update Commonmarker option#26

Merged
jeremyevans merged 1 commit intojeremyevans:masterfrom
halo:master
Feb 19, 2026
Merged

Update Commonmarker option#26
jeremyevans merged 1 commit intojeremyevans:masterfrom
halo:master

Conversation

@halo
Copy link
Contributor

@halo halo commented Feb 19, 2026

Hi!

These are the options Tilt currently allows to be passed to the Commonmarker gem:

aliases = {
:smartypants => :smart
}.freeze
parse_opts = [
:smart,
:default_info_string,
].freeze
render_opts = [
:hardbreaks,
:github_pre_lang,
:width,
:unsafe,
:escape,
:sourcepos,
].freeze
exts = [
:strikethrough,
:tagfilter,
:table,
:autolink,
:tasklist,
:superscript,
:header_ids,
:footnotes,
:description_lists,
:front_matter_delimiter,
:shortcodes,
].freeze

But the Commonmarker gem supports quite a few more options than Tilt is currently able to pass on.

I haven't looked much at the Tilt code (other than finding out why my options aren't passed on), so I'm unsure what the best way forward would be.

If I understand it correctly, Tilt::Template has one flat options hash, that includes all sorts of options. Those are then parsed out and forwarded to the appropriate receiver.

E.g. keep :default_encoding

# Force a specific scope class, instead of using the class of the provided
# scope as the scope class.
@scope_class = @options.delete :scope_class

but pass others to Commonmarker, such as :autolink as extention option

extensions = @options.select { |key, _| exts.include?(key) }.transform_keys(&:downcase)

and :hardbreaks as render option

render_options = @options.select { |key, _| render_opts.include?(key.downcase) }.transform_keys(&:downcase)

I guess that "routing" of options is the reason why all keys must be defined in Tilt. So, I currently see no better way than to simply try to keep the options up-to-date with the upstream gem, right?.

Thank you for your hard work on this, I appreciate it a lot!

@jeremyevans
Copy link
Owner

Thank you for the report. I think the simplest solution instead of trying to play whack-a-mole every time a commonmarker option is added is to accept parse_options and render_options for the tilt template. These would take hashes, and tilt would pass the values through to when calling the commonmarker code.

@jeremyevans
Copy link
Owner

Since you've already done the work here, it seems simplest to just merge it as opposed to going with a parse_options and render_options approach.

@jeremyevans jeremyevans merged commit e3c13ab into jeremyevans:master Feb 19, 2026
14 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants