diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..263645e --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source 'https://rubygems.org' + +gem 'kramdown' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..a09cfff --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,13 @@ +GEM + remote: https://rubygems.org/ + specs: + kramdown (1.17.0) + +PLATFORMS + ruby + +DEPENDENCIES + kramdown + +BUNDLED WITH + 1.16.2 diff --git a/README.md b/README.md index 4617398..cc96df3 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ At the top of each file is some attributes — lines that start with a `@` sign. Files are treated according to their suffixes: `.html` means not to process the text; `.markdown` means to use the Markdown renderer. -(Wildcat requires the RDiscount gem for Markdown rendering.) +(Wildcat requires the Kramdown gem for Markdown rendering.) ## Macros @@ -54,4 +54,11 @@ TBD ## How to run locally -TBD +Install gem dependencies from `Gemfile`: + +``` +gem install bundler +bundle install +``` + +**TBD** diff --git a/utilities/wildcat_file.rb b/utilities/wildcat_file.rb index 3d603d0..f009546 100644 --- a/utilities/wildcat_file.rb +++ b/utilities/wildcat_file.rb @@ -1,7 +1,7 @@ # Contains the attributes, text, and text type of a file. # Could be a page, post, or settings file. -require 'rdiscount' +require 'kramdown' require_relative 'file_parser' require_relative '../wildcat_constants' @@ -43,6 +43,15 @@ def text_type_from_path(path) end def render_text - @text_type == TEXT_TYPE_MARKDOWN ? RDiscount.new(@text).to_html : @text + if @text_type == TEXT_TYPE_MARKDOWN + Kramdown::Document.new( + @text, + input: :kramdown, + remove_block_html_tags: false, + transliterated_header_ids: true + ).to_html + else + @text + end end end