Skip to content

Commit

Permalink
Change configuration for Commonmarker
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ania-hm committed Nov 21, 2023
1 parent cc99bdd commit 5a30f1b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion lib/markdown.rb
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -19,6 +29,7 @@ def to_html

def options
{
extension: EXTENSION,
render: RENDER
}
end
Expand Down

0 comments on commit 5a30f1b

Please sign in to comment.