Add const Repubmark::FORMATS

This commit is contained in:
Alex Kotov 2024-02-24 09:12:35 +04:00
parent be5ce87dab
commit 8a6d2ca90e
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
3 changed files with 11 additions and 9 deletions

View file

@ -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?

View file

@ -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

View file

@ -3,8 +3,6 @@
module Repubmark
module Elems
class CustomLogue < Base
FORMATS = %i[html gemtext].freeze
parents :Article
def initialize(parent)