Skip to content

Instantly share code, notes, and snippets.

@takuya
Created October 6, 2015 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takuya/4322370d2ef22d317f0b to your computer and use it in GitHub Desktop.
Save takuya/4322370d2ef22d317f0b to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# coding: utf-8
HELP = <<-help
Usage: remakr[<markdwonfile> ,<output_file>]
標準入力か、最初のファイルを読み取って remark プレゼンファイルに仕立てる。
出力を指定しない場合は、STDOUTへ
help
if ARGV.include?('--help')
puts HELP
exit 0
end
if ARGV[1] then
output_file = ARGV[0]+".remark.html"
$stdout = open(output_file, "w")
ARGV.delete_at(1)
end
if ARGV[0] then
input_file = ARGV[0]
input = open(input_file)
ARGV.delete_at(1)
else
input = ARGF
end
require 'github/markdown'
begin
md_text = input.read
PREFIX = <<-prefix
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
<meta charset="utf-8">
<style>
@import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz);
@import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic);
@import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic);
body { font-family: 'Droid Serif'; }
h1, h2, h3 {
font-family: 'Yanone Kaffeesatz';
font-weight: normal;
}
.remark-code, .remark-inline-code { font-family: 'Ubuntu Mono'; }
</style>
</head>
<body>
<textarea id="source">
prefix
SUFFIX = <<-suffix
</textarea>
<script src="https://gnab.github.io/remark/downloads/remark-latest.min.js">
</script>
<script>
var slideshow = remark.create({ratio: '16:9'});
</script>
</body>
</html>
suffix
html = PREFIX + md_text + SUFFIX
$stdout.write(html)
# if File.exists?(output_file) then
# STDOUT.puts "md file was converted to \n-->\n
# #{output_file} "
# #`open '#{output_file}'`
# end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment