From cf44a71c6715e39c9868b2beddaa0be4cf67b71e Mon Sep 17 00:00:00 2001 From: "Garen J. Torikian" Date: Mon, 27 Jan 2025 11:18:04 -0500 Subject: [PATCH] Support both Commonmarker pre and post 1.0 --- lib/yard/templates/helpers/html_helper.rb | 4 +++- lib/yard/templates/helpers/markup_helper.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/yard/templates/helpers/html_helper.rb b/lib/yard/templates/helpers/html_helper.rb index 9f7dae9b4..287a7eef1 100644 --- a/lib/yard/templates/helpers/html_helper.rb +++ b/lib/yard/templates/helpers/html_helper.rb @@ -89,7 +89,9 @@ def html_markup_markdown(text) :tables, :with_toc_data, :no_intraemphasis).to_html - when 'CommonMarker' + when 'Commonmarker' # GFM configs are on by default; use YARD for syntax highlighting + Commonmarker.to_html(text, options: { extension: { header_ids: nil } }, plugins: {syntax_highlighter: nil}) + when 'CommonMarker' # old, pre 1.0; downstream consumers should upgrade CommonMarker.render_html(text, %i[DEFAULT GITHUB_PRE_LANG], %i[autolink table]) else provider.new(text).to_html diff --git a/lib/yard/templates/helpers/markup_helper.rb b/lib/yard/templates/helpers/markup_helper.rb index 9d7a6dcd1..dddc5d395 100644 --- a/lib/yard/templates/helpers/markup_helper.rb +++ b/lib/yard/templates/helpers/markup_helper.rb @@ -30,7 +30,7 @@ def clear_markup_cache {:lib => :maruku, :const => 'Maruku'}, {:lib => :'rpeg-markdown', :const => 'PEGMarkdown'}, {:lib => :rdoc, :const => 'YARD::Templates::Helpers::Markup::RDocMarkdown'}, - {:lib => :commonmarker, :const => 'CommonMarker'} + {:lib => :commonmarker, :const => defined?(CommonMarker) ? 'CommonMarker' : "Commonmarker" } ], :textile => [ {:lib => :redcloth, :const => 'RedCloth'}