jekyll-pypedown 0.0.1 → 0.0.2

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: b420396b59f49fcbafc8ce0e01bb591a8a1ed116
4
- data.tar.gz: 9027d7e5f3f5907fb7420bc0e94e6ce95b5a40dc
3
+ metadata.gz: 4f0595e2e583784ac03bd806d204a8fde5d819a1
4
+ data.tar.gz: 43b775b241b9228596a414af5ef6510713a01dda
5
5
  SHA512:
6
- metadata.gz: a95d1bb54b67700e76027f7dcd0eebd4d1c3b8b9deb86d8a98bdff7c2261cdd657c93b342bb53ddcb455d3de286b89e16fc273414de483fe5eb4ab9e105b252f
7
- data.tar.gz: fda138d06aac038fec08ec65cfb6462df7ad83991ce72dec2d6f96ff711bf8a004093c51b13c236506ab2593bb29da38969c2db65ffa0b29a7d310c0a159f150
6
+ metadata.gz: 6394bcf0cfec454f385ddf552e853fccd731d9ea7df5a56a1967f766e2b71e326609e6603d2508c9a933735fde54900b47d5bffc6035428dbbebc75fecdc39af
7
+ data.tar.gz: a50e2a5295d77c9cdf092f15feebc1228a5aedf28e1590d69891e3ab5800d6e741538b913f17b148aaa3e46cb073e4f44f806f5fd8c68199f30463d05307031c
@@ -1,29 +1,11 @@
1
+ require 'pygments.rb'
2
+ require 'typogruby'
3
+ require 'kramdown'
4
+ require 'kramdown/converter/html_pygments'
1
5
  require 'jekyll'
6
+ require 'jekyll/converters/markdown/pypedown'
2
7
 
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
8
  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
-
9
+ module Pypedown
28
10
  end
29
11
  end
@@ -1,5 +1,5 @@
1
1
  module Jekyll
2
2
  module Pypedown
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -0,0 +1,38 @@
1
+ module Jekyll
2
+ module Converters
3
+
4
+ class Markdown::Pypedown
5
+ def initialize(config)
6
+ @config = config
7
+
8
+ # Kramdown
9
+ if @config['pypedown']
10
+ %w[auto_ids auto_id_prefix default_lang entity_output footnote_nr smart_quotes toc_levels indent input].each do |key|
11
+ @config['pypedown'][key] = @config['kramdown'][key] unless @config['pypedown'][key]
12
+ end
13
+ elsif
14
+ @config['pypedown'] = @config['kramdown']
15
+ end
16
+
17
+ # Typogruby
18
+ if @config['pypedown']['typogruby'].nil?
19
+ @typogruby_enabled = true
20
+ else
21
+ @typogruby_enabled = false
22
+ end
23
+ end
24
+
25
+ def convert(content)
26
+ options = Jekyll::Utils.symbolize_hash_keys(@config["pypedown"])
27
+ html = Kramdown::Document.new(content, options).to_html_pygments
28
+
29
+ if @typogruby_enabled == true
30
+ return Typogruby.improve(html)
31
+ else
32
+ return html
33
+ end
34
+ end
35
+ end
36
+
37
+ end
38
+ end
@@ -1,13 +1,7 @@
1
- require 'pygments'
2
- require 'typogruby'
3
- require 'kramdown'
4
-
5
- # Patch kramdown to use Pygments for syntax highlighting
6
1
  module Kramdown
7
2
  module Converter
8
3
 
9
- # Subclass Html to add indent option and disable coderay
10
- class Html
4
+ class HtmlPygments < Html
11
5
  attr_accessor :indent
12
6
 
13
7
  def initialize(root, options)
@@ -18,32 +12,29 @@ module Kramdown
18
12
  @footnote_location = nil
19
13
  @toc = []
20
14
  @toc_code = nil
21
- @indent = @options[:indent] || 2
15
+ @indent = @options[:indent] || 4
22
16
  @stack = []
23
17
  @coderay_enabled = false
24
18
  end
25
- end
26
19
 
27
- # Highlight code blocks and code spans using Pygments
28
- class Pygs < Html
29
20
  def convert_codeblock(el, indent)
30
21
  attr = el.attr.dup
31
- lang = extract_code_language!(attr) || @options[:coderay_default_lang]
22
+ lang = extract_code_language!(attr) || @options[:default_lang]
32
23
  code = pygmentize(el.value, lang)
33
24
  code_attr = {}
34
- code_attr['class'] = "syntax syntax--#{lang}" if lang
25
+ code_attr['class'] = "language-#{lang}" if lang
35
26
  "#{' '*indent}<pre#{html_attributes(attr)}><code#{html_attributes(code_attr)}>#{code}</code></pre>\n"
36
27
  end
37
28
 
38
29
  def convert_codespan(el, indent)
39
30
  attr = el.attr.dup
40
- lang = extract_code_language!(attr) || @options[:coderay_default_lang]
31
+ lang = extract_code_language!(attr) || @options[:default_lang]
41
32
  code = pygmentize(el.value, lang)
42
33
  if lang
43
34
  if attr.has_key?('class')
44
- attr['class'] += " syntax syntax--#{lang}"
35
+ attr['class'] += " language-#{lang}"
45
36
  else
46
- attr['class'] = "syntax syntax--#{lang}"
37
+ attr['class'] = "language-#{lang}"
47
38
  end
48
39
  end
49
40
  "<code#{html_attributes(attr)}>#{code}</code>"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-pypedown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Robert Lloyd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-18 00:00:00.000000000 Z
11
+ date: 2014-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -74,8 +74,9 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - lib/jekyll-pypedown.rb
77
- - lib/jekyll-pypedown/kramdown.rb
78
77
  - lib/jekyll-pypedown/version.rb
78
+ - lib/jekyll/converters/markdown/pypedown.rb
79
+ - lib/kramdown/converter/html_pygments.rb
79
80
  homepage: https://github.com/paulrobertlloyd/jekyll-pypedown
80
81
  licenses:
81
82
  - MIT