From 672255ed7b13a1617bc0e04493c93bae4ee17a48 Mon Sep 17 00:00:00 2001 From: Dima Shevtsov Date: Fri, 6 Dec 2019 16:04:19 -0600 Subject: [PATCH] Add rake convert Converts HTML text to kramdown in terminal --- Rakefile | 8 ++++++++ bin/kramdown | 29 +++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 bin/kramdown diff --git a/Rakefile b/Rakefile index daa684d11e4..39a5cd4d4a7 100644 --- a/Rakefile +++ b/Rakefile @@ -81,3 +81,11 @@ task index: %w[init] do 'algolia', '--config=_config.yml,_config.index.yml' end + +desc 'Convert HTML text to kramdown in your terminal' +task :convert do + puts 'Paste HTML text followed by a new line and press Control-D.'.magenta + result = `bin/kramdown --input=html --output=kramdown` + puts 'Converted text:'.magenta + puts result.bold +end diff --git a/bin/kramdown b/bin/kramdown new file mode 100755 index 00000000000..73320ecb804 --- /dev/null +++ b/bin/kramdown @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'kramdown' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require "pathname" +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", + Pathname.new(__FILE__).realpath) + +bundle_binstub = File.expand_path("../bundle", __FILE__) + +if File.file?(bundle_binstub) + if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/ + load(bundle_binstub) + else + abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run. +Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.") + end +end + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("kramdown", "kramdown")