diff --git a/exe/repubmark b/exe/repubmark index 46c0dea..6d3b236 100755 --- a/exe/repubmark +++ b/exe/repubmark @@ -8,10 +8,10 @@ require 'bundler/setup' require 'repubmark' -FORMATS = %w[word_count html gemtext].freeze - -format = String(ARGV[0]).freeze -raise "Invalid format: #{format.inspect}" unless FORMATS.include? format +format = String(ARGV[0]).to_sym +unless Repubmark::FORMATS.include? format + raise "Invalid format: #{format.inspect}" +end template = $stdin.read.freeze @@ -37,9 +37,9 @@ context.instance_eval template, __FILE__, __LINE__ output = case format - when 'word_count' then $article.word_count - when 'html' then $article.to_html - when 'gemtext' then $article.to_gemtext + when :word_count then $article.word_count + when :html then $article.to_html + when :gemtext then $article.to_gemtext end.to_s.strip puts output unless output.empty? diff --git a/lib/repubmark.rb b/lib/repubmark.rb index d87c8d2..e70ed22 100644 --- a/lib/repubmark.rb +++ b/lib/repubmark.rb @@ -54,3 +54,7 @@ require_relative 'repubmark/elems/section' require_relative 'repubmark/elems/special' require_relative 'repubmark/elems/text' require_relative 'repubmark/elems/link' + +module Repubmark + FORMATS = %i[gemtext html].freeze +end diff --git a/lib/repubmark/elems/custom_logue.rb b/lib/repubmark/elems/custom_logue.rb index 25e6e7e..a3bd396 100644 --- a/lib/repubmark/elems/custom_logue.rb +++ b/lib/repubmark/elems/custom_logue.rb @@ -3,8 +3,6 @@ module Repubmark module Elems class CustomLogue < Base - FORMATS = %i[html gemtext].freeze - parents :Article def initialize(parent)