Class: PageHub::Markdown::Embedder::GithubWikiProcessor
- Defined in:
- lib/pagehub-markdown/processors/embedder.rb
Overview
Instance Method Summary collapse
-
#initialize ⇒ GithubWikiProcessor
constructor
A new instance of GithubWikiProcessor.
-
#process(content, uri, args = "") ⇒ Object
Returns the content of the node <div class=‘markdown-body’></div>, it will also remove all id attributes of all content nodes.
Methods inherited from Processor
Constructor Details
#initialize ⇒ GithubWikiProcessor
Returns a new instance of GithubWikiProcessor.
161 162 163 |
# File 'lib/pagehub-markdown/processors/embedder.rb', line 161 def initialize() super(["github-wiki", /github.com.*\/wiki\//]) end |
Instance Method Details
#process(content, uri, args = "") ⇒ Object
Returns the content of the node <div class=‘markdown-body’></div>, it will also remove all id attributes of all content nodes.
Supported options:
-
reduce-headings: all heading nodes (<h1> through <h5>) will be
stepped one level, so h1 becomes h2, etc.
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/pagehub-markdown/processors/embedder.rb', line 171 def process(content, uri, args = "") html_doc = Nokogiri::HTML(content) do |config| config.noerror end node = html_doc.xpath("//div[@class='markdown-body']").first stamp(node, uri, 'github-wiki') if args.include?("reduce-headings") then 5.downto(1) { |level| node.xpath("//h#{level}").each { |heading_node| heading_node.name = "h#{level+1}" } } end node end |