pandocomatic 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4eb96b887676605773e3929aebac5709f2a70ff
|
4
|
+
data.tar.gz: 2815789aeb3065e128606f3dedb338277251134f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 439b66fabcd4f8c9af43c112f16495aa251a71a592ba22b8691fbdfb40ced84dd1abdb859a927be56ad2fd829aede581a4f811749bdb58bcc9e0839a41ce9623
|
7
|
+
data.tar.gz: 982c94db04f6e51e0bce760e3028aa8256bd9315d3b7ffab6bfe0609810479a215f7cc5ccb27df428fd0daffb4dd19d0cac76587741b0fcf6dda5a7fef99f78b
|
@@ -26,18 +26,6 @@ module Pandocomatic
|
|
26
26
|
require_relative './error/io_error.rb'
|
27
27
|
|
28
28
|
class PandocMetadata < Hash
|
29
|
-
|
30
|
-
# Paru converters:
|
31
|
-
# Note. When converting metadata back to the pandoc markdown format, you have
|
32
|
-
# to use the option 'standalone', otherwise the metadata is skipped
|
33
|
-
PANDOC_2_JSON = Paru::Pandoc.new {from 'markdown'; to 'json'}
|
34
|
-
JSON_2_PANDOC = Paru::Pandoc.new {from 'json'; to 'markdown'; standalone}
|
35
|
-
|
36
|
-
# When converting a pandoc document to JSON, or vice versa, the JSON object
|
37
|
-
# has the following three properties:
|
38
|
-
VERSION = 'pandoc-api-version'
|
39
|
-
META = 'meta'
|
40
|
-
BLOCKS = 'blocks'
|
41
29
|
|
42
30
|
def self.extract_metadata input_document
|
43
31
|
begin
|
@@ -48,31 +36,17 @@ module Pandocomatic
|
|
48
36
|
end
|
49
37
|
|
50
38
|
def self.pandoc2yaml(input)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
if not metadata.empty? then
|
58
|
-
metadata_document = {
|
59
|
-
VERSION => version,
|
60
|
-
META => metadata,
|
61
|
-
BLOCKS => []
|
62
|
-
}
|
63
|
-
|
64
|
-
yaml = JSON_2_PANDOC << JSON.generate(metadata_document)
|
65
|
-
end
|
66
|
-
rescue Paru::Error => e
|
67
|
-
raise PandocError.new(:error_running_pandoc, e, input_document)
|
68
|
-
end
|
69
|
-
|
70
|
-
yaml
|
39
|
+
input
|
40
|
+
.scan(/^---\n(.+?)^(?:---|\.\.\.)\n/m)
|
41
|
+
.flatten
|
42
|
+
.map{|yaml| yaml.strip}
|
43
|
+
.join("\n")
|
71
44
|
end
|
72
45
|
|
73
46
|
# Collect the metadata embedded in the src file
|
74
47
|
def self.load_file src
|
75
48
|
yaml_metadata = extract_metadata src
|
49
|
+
|
76
50
|
if yaml_metadata.empty? then
|
77
51
|
return PandocMetadata.new
|
78
52
|
else
|
@@ -85,14 +59,13 @@ module Pandocomatic
|
|
85
59
|
merge! hash
|
86
60
|
end
|
87
61
|
|
88
|
-
def has_template?
|
89
|
-
|
90
|
-
not self['pandocomatic']['use-template'].empty?
|
62
|
+
def has_template?()
|
63
|
+
has_pandocomatic? and pandocomatic.has_key? 'use-template' and not pandocomatic['use-template'].empty?
|
91
64
|
end
|
92
65
|
|
93
|
-
def template_name
|
66
|
+
def template_name()
|
94
67
|
if has_template? then
|
95
|
-
|
68
|
+
pandocomatic['use-template']
|
96
69
|
else
|
97
70
|
''
|
98
71
|
end
|
@@ -101,18 +74,27 @@ module Pandocomatic
|
|
101
74
|
# TODO: allow a pandoc block outside a pandocomatic block to make
|
102
75
|
# pandocomatic work like paru's do-pandoc.rb.
|
103
76
|
|
104
|
-
def has_pandoc_options?
|
105
|
-
|
77
|
+
def has_pandoc_options?()
|
78
|
+
has_pandocomatic? and pandocomatic.has_key? 'pandoc'
|
106
79
|
end
|
107
80
|
|
108
|
-
def pandoc_options
|
81
|
+
def pandoc_options()
|
109
82
|
if has_pandoc_options? then
|
110
|
-
|
83
|
+
pandocomatic['pandoc']
|
111
84
|
else
|
112
85
|
{}
|
113
86
|
end
|
114
87
|
end
|
115
88
|
|
89
|
+
def has_pandocomatic?()
|
90
|
+
has_key? 'pandocomatic' or has_key? 'pandocomatic_'
|
91
|
+
end
|
92
|
+
|
93
|
+
def pandocomatic()
|
94
|
+
return self['pandocomatic'] if has_key? 'pandocomatic'
|
95
|
+
return self['pandocomatic_'] if has_key? 'pandocomatic_'
|
96
|
+
end
|
97
|
+
|
116
98
|
end
|
117
99
|
|
118
100
|
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.1.
|
4
|
+
version: 0.1.2
|
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: 2017-03-
|
11
|
+
date: 2017-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paru
|