repubmark/exe/repubmark

47 lines
1.2 KiB
Ruby
Executable File

#!/usr/bin/env ruby
# frozen_string_literal: true
lib = File.expand_path('../lib', __dir__).freeze
$LOAD_PATH.unshift lib unless $LOAD_PATH.include? lib
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
$template = $stdin.read.freeze
$config = Repubmark::Config.new(
base_url: 'https://causa-arcana.com',
css_class_annotation: 'nice-annotation',
css_class_blockquote_figure: 'nice-blockquote',
css_class_figure_self: 'nice-figure',
css_class_figure_wrap: 'd-flex justify-content-center',
css_class_figures_left: 'col-xl-6',
css_class_figures_right: 'col-xl-6',
css_class_figures_wrap: 'row',
css_class_iframe_wrap: 'ratio ratio-16x9',
current_path: '/xx/blog/xxxx/xx/xx/xxx.xxx',
relative_urls: false,
)
$article = Repubmark::Elems::Article.new $config
$article.tap do |article| # rubocop:disable Lint/UnusedBlockArgument
eval $template # rubocop:disable Security/Eval
end
case $format
when 'word_count'
puts $article.word_count
when 'html'
puts $article.to_html.strip
when 'gemtext'
puts $article.to_gemtext.strip
else
raise 'Unknown blog format'
end