From ffe3c3cb6a6b7b93c07d24537e04d44e558e5c23 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 20 Aug 2018 14:42:27 -0700 Subject: [PATCH 1/3] Use Kramdown instead of RDiscount MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added `Gemfile` to add `kramdown` as a dependency. *** Make sure you have Bundler installed: `bundle -v` If you don't, install it. `gem install bundler` Because you're using system Ruby, you might need to `sudo` that. `sudo gem install bundler` *** When you have Bundler installed, `bundle` your gem dependencies from your `Gemfile`. `bundle install` *** After that, your usage _should_ be the same as it ever was. Same as it ever was. *** Lemme know if that Just Works™ for you on Mojave + System Ruby. If not, I have a very simple approach to using non-system Ruby that I can add to the project for you. --- Gemfile | 3 +++ Gemfile.lock | 13 +++++++++++++ README.md | 11 +++++++++-- utilities/wildcat_file.rb | 13 +++++++++++-- 4 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 Gemfile create mode 100644 Gemfile.lock 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..8c094e7 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( + MarkdownMedia.parse(@text), + input: :kramdown, + remove_block_html_tags: false, + transliterated_header_ids: true + ).to_html + else + @text + end end end From 19c6ed0bb57737400f541e4b656adb1a1b1c676c Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 20 Aug 2018 14:49:54 -0700 Subject: [PATCH 2/3] Remove MarkdownMedia.parse reference --- utilities/wildcat_file.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/wildcat_file.rb b/utilities/wildcat_file.rb index 8c094e7..ff3c91c 100644 --- a/utilities/wildcat_file.rb +++ b/utilities/wildcat_file.rb @@ -45,7 +45,7 @@ def text_type_from_path(path) def render_text if @text_type == TEXT_TYPE_MARKDOWN Kramdown::Document.new( - MarkdownMedia.parse(@text), + @text, input: :kramdown, remove_block_html_tags: false, transliterated_header_ids: true From f337aa9f12f15896e66706c08973d3ec364f2592 Mon Sep 17 00:00:00 2001 From: Shane Becker Date: Mon, 20 Aug 2018 14:50:13 -0700 Subject: [PATCH 3/3] Fix indentation --- utilities/wildcat_file.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/utilities/wildcat_file.rb b/utilities/wildcat_file.rb index ff3c91c..f009546 100644 --- a/utilities/wildcat_file.rb +++ b/utilities/wildcat_file.rb @@ -45,10 +45,10 @@ def text_type_from_path(path) def render_text if @text_type == TEXT_TYPE_MARKDOWN Kramdown::Document.new( - @text, - input: :kramdown, - remove_block_html_tags: false, - transliterated_header_ids: true + @text, + input: :kramdown, + remove_block_html_tags: false, + transliterated_header_ids: true ).to_html else @text