Skip to content

Delete horizontal rule

Huub de Beer edited this page May 11, 2017 · 6 revisions

Assuming the following example markdown

This paragraph is above the line

-----

This paragraph is below the line

how can you delete that line with a Paru filter? And what about a line as child of another element?

The following filter will do the trick:

#!/usr/bin/env ruby
require "paru/filter"

Paru::Filter.run do 
  with "HorizontalRule" do |rule|
    if rule.has_parent? then
      rule.parent.delete rule
    else
      rule.outer_markdown = ""
    end
  end
end

If a rule has a parent, ask its parent to delete the rule. If it hasn't just replace its markdown by "".

Clone this wiki locally