Skip to content

Commit 809af55

Browse files
authored
Merge pull request #193 from publify/upgrade-commonmarker-2-3
Upgrade to commonmarker version 2.3
2 parents 7fbd069 + e157d13 commit 809af55

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

app/models/content_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def html(field = :all)
3333
# Generate HTML for a specific field using the text_filter in use for this
3434
# object.
3535
def generate_html(field, text = nil)
36-
text ||= self[field].to_s
36+
text ||= self[field] || ""
3737
html = (text_filter || default_text_filter).filter_text(text) || text
3838
html_postprocess(field, html).to_s
3939
end

app/models/text_filter.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def help
4444
if f.help_text.blank?
4545
""
4646
else
47-
"<h3>#{f.display_name}</h3>\n#{CommonMarker.render_html(f.help_text, :DEFAULT)}"
47+
"<h3>#{f.display_name}</h3>\n#{Commonmarker.to_html(f.help_text)}"
4848
end
4949
end
5050

@@ -56,7 +56,7 @@ def commenthelp
5656
.expand_filter_list([markup, filters].flatten)
5757

5858
help_filters.map do |f|
59-
f.help_text.blank? ? "" : CommonMarker.render_html(f.help_text)
59+
f.help_text.blank? ? "" : Commonmarker.to_html(f.help_text)
6060
end.join("\n")
6161
end
6262

lib/publify_core/text_filter/markdown.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ def self.help_text
4646
def self.filtertext(text)
4747
# FIXME: Workaround for <publify:foo> not being interpreted as an HTML tag.
4848
escaped_macros = text.gsub(%r{(</?publify):}, '\1X')
49-
html = CommonMarker.render_html(escaped_macros, :UNSAFE)
49+
html = Commonmarker.to_html(escaped_macros,
50+
options: {
51+
extension: { header_ids: nil },
52+
render: { unsafe: true }
53+
})
5054
html.gsub(%r{(</?publify)X}, '\1:').strip
5155
end
5256
end

lib/publify_core/text_filter/markdown_smartquotes.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ class MarkdownSmartquotes < PublifyCore::TextFilter::Markdown
1313
def self.filtertext(text)
1414
# FIXME: Workaround for <publify:foo> not being interpreted as an HTML tag.
1515
escaped_macros = text.gsub(%r{(</?publify):}, '\1X')
16-
html = CommonMarker.render_doc(escaped_macros, :SMART).to_html(:UNSAFE)
16+
html = Commonmarker.to_html(escaped_macros,
17+
options: {
18+
parse: { smart: true },
19+
extension: { header_ids: nil },
20+
render: { unsafe: true }
21+
})
1722
html.gsub(%r{(</?publify)X}, '\1:').strip
1823
end
1924
end

publify_core.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
2424
s.add_dependency "bootstrap", "~> 4.6.2"
2525
s.add_dependency "cancancan", "~> 3.0"
2626
s.add_dependency "carrierwave", "~> 3.0"
27-
s.add_dependency "commonmarker", "~> 0.23.2"
27+
s.add_dependency "commonmarker", "~> 2.3"
2828
s.add_dependency "devise", ">= 4.8", "< 4.10"
2929
s.add_dependency "devise-i18n", "~> 1.2"
3030
s.add_dependency "devise_zxcvbn", "~> 6.0"

0 commit comments

Comments
 (0)