lib/trifle/docs/harvester/markdown.rb in trifle-docs-0.3.0 vs lib/trifle/docs/harvester/markdown.rb in trifle-docs-0.3.1
- old
+ new
@@ -33,28 +33,40 @@
Render.new(with_toc_data: true),
fenced_code_blocks: true,
disable_indented_code_blocks: true,
footnotes: true
).render(data.sub(/^---(.*?)---(\s*)/m, ''))
+ rescue StandardError => e
+ puts "Markdown: Failed to parse CONTENT for #{file}: #{e}"
end
- def meta
- @meta = nil unless cache
-
- @meta ||= (YAML.safe_load(data[/^---(.*?)---(\s*)/m].to_s) || {}).merge(
+ def default_meta
+ {
'url' => "/#{[namespace, url].compact.join('/')}",
'breadcrumbs' => url.split('/'),
'toc' => toc,
'updated_at' => ::File.stat(file).mtime
- )
+ }
end
+ def meta
+ @meta = nil unless cache
+
+ @meta ||= (YAML.safe_load(data[/^---(.*?)---(\s*)/m].to_s) || {}).merge(default_meta)
+ rescue StandardError => e
+ puts "Markdown: Failed to parse META for #{file}: #{e}"
+
+ default_meta
+ end
+
def toc
@toc = nil unless cache
@toc ||= Redcarpet::Markdown.new(
Redcarpet::Render::HTML_TOC
).render(data.sub(/^---(.*?)---(\s*)/m, ''))
+ rescue StandardError => e
+ puts "Markdown: Failed to parse TOC for #{file}: #{e}"
end
end
end
end
end