pandocomatic 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dd24956dd80cddb7d00b97c85b67f273aaac352
|
4
|
+
data.tar.gz: a7e58aca8742f9dd3257f7402bf7b91f641b240f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a9a03171aba28b925e30434ead0a1aae0664a1d78bf322e6e828cc7434c4597947703a04894ce242781fcb5ac9195c252e529eb6fcd4221ab610a6f4464f88b
|
7
|
+
data.tar.gz: 31f06d733453f38c5d02da008fb1da0a632f4b8255f586c9dca839601dbaa3c8770a92f98a1471a8350ca5f9c0bdd6d5ae438bbbcc5060d61de6bcf32c566a3a
|
@@ -9,6 +9,7 @@ module Pandocomatic
|
|
9
9
|
|
10
10
|
def convert src, dst, current_config
|
11
11
|
@config = current_config
|
12
|
+
@src = src
|
12
13
|
metadata = PandocMetadata.load_file src
|
13
14
|
|
14
15
|
if metadata.has_template? then
|
@@ -83,7 +84,8 @@ module Pandocomatic
|
|
83
84
|
processors = config[type]
|
84
85
|
output = input
|
85
86
|
processors.each do |processor|
|
86
|
-
|
87
|
+
script = @config.update_path(processor, File.dirname(@src))
|
88
|
+
output = Processor.run(script, output)
|
87
89
|
end
|
88
90
|
output
|
89
91
|
else
|
@@ -4,8 +4,6 @@ module Pandocomatic
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'paru/pandoc'
|
6
6
|
|
7
|
-
require_relative 'configuration.rb'
|
8
|
-
|
9
7
|
class PandocMetadata < Hash
|
10
8
|
|
11
9
|
def initialize hash = {}
|
@@ -16,24 +14,32 @@ module Pandocomatic
|
|
16
14
|
# Collect the metadata embedded in the src file
|
17
15
|
def self.load_file src
|
18
16
|
begin
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
return PandocMetadata.new
|
17
|
+
yaml_metadata = pandoc2yaml File.read(src)
|
18
|
+
if yaml_metadata.empty? then
|
19
|
+
return PandocMetadata.new
|
23
20
|
else
|
24
|
-
|
25
|
-
json_writer = Paru::Pandoc.new {from 'json'; to 'markdown'; standalone}
|
26
|
-
yaml_metadata = json_writer << JSON.generate(json_metadata)
|
27
|
-
return PandocMetadata.new YAML.load yaml_metadata
|
21
|
+
return PandocMetadata.new YAML.load(yaml_metadata)
|
28
22
|
end
|
29
23
|
rescue Exception => e
|
30
24
|
raise "Error while reading metadata from #{src}; Are you sure it is a pandoc markdown file?\n#{e.message}"
|
31
25
|
end
|
32
26
|
end
|
33
27
|
|
28
|
+
def self.pandoc2yaml document
|
29
|
+
json_reader = Paru::Pandoc.new {from 'markdown'; to 'json'}
|
30
|
+
json_document = JSON.parse json_reader << document
|
31
|
+
yaml_metadata = ''
|
32
|
+
metadata = json_document.first
|
33
|
+
if metadata.has_key? "unMeta" and not metadata["unMeta"].empty? then
|
34
|
+
json_metadata = [metadata, []]
|
35
|
+
json_writer = Paru::Pandoc.new {from 'json'; to 'markdown'; standalone}
|
36
|
+
yaml_metadata = json_writer << JSON.generate(json_metadata)
|
37
|
+
end
|
38
|
+
yaml_metadata
|
39
|
+
end
|
40
|
+
|
34
41
|
def has_template?
|
35
|
-
|
36
|
-
self['pandocomatic'].has_key? 'use-template' and
|
42
|
+
self['pandocomatic'] and self['pandocomatic']['use-template'] and
|
37
43
|
not self['pandocomatic']['use-template'].empty?
|
38
44
|
end
|
39
45
|
|
@@ -46,7 +52,7 @@ module Pandocomatic
|
|
46
52
|
end
|
47
53
|
|
48
54
|
def has_pandoc_options?
|
49
|
-
|
55
|
+
self['pandocomatic'] and self['pandocomatic']['pandoc']
|
50
56
|
end
|
51
57
|
|
52
58
|
def pandoc_options
|
@@ -57,9 +63,6 @@ module Pandocomatic
|
|
57
63
|
end
|
58
64
|
end
|
59
65
|
|
60
|
-
def to_configuration parent_config = Configuration.new
|
61
|
-
end
|
62
|
-
|
63
66
|
end
|
64
67
|
|
65
68
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pandocomatic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Huub de Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paru
|