From 5a30f1b78b3a3dabd62136edd2e2a81102128a0f Mon Sep 17 00:00:00 2001 From: Anna Bargiel Date: Tue, 21 Nov 2023 09:13:58 +0100 Subject: [PATCH] Change configuration for Commonmarker I need to change the configuration for Commonmarker [1] to render the HTML code from Markdown correctly. The current configuration causes that Markdown to ommit part of the code with raw HTML, among other things for Youtube movies. I need to find the correct render and extension for Commonmarker to be able to render raw HTML and enable other features of Markdown. The combination of `unsafe: true` render and `tagfilter: false` extension helps Markdown with HTML to return HTML code. But this combination disables some other default extensions like: tables, autolinks, task list and striked text. Disabled extensions have to be enabled directly in the Commonmarker configuration. [1]: https://github.com/gjtorikian/commonmarker/blob/main/README.md --- lib/markdown.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/markdown.rb b/lib/markdown.rb index ac74922a..3d263997 100644 --- a/lib/markdown.rb +++ b/lib/markdown.rb @@ -1,8 +1,18 @@ require 'commonmarker' class Markdown + EXTENSION = { + autolink: true, + footnotes: true, + strikethrough: true, + table: true, + tagfilter: false, + tasklist: true + }.freeze + RENDER = { - hardbreaks: false + hardbreaks: false, + unsafe: true }.freeze def initialize(input) @@ -19,6 +29,7 @@ def to_html def options { + extension: EXTENSION, render: RENDER } end