Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change markdown to roff converter from pandoc tool to md2man gem #13

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'md2man/roff/engine'
require 'rake/clean'

SOURCE_DIR = 'doc'.freeze
Expand Down Expand Up @@ -25,5 +26,6 @@ CLOBBER.include(OUTPUT_DIR)

rule OUTPUT_EXT => -> (name) { out_to_source(name) } do |t|
mkdir_p t.name.pathmap('%d')
sh "pandoc -s -t man -o '#{t.name}' '#{t.source}'"
roff_output = Md2Man::Roff::ENGINE.render(File.read(t.source))
File.write t.name, roff_output
end
11 changes: 3 additions & 8 deletions libexec/um-read.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'md2man/roff/engine'
require 'shellwords'
require 'tempfile'
require_relative '../lib/um.rb'
Expand Down Expand Up @@ -36,14 +37,8 @@
if File.extname(page_path) == UmConfig::UM_MARKDOWN_EXT
begin
temp_file = Tempfile.new('um')
pandoc_output = `pandoc -s -t man "#{page_path}" > "#{temp_file.path}"`
unless $?.success?
$stderr.puts "Could not convert " +
"#{page_name} #{UM_MARKDOWN_EXT} file to man page."
$stderr.puts pandoc_output
exit 1
end

roff_output = Md2Man::Roff::ENGINE.render(File.read(page_path))
File.write temp_file.path, roff_output
system(%{man "#{temp_file.path}"})
ensure
temp_file.unlink
Expand Down