jekyll-pandoc 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c063c91f4377065f1305bb23e9bd0ac59d27d700
4
+ data.tar.gz: cf23870d95624d068a5fafd54813fc153c3a1bb2
5
+ SHA512:
6
+ metadata.gz: 79145aff7c179f3752872308796c46e1846d0792e726b935e87abb4982f7f8097a7fe004c6350651d1c56a956f1593a72866cf677aaccaf85ea86340dde27596
7
+ data.tar.gz: a0d3041364289ea419e37b00da948f4f36dc3bfaaf80c3a574983d6ae4810454ea57deed05cb71b92473d37e5337210dcd1080558a8bde9b55dd6966817e2a97
@@ -0,0 +1,2 @@
1
+ require 'jekyll/converters/markdown'
2
+ require 'jekyll/converters/markdown/pandoc_parser'
@@ -0,0 +1,3 @@
1
+ module JekyllPandoc
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,71 @@
1
+ # monkey patch Jekyll Markdown setup method for compatibility
2
+ module Jekyll
3
+ module Converters
4
+ class Markdown
5
+
6
+ PARSERS = { 'redcarpet' => RedcarpetParser,
7
+ 'kramdown' => KramdownParser,
8
+ 'rdiscount' => RDiscountParser,
9
+ 'maruku' => MarukuParser }
10
+
11
+ def setup
12
+ return if @setup
13
+ @parser = parser(@config['markdown']).new(@config)
14
+ @setup = true
15
+ rescue NameError
16
+ Jekyll.logger.error "Invalid Markdown Processor:", "#{@config['markdown']}"
17
+ Jekyll.logger.error "", "Valid options are [ #{PARSERS.keys.join(" | ")} ]"
18
+ raise Jekyll::FatalException, "Invalid Markdown Processor: #{@config['markdown']}"
19
+ end
20
+
21
+ private
22
+
23
+ def parser(name)
24
+ if PARSERS.keys.include?(name.downcase)
25
+ PARSERS[name.downcase]
26
+ elsif name =~ /[^A-Za-z0-9]/
27
+ InvalidParser
28
+ else
29
+ eval "#{name.capitalize}Parser"
30
+ end
31
+ end
32
+
33
+ end
34
+ end
35
+ end
36
+
37
+ module Jekyll
38
+ module Converters
39
+ class Markdown
40
+ class PandocParser
41
+
42
+ def initialize(config)
43
+ require 'pandoc-ruby'
44
+ @config = config
45
+ rescue LoadError
46
+ STDERR.puts 'You are missing a library required for Pandoc. Please run:'
47
+ STDERR.puts ' $ [sudo] gem install pandoc-ruby'
48
+ raise FatalException, "Missing dependency: pandoc-ruby"
49
+ end
50
+
51
+ def convert(content)
52
+ extensions = config_option('extensions', [])
53
+ format = config_option('format', 'html5')
54
+
55
+ content = PandocRuby.new(content, *extensions).send("to_#{format}")
56
+ raise FatalException, "Conversion returned empty string" unless content.length > 0
57
+ content
58
+ end
59
+
60
+ def config_option(key, default=nil)
61
+ if @config['pandoc']
62
+ @config['pandoc'].fetch(key, default)
63
+ else
64
+ default
65
+ end
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-pandoc
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Martin Fenner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: jekyll
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: pandoc-ruby
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.7.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.7.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rdiscount
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 2.1.7
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 2.1.7
69
+ description: A Jekyll markdown converter that uses Pandoc (via the pandoc-ruby gem).
70
+ email: mf@martinfenner.org
71
+ executables: []
72
+ extensions: []
73
+ extra_rdoc_files: []
74
+ files:
75
+ - lib/jekyll-pandoc.rb
76
+ - lib/jekyll-pandoc/version.rb
77
+ - lib/jekyll/converters/markdown/pandoc_parser.rb
78
+ homepage: https://github.com/mfenner/jekyll-pandoc
79
+ licenses:
80
+ - MIT
81
+ metadata: {}
82
+ post_install_message:
83
+ rdoc_options: []
84
+ require_paths:
85
+ - lib
86
+ required_ruby_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: 1.3.6
96
+ requirements: []
97
+ rubyforge_project:
98
+ rubygems_version: 2.2.2
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Jekyll Pandoc markdown converter
102
+ test_files: []