From 2c0bac25a5d41a6942c244eaec799cf9d0f3ee73 Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Fri, 22 Mar 2024 16:21:10 -0600 Subject: [PATCH 1/4] Surface missing/incompatible markups rather than skip --- .../markup_processor_integrations/integration_spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/templates/markup_processor_integrations/integration_spec_helper.rb b/spec/templates/markup_processor_integrations/integration_spec_helper.rb index de9843897..6dde87cc9 100644 --- a/spec/templates/markup_processor_integrations/integration_spec_helper.rb +++ b/spec/templates/markup_processor_integrations/integration_spec_helper.rb @@ -26,7 +26,7 @@ before(:each) do if html_renderer.markup_class(markup).nil? - skip "Missing markup renderer #{markup}" + raise "Missing markup renderer #{markup}" end end From 347234294cdbfa572e1944699e7ceff121644f0b Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Fri, 22 Mar 2024 18:18:51 -0600 Subject: [PATCH 2/4] Support `Commonmarker` (lowercase `m`) from v1.x Fixes #1528 Co-Authored-By: Andrew Haines --- lib/yard/templates/helpers/html_helper.rb | 2 ++ lib/yard/templates/helpers/markup_helper.rb | 1 + spec/templates/helpers/html_helper_spec.rb | 2 +- spec/templates/markup_processor_integrations/markdown_spec.rb | 2 +- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/yard/templates/helpers/html_helper.rb b/lib/yard/templates/helpers/html_helper.rb index 9f7dae9b4..40ed3fd7f 100644 --- a/lib/yard/templates/helpers/html_helper.rb +++ b/lib/yard/templates/helpers/html_helper.rb @@ -89,6 +89,8 @@ def html_markup_markdown(text) :tables, :with_toc_data, :no_intraemphasis).to_html + when 'Commonmarker' + Commonmarker.to_html(text) # GFM configs are on by default when 'CommonMarker' CommonMarker.render_html(text, %i[DEFAULT GITHUB_PRE_LANG], %i[autolink table]) else diff --git a/lib/yard/templates/helpers/markup_helper.rb b/lib/yard/templates/helpers/markup_helper.rb index 9d7a6dcd1..105d86495 100644 --- a/lib/yard/templates/helpers/markup_helper.rb +++ b/lib/yard/templates/helpers/markup_helper.rb @@ -30,6 +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 => 'CommonMarker'} ], :textile => [ diff --git a/spec/templates/helpers/html_helper_spec.rb b/spec/templates/helpers/html_helper_spec.rb index b514fcacc..8fc92a460 100644 --- a/spec/templates/helpers/html_helper_spec.rb +++ b/spec/templates/helpers/html_helper_spec.rb @@ -158,7 +158,7 @@ def options it "creates tables (markdown specific)" do log.enter_level(Logger::FATAL) do - supports_table = %w(RedcarpetCompat Kramdown::Document CommonMarker) + supports_table = %w(RedcarpetCompat Kramdown::Document Commonmarker CommonMarker) unless supports_table.include?(markup_class(:markdown).to_s) pending "This test depends on a markdown engine that supports tables" end diff --git a/spec/templates/markup_processor_integrations/markdown_spec.rb b/spec/templates/markup_processor_integrations/markdown_spec.rb index 8581f7dd8..ad9019ac6 100644 --- a/spec/templates/markup_processor_integrations/markdown_spec.rb +++ b/spec/templates/markup_processor_integrations/markdown_spec.rb @@ -82,7 +82,7 @@ end end - describe 'CommonMarker', if: RUBY_VERSION >= '2.3' do + describe 'Commonmarker', if: RUBY_VERSION >= '2.3' do let(:markup) { :markdown } let(:markup_provider) { :commonmarker } From 0e274a041def97bab4fcef55772e787cef99da25 Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Fri, 22 Mar 2024 19:51:23 -0600 Subject: [PATCH 3/4] Disable `Commonmarker` syntax highlighting for compatibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Preference for the provider’s highlighting is outside of this PR’s scope. --- lib/yard/templates/helpers/html_helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/yard/templates/helpers/html_helper.rb b/lib/yard/templates/helpers/html_helper.rb index 40ed3fd7f..a84f9ce91 100644 --- a/lib/yard/templates/helpers/html_helper.rb +++ b/lib/yard/templates/helpers/html_helper.rb @@ -90,7 +90,8 @@ def html_markup_markdown(text) :with_toc_data, :no_intraemphasis).to_html when 'Commonmarker' - Commonmarker.to_html(text) # GFM configs are on by default + # GFM configs are on by default; use YARD for syntax highlighting + Commonmarker.to_html(text, plugins: {syntax_highlighter: nil}) when 'CommonMarker' CommonMarker.render_html(text, %i[DEFAULT GITHUB_PRE_LANG], %i[autolink table]) else From 9e869c940859570b07b81c5eadd6070e76f6291e Mon Sep 17 00:00:00 2001 From: ParadoxV5 Date: Sat, 23 Mar 2024 12:28:19 -0600 Subject: [PATCH 4/4] Remove tests for Markdown header IDs or the lack of MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Testing providers’ implementation is outside of the scope of YARD. I let the backslash line break difference live since that’s probably provider-specific. --- .../markup_processor_integrations/markdown_spec.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/spec/templates/markup_processor_integrations/markdown_spec.rb b/spec/templates/markup_processor_integrations/markdown_spec.rb index ad9019ac6..90623c175 100644 --- a/spec/templates/markup_processor_integrations/markdown_spec.rb +++ b/spec/templates/markup_processor_integrations/markdown_spec.rb @@ -72,26 +72,17 @@ include_examples 'shared examples for markdown processors' - - it 'generates anchor tags for level 2 header' do - expect(rendered_document).to include('

Example code listings

') - end - it 'does not create line break via backslash' do expect(rendered_document).to include("commonmark line break with\\\na backslash") end end - describe 'Commonmarker', if: RUBY_VERSION >= '2.3' do + describe 'Commonmarker', if: RUBY_VERSION >= '2.3' do let(:markup) { :markdown } let(:markup_provider) { :commonmarker } include_examples 'shared examples for markdown processors' - it 'generates level 2 header without id' do - expect(rendered_document).to include('

Example code listings

') - end - it 'creates line break via backslash' do expect(rendered_document).to include("commonmark line break with
\na backslash") end