30 lines
736 B
Ruby
Executable File
30 lines
736 B
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'
|
|
|
|
config_filename = String(ARGV[0]).freeze
|
|
profile = String(ARGV[1]).freeze
|
|
|
|
config = Repubmark::Config.load_file config_filename, profile
|
|
$article = Repubmark::Elems::Article.new config
|
|
|
|
template = $stdin.read.freeze
|
|
context = BasicObject.new
|
|
def context.article = $article
|
|
context.instance_eval template, __FILE__, __LINE__
|
|
|
|
output =
|
|
case config.format
|
|
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?
|