Sha256: 3176e430f58560da8c6b91f1e33796f20f3d3fba7e12797bd6938b48d2a6ad8d
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
# frozen_string_literal: true require 'yaml' require 'redcarpet' require 'rouge' require 'rouge/plugins/redcarpet' module Trifle module Docs module Harvester module Markdown class Render < Redcarpet::Render::HTML include Rouge::Plugins::Redcarpet end class Sieve < Harvester::Sieve def match? file.end_with?('.md') end def to_url file.gsub(%r{^#{path}/}, '') .gsub(%r{/?index\.md}, '') .gsub(/\.md/, '') end end class Conveyor < Harvester::Conveyor def content @content = nil unless cache @content ||= Redcarpet::Markdown.new( Render.new(with_toc_data: true), fenced_code_blocks: true, disable_indented_code_blocks: true, footnotes: true ).render(data.sub(/^---(.*?)---(\s*)/m, '')) end def meta @meta = nil unless cache @meta ||= (YAML.safe_load(data[/^---(.*?)---(\s*)/m].to_s) || {}).merge( 'url' => "/#{[namespace, url].compact.join('/')}", 'breadcrumbs' => url.split('/'), 'toc' => toc, 'updated_at' => ::File.stat(file).mtime ) end def toc @toc = nil unless cache @toc ||= Redcarpet::Markdown.new( Redcarpet::Render::HTML_TOC ).render(data.sub(/^---(.*?)---(\s*)/m, '')) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
trifle-docs-0.3.0 | lib/trifle/docs/harvester/markdown.rb |