pandocomatic 0.0.4 → 0.0.5

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: 270f53bbe40f85d3e270da8512c8c43b24b4f433
4
- data.tar.gz: 9d637b18ad586b9513a8eae8d5e6ed9f0d08df0b
3
+ metadata.gz: 6dd24956dd80cddb7d00b97c85b67f273aaac352
4
+ data.tar.gz: a7e58aca8742f9dd3257f7402bf7b91f641b240f
5
5
  SHA512:
6
- metadata.gz: c6ce8bb13042c452f0087ab30435c1ea72e76f509f31b475fdbd1f50f041829ff49e5b2d68efee5b731e41de397dd5694287fc3216369f9fa5503df877a5e1db
7
- data.tar.gz: a1c5c4f72999edf47d31a4afbb02285d8aab3f8b6199f0bb42a46037e81e9c6c5533e30ae671e08b78c3aa7c1abf2fc87215690aab51c1d136e270782792a48f
6
+ metadata.gz: 8a9a03171aba28b925e30434ead0a1aae0664a1d78bf322e6e828cc7434c4597947703a04894ce242781fcb5ac9195c252e529eb6fcd4221ab610a6f4464f88b
7
+ data.tar.gz: 31f06d733453f38c5d02da008fb1da0a632f4b8255f586c9dca839601dbaa3c8770a92f98a1471a8350ca5f9c0bdd6d5ae438bbbcc5060d61de6bcf32c566a3a
@@ -1,6 +1,6 @@
1
1
  settings:
2
2
  recursive: true
3
- follow-symlinks: true
3
+ follow-symlinks: false
4
4
  skip: ['.*', 'pandocomatic.yaml']
5
5
  templates:
6
6
  markdown-to-html:
@@ -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
- output = Processor.run(@config.update_path(type, processor), output)
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
- json_reader = Paru::Pandoc.new {from 'markdown'; to 'json'}
20
- json_document = JSON.parse json_reader << File.read(src)
21
- if json_document.first["unMeta"].empty? then
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
- json_metadata = [json_document.first, []]
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
- has_key? 'pandocomatic' and
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
- has_key? 'pandocomatic' and self['pandocomatic'].has_key? 'pandoc'
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
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-21 00:00:00.000000000 Z
11
+ date: 2015-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paru