diff --git a/lib/yard/templates/helpers/html_helper.rb b/lib/yard/templates/helpers/html_helper.rb index 9f7dae9b4..a84f9ce91 100644 --- a/lib/yard/templates/helpers/html_helper.rb +++ b/lib/yard/templates/helpers/html_helper.rb @@ -89,6 +89,9 @@ def html_markup_markdown(text) :tables, :with_toc_data, :no_intraemphasis).to_html + when 'Commonmarker' + # 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 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/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 diff --git a/spec/templates/markup_processor_integrations/markdown_spec.rb b/spec/templates/markup_processor_integrations/markdown_spec.rb index 8581f7dd8..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