Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions .github/workflows/ruby_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ["3.1", "3.2", "3.3"]
ruby-version: ["3.2", "3.3"]
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake test
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake test
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ require:
- rubocop-performance

AllCops:
TargetRubyVersion: 3.1
TargetRubyVersion: 3.2
DisplayCopNames: true
Exclude:
- bin/**/*
Expand Down
5 changes: 5 additions & 0 deletions lib/mato/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Config
render: {
hardbreaks: true,
unsafe: true,
escaped_char_spans: false,
},
extension: {
table: true,
Expand Down Expand Up @@ -43,6 +44,9 @@ class Config
# @return [Hash] Commonmarker's options
attr_accessor :markdown_options

# @return [Hash] Commonmarker's plugins
attr_accessor :markdown_plugins

def initialize
@text_filters = []
@markdown_filters = []
Expand All @@ -54,6 +58,7 @@ def initialize
@document_factory = Document

@markdown_options = DEFAULT_MARKDOWN_OPTIONS
@markdown_plugins = { syntax_highlighter: nil }
end

# @param [Proc] block
Expand Down
2 changes: 2 additions & 0 deletions lib/mato/html_filters/section_anchor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ def call(doc)
anchor_builder = AnchorBuilder.new(@anchor_icon_element)

doc.css(HX_PATTERN).each do |hx|
# Remove existing anchor elements generated by CommonMarker v2
hx.css('a.anchor[inert]').remove
hx.children = anchor_builder.make_anchor_element(hx) + hx.children.to_html
end
end
Expand Down
3 changes: 2 additions & 1 deletion lib/mato/html_filters/syntax_highlight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def parse_label(class_name)
# @return [Nokogiri::XML::Element] a new <div/> wrapping the given code block
def highlight(pre)
code = pre.at('code')
metadata = parse_label(code['class'])
lang_attr = pre['lang'] || code['class']
metadata = parse_label(lang_attr)
language = metadata[:language]&.sub(/^language-/, '')
filename = metadata[:filename]
source = code.inner_text
Expand Down
2 changes: 1 addition & 1 deletion lib/mato/processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def parse_markdown(text)
# @param [Commonmarker::Node] markdown_node
# @return [String]
def render_to_html(markdown_node)
markdown_node.to_html(options: config.markdown_options)
markdown_node.to_html(options: config.markdown_options, plugins: config.markdown_plugins)
end

# @param [String] html
Expand Down
4 changes: 2 additions & 2 deletions mato.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.required_ruby_version = "~> 3.1"
spec.required_ruby_version = "~> 3.2"

spec.add_runtime_dependency "commonmarker", "~> 1.0"
spec.add_runtime_dependency "commonmarker", "~> 2.3"
spec.add_runtime_dependency "nokogiri", ">= 1.12"
spec.add_runtime_dependency "rouge", ">= 3.0.0"
end
Loading