jekyll-pypedown 0.0.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3128dbaf013ec8bc10b5b6babc77cbe2eefa2f04
4
+ data.tar.gz: d080c4539608d2ceffa9779e43b7aae5f79a9496
5
+ SHA512:
6
+ metadata.gz: 8e3aa1972d70a83b78a5a1fa542912f23367a804d422def8d8f408e0fd1b02d99f147cf405fc19d41b10ff700959b8937877f6b7f5656a726e51bfbc8d21d34c
7
+ data.tar.gz: 5cd98a4c4d2970634b771403597d51b04d19916e9913113a8d777ce41628529bffcd9a64d0f064ca9d606bb102f917913306486705e18fe55e74de1efaecea2c
@@ -0,0 +1,29 @@
1
+ require 'jekyll'
2
+
3
+ # Create a new Markdown processor that uses Pygments-flavoured kramdown
4
+ # We can only patch the converter once, so add typographic hooks with Typogruby
5
+ module Jekyll
6
+ class Pypedown < Jekyll::Converters::Markdown
7
+ # Internal requires
8
+ autoload :Kramdown, 'jekyll-pypedown/kramdown'
9
+
10
+ def initialize(config)
11
+ @config = config
12
+ if @config['pypedown']
13
+ %w[auto_ids auto_id_prefix default_lang entity_output footnote_nr smart_quotes toc_levels indent input].each do |key|
14
+ @config['pypedown'][key] = @config['kramdown'][key] unless @config['pypedown'][key]
15
+ end
16
+ elsif
17
+ @config['pypedown'] = @config['kramdown']
18
+ end
19
+ end
20
+
21
+ def convert(content)
22
+ options = Jekyll::Utils.symbolize_hash_keys(@config["pypedown"])
23
+ html = Kramdown::Document.new(content, options).to_pygs
24
+
25
+ return Typogruby.improve(html)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,64 @@
1
+ require 'pygments'
2
+ require 'typogruby'
3
+ require 'kramdown'
4
+
5
+ # Patch kramdown to use Pygments for syntax highlighting
6
+ module Kramdown
7
+ module Converter
8
+
9
+ # Subclass Html to add indent option and disable coderay
10
+ class Html
11
+ attr_accessor :indent
12
+
13
+ def initialize(root, options)
14
+ super
15
+ @footnote_counter = @footnote_start = @options[:footnote_nr]
16
+ @footnotes = []
17
+ @footnotes_by_name = {}
18
+ @footnote_location = nil
19
+ @toc = []
20
+ @toc_code = nil
21
+ @indent = @options[:indent] || 2
22
+ @stack = []
23
+ @coderay_enabled = false
24
+ end
25
+ end
26
+
27
+ # Highlight code blocks and code spans using Pygments
28
+ class Pygs < Html
29
+ def convert_codeblock(el, indent)
30
+ attr = el.attr.dup
31
+ lang = extract_code_language!(attr) || @options[:coderay_default_lang]
32
+ code = pygmentize(el.value, lang)
33
+ code_attr = {}
34
+ code_attr['class'] = "syntax syntax--#{lang}" if lang
35
+ "#{' '*indent}<pre#{html_attributes(attr)}><code#{html_attributes(code_attr)}>#{code}</code></pre>\n"
36
+ end
37
+
38
+ def convert_codespan(el, indent)
39
+ attr = el.attr.dup
40
+ lang = extract_code_language!(attr) || @options[:coderay_default_lang]
41
+ code = pygmentize(el.value, lang)
42
+ if lang
43
+ if attr.has_key?('class')
44
+ attr['class'] += " syntax syntax--#{lang}"
45
+ else
46
+ attr['class'] = "syntax syntax--#{lang}"
47
+ end
48
+ end
49
+ "<code#{html_attributes(attr)}>#{code}</code>"
50
+ end
51
+
52
+ def pygmentize(code, lang)
53
+ if lang
54
+ Pygments.highlight(code,
55
+ :lexer => lang,
56
+ :options => { :encoding => 'utf-8', :nowrap => true, :startinline => true })
57
+ else
58
+ escape_html(code)
59
+ end
60
+ end
61
+ end
62
+
63
+ end
64
+ end
@@ -0,0 +1,5 @@
1
+ module Jekyll
2
+ module Pypedown
3
+ VERSION = "0.0.0"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-pypedown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Paul Robert Lloyd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-18 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: '2.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pygments
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: typogruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: kramdown
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.4'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.4'
69
+ description: A Jekyll plugin that enables Pygments syntax highlighting for kramdown-parsed
70
+ fenced code blocks.
71
+ email: me+gems@paulrobertlloyd.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - lib/jekyll-pypedown.rb
77
+ - lib/jekyll-pypedown/kramdown.rb
78
+ - lib/jekyll-pypedown/version.rb
79
+ homepage: https://github.com/paulrobertlloyd/jekyll-pypedown
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.2.2
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Pygments + Typogruby + kramdown for Jekyll
103
+ test_files: []