Sha256: 0b31ace19a920927a47527db8c3afae49a7f9ff0b174ed24693db1414d300c7a
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
#!/usr/bin/env ruby require File.expand_path( File.join(File.dirname(__FILE__), %w[.. lib org-parse])) #require 'rubygems' #require 'org-parse' require 'optparse' options = {} options_parser = OptionParser.new do |opts| options[:help] = false options[:format] = :html options[:template] = nil opts.banner = "Usage: org-parse [options] <file>" opts.on("-h", "--help", "Show this message") do |v| options[:help] = true end opts.on("-f", "--format FORMAT", [:html, :textile], "Translate the ORG file to the specified format.(not yet)") do |v| options[:format] = v end opts.on("-t", "--template TEMPLATE", "Erb template for build the output.") do |v| options[:template] = v end end def update_test(node, opt = {}) cnt = 1; section_no = node.section_no if node.kind == :SECTION node.children.each do |n| n.parent = node if n.kind == :SECTION if node.kind == :ROOT n.section_no = cnt.to_s else n.section_no = section_no + "." + cnt.to_s end cnt += 1 end update_test n, opt end end def disp_toc(node) node.children.each do |n| if n.kind == :SECTION puts n.section_no disp_toc(n) end end end begin options_parser.parse! if (ARGV.length == 0) then puts options_parser else data = IO.read(ARGV[0]) parser = OrgParse::StructParser.new(data, File.basename(ARGV[0], '.*')) root = parser.parse update_test(root) disp_toc(root) # visitor = OrgParse::HtmlVisitor.new(root, options[:template]) # puts visitor.build end rescue OptionParser::ParseError puts options_parser end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
org-parse-0.1.2 | bin/org-test |
org-parse-0.1.1 | bin/org-test |