bin/polytexnic in polytexnic-1.6.2 vs bin/polytexnic in polytexnic-1.6.3
- old
+ new
@@ -38,27 +38,30 @@
end.parse!
# Returns the file format based on extension.
# Should be 'html' or 'tex'.
def format(filename)
- puts '***********'
- puts '***********'
- puts '***********'
- puts '***********'
- puts '***********'
- p filename.split('.')
filename.split('.').last
rescue
nil
end
-puts '$$$$$$$$$$$'
-puts '$$$$$$$$$$$'
-puts '$$$$$$$$$$$'
-puts '$$$$$$$$$$$'
-puts '$$$$$$$$$$$'
-p options
+# Defines a valid HTML template.
+def html_template(title, body)
+%(<!DOCTYPE html>
+<html>
+ <head>
+ <title>#{title}</title>
+ <meta charset="utf-8">
+ </head>
+ <body>
+ #{body}
+ </body>
+</html>
+)
+end
+
if (infile = options[:infile] || ARGV.shift)
puts infile
input = File.read(infile)
else
input = STDIN.read
@@ -66,10 +69,10 @@
outfile = options[:outfile] || ARGV.shift
puts outfile
pipeline = Polytexnic::Pipeline.new(input, article: true)
format = options[:format] || format(outfile) || "html"
if format == "html"
- output = pipeline.to_html
+ output = html_template("HTML output", pipeline.to_html)
elsif format == "tex"
output = pipeline.to_polytex
else
raise ArgumentError, "Invalid format: #{format}"
end