summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-02-09 17:17:45 -0500
committerLuke Shumaker <lukeshu@lukeshu.com>2018-02-09 17:28:02 -0500
commitc558898337b858c0fd071f06242ab94618b2a113 (patch)
tree6e6eca785a43d4305cd3556c26e5f467dc474dd4
parente4ed04cce992a438e46da1c15d41bfeb3c111f4d (diff)
Backport update to pandoc.rb from andrewdm.me
-rw-r--r--pandoc.rb29
1 files changed, 24 insertions, 5 deletions
diff --git a/pandoc.rb b/pandoc.rb
index 9c12351..8c51cb4 100644
--- a/pandoc.rb
+++ b/pandoc.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
require 'open3'
require 'json'
@@ -37,7 +38,11 @@ module Pandoc
end
def [](key)
- Pandoc::AST::js2sane(@js[0]["unMeta"][key])
+ Pandoc::AST::js2sane(@js["meta"][key])
+ end
+
+ def js
+ @js
end
def to(format)
@@ -61,16 +66,30 @@ module Pandoc
return js
end
case js["t"]
+ when "MetaMap"
+ Hash[js["c"].map{|k,v| [k, js2sane(v)]}]
when "MetaList"
js["c"].map{|c| js2sane(c)}
- when "MetaInlines"
- js["c"].map{|c| js2sane(c)}.join()
- when "Space"
- " "
+ when "MetaBool"
+ js["c"]
when "MetaString"
js["c"]
+ when "MetaInlines"
+ js["c"].map{|c| js2sane(c)}.join()
+ when "MetaBlocks"
+ js["c"].map{|c| js2sane(c)}.join("\n")
when "Str"
js["c"]
+ when "Space"
+ " "
+ when "RawInline"
+ js["c"][1]
+ when "RawBlock"
+ js["c"][1]
+ when "Para"
+ js["c"].map{|c| js2sane(c)}.join()
+ else
+ raise "Unexpected AST node type '#{js["t"]}'"
end
end
end