jekyll-docs 3.6.0 → 3.6.1

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.
Files changed (253) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jekyll.rb +195 -0
  3. data/lib/jekyll/cleaner.rb +110 -0
  4. data/lib/jekyll/collection.rb +230 -0
  5. data/lib/jekyll/command.rb +78 -0
  6. data/lib/jekyll/commands/build.rb +102 -0
  7. data/lib/jekyll/commands/clean.rb +43 -0
  8. data/lib/jekyll/commands/doctor.rb +153 -0
  9. data/lib/jekyll/commands/help.rb +34 -0
  10. data/lib/jekyll/commands/new.rb +156 -0
  11. data/lib/jekyll/commands/new_theme.rb +40 -0
  12. data/lib/jekyll/commands/serve.rb +245 -0
  13. data/lib/jekyll/commands/serve/servlet.rb +62 -0
  14. data/lib/jekyll/configuration.rb +410 -0
  15. data/lib/jekyll/converter.rb +54 -0
  16. data/lib/jekyll/converters/identity.rb +23 -0
  17. data/lib/jekyll/converters/markdown.rb +104 -0
  18. data/lib/jekyll/converters/markdown/kramdown_parser.rb +123 -0
  19. data/lib/jekyll/converters/markdown/rdiscount_parser.rb +35 -0
  20. data/lib/jekyll/converters/markdown/redcarpet_parser.rb +108 -0
  21. data/lib/jekyll/converters/smartypants.rb +36 -0
  22. data/lib/jekyll/convertible.rb +251 -0
  23. data/lib/jekyll/deprecator.rb +52 -0
  24. data/lib/jekyll/document.rb +507 -0
  25. data/lib/jekyll/drops/collection_drop.rb +22 -0
  26. data/lib/jekyll/drops/document_drop.rb +69 -0
  27. data/lib/jekyll/drops/drop.rb +214 -0
  28. data/lib/jekyll/drops/excerpt_drop.rb +15 -0
  29. data/lib/jekyll/drops/jekyll_drop.rb +33 -0
  30. data/lib/jekyll/drops/site_drop.rb +47 -0
  31. data/lib/jekyll/drops/static_file_drop.rb +13 -0
  32. data/lib/jekyll/drops/unified_payload_drop.rb +25 -0
  33. data/lib/jekyll/drops/url_drop.rb +88 -0
  34. data/lib/jekyll/entry_filter.rb +123 -0
  35. data/lib/jekyll/errors.rb +20 -0
  36. data/lib/jekyll/excerpt.rb +126 -0
  37. data/lib/jekyll/external.rb +74 -0
  38. data/lib/jekyll/filters.rb +430 -0
  39. data/lib/jekyll/filters/grouping_filters.rb +65 -0
  40. data/lib/jekyll/filters/url_filters.rb +60 -0
  41. data/lib/jekyll/frontmatter_defaults.rb +197 -0
  42. data/lib/jekyll/generator.rb +5 -0
  43. data/lib/jekyll/hooks.rb +104 -0
  44. data/lib/jekyll/layout.rb +62 -0
  45. data/lib/jekyll/liquid_extensions.rb +24 -0
  46. data/lib/jekyll/liquid_renderer.rb +49 -0
  47. data/lib/jekyll/liquid_renderer/file.rb +56 -0
  48. data/lib/jekyll/liquid_renderer/table.rb +96 -0
  49. data/lib/jekyll/log_adapter.rb +147 -0
  50. data/lib/jekyll/mime.types +825 -0
  51. data/lib/jekyll/page.rb +187 -0
  52. data/lib/jekyll/plugin.rb +98 -0
  53. data/lib/jekyll/plugin_manager.rb +113 -0
  54. data/lib/jekyll/publisher.rb +23 -0
  55. data/lib/jekyll/reader.rb +134 -0
  56. data/lib/jekyll/readers/collection_reader.rb +22 -0
  57. data/lib/jekyll/readers/data_reader.rb +77 -0
  58. data/lib/jekyll/readers/layout_reader.rb +71 -0
  59. data/lib/jekyll/readers/page_reader.rb +25 -0
  60. data/lib/jekyll/readers/post_reader.rb +72 -0
  61. data/lib/jekyll/readers/static_file_reader.rb +25 -0
  62. data/lib/jekyll/readers/theme_assets_reader.rb +49 -0
  63. data/lib/jekyll/regenerator.rb +201 -0
  64. data/lib/jekyll/related_posts.rb +52 -0
  65. data/lib/jekyll/renderer.rb +269 -0
  66. data/lib/jekyll/site.rb +471 -0
  67. data/lib/jekyll/static_file.rb +162 -0
  68. data/lib/jekyll/stevenson.rb +61 -0
  69. data/lib/jekyll/tags/highlight.rb +141 -0
  70. data/lib/jekyll/tags/include.rb +215 -0
  71. data/lib/jekyll/tags/link.rb +37 -0
  72. data/lib/jekyll/tags/post_url.rb +103 -0
  73. data/lib/jekyll/theme.rb +68 -0
  74. data/lib/jekyll/theme_builder.rb +119 -0
  75. data/lib/jekyll/url.rb +161 -0
  76. data/lib/jekyll/utils.rb +337 -0
  77. data/lib/jekyll/utils/ansi.rb +59 -0
  78. data/lib/jekyll/utils/exec.rb +27 -0
  79. data/lib/jekyll/utils/platforms.rb +82 -0
  80. data/lib/jekyll/utils/rouge.rb +21 -0
  81. data/lib/jekyll/utils/win_tz.rb +75 -0
  82. data/lib/jekyll/version.rb +5 -0
  83. data/lib/site_template/404.html +24 -0
  84. data/lib/site_template/_config.yml +43 -0
  85. data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +25 -0
  86. data/lib/site_template/about.md +18 -0
  87. data/lib/site_template/index.md +6 -0
  88. data/lib/theme_template/CODE_OF_CONDUCT.md.erb +74 -0
  89. data/lib/theme_template/Gemfile +4 -0
  90. data/lib/theme_template/LICENSE.txt.erb +21 -0
  91. data/lib/theme_template/README.md.erb +52 -0
  92. data/lib/theme_template/_layouts/default.html +1 -0
  93. data/lib/theme_template/_layouts/page.html +5 -0
  94. data/lib/theme_template/_layouts/post.html +5 -0
  95. data/lib/theme_template/example/_config.yml.erb +1 -0
  96. data/lib/theme_template/example/_post.md +12 -0
  97. data/lib/theme_template/example/index.html +14 -0
  98. data/lib/theme_template/example/style.scss +7 -0
  99. data/lib/theme_template/gitignore.erb +5 -0
  100. data/lib/theme_template/theme.gemspec.erb +19 -0
  101. metadata +103 -156
  102. data/lib/jekyll-docs.rb +0 -31
  103. data/site/404.html +0 -153
  104. data/site/CNAME +0 -1
  105. data/site/community/index.html +0 -299
  106. data/site/conduct/index.html +0 -10
  107. data/site/css/screen.css +0 -1
  108. data/site/docs/assets/index.html +0 -724
  109. data/site/docs/code_of_conduct/index.html +0 -730
  110. data/site/docs/collections/index.html +0 -1097
  111. data/site/docs/conduct/index.html +0 -744
  112. data/site/docs/configuration/index.html +0 -1403
  113. data/site/docs/continuous-integration/buddyworks/index.html +0 -726
  114. data/site/docs/continuous-integration/circleci/index.html +0 -757
  115. data/site/docs/continuous-integration/index.html +0 -681
  116. data/site/docs/continuous-integration/travis-ci/index.html +0 -891
  117. data/site/docs/contributing/index.html +0 -863
  118. data/site/docs/datafiles/index.html +0 -780
  119. data/site/docs/deployment-methods/index.html +0 -875
  120. data/site/docs/drafts/index.html +0 -636
  121. data/site/docs/extras/index.html +0 -689
  122. data/site/docs/frontmatter/index.html +0 -807
  123. data/site/docs/github-pages/index.html +0 -819
  124. data/site/docs/history/index.html +0 -3955
  125. data/site/docs/home/index.html +0 -644
  126. data/site/docs/includes/index.html +0 -800
  127. data/site/docs/index.html +0 -10
  128. data/site/docs/installation/index.html +0 -732
  129. data/site/docs/maintaining/affinity-team-captain/index.html +0 -706
  130. data/site/docs/maintaining/avoiding-burnout/index.html +0 -709
  131. data/site/docs/maintaining/becoming-a-maintainer/index.html +0 -717
  132. data/site/docs/maintaining/index.html +0 -713
  133. data/site/docs/maintaining/merging-a-pull-request/index.html +0 -747
  134. data/site/docs/maintaining/reviewing-a-pull-request/index.html +0 -725
  135. data/site/docs/maintaining/special-labels/index.html +0 -705
  136. data/site/docs/maintaining/triaging-an-issue/index.html +0 -735
  137. data/site/docs/migrations/index.html +0 -647
  138. data/site/docs/pages/index.html +0 -695
  139. data/site/docs/pagination/index.html +0 -870
  140. data/site/docs/permalinks/index.html +0 -1027
  141. data/site/docs/plugins/index.html +0 -1800
  142. data/site/docs/posts/index.html +0 -858
  143. data/site/docs/quickstart/index.html +0 -650
  144. data/site/docs/resources/index.html +0 -769
  145. data/site/docs/sites/index.html +0 -702
  146. data/site/docs/static-files/index.html +0 -720
  147. data/site/docs/structure/index.html +0 -822
  148. data/site/docs/templates/index.html +0 -1208
  149. data/site/docs/themes/index.html +0 -935
  150. data/site/docs/troubleshooting/index.html +0 -893
  151. data/site/docs/upgrading/0-to-2/index.html +0 -826
  152. data/site/docs/upgrading/2-to-3/index.html +0 -824
  153. data/site/docs/upgrading/index.html +0 -693
  154. data/site/docs/usage/index.html +0 -705
  155. data/site/docs/variables/index.html +0 -1048
  156. data/site/docs/windows/index.html +0 -799
  157. data/site/favicon.ico +0 -0
  158. data/site/feed.xml +0 -372
  159. data/site/fonts/FontAwesome.eot +0 -0
  160. data/site/fonts/FontAwesome.svg +0 -12
  161. data/site/fonts/FontAwesome.ttf +0 -0
  162. data/site/fonts/FontAwesome.woff +0 -0
  163. data/site/github.html +0 -10
  164. data/site/help/index.html +0 -244
  165. data/site/icomoon-selection.json +0 -96
  166. data/site/img/article-footer.png +0 -0
  167. data/site/img/footer-arrow.png +0 -0
  168. data/site/img/footer-logo.png +0 -0
  169. data/site/img/jekyll-sticker.jpg +0 -0
  170. data/site/img/jekylllayoutconcept.png +0 -0
  171. data/site/img/logo-2x.png +0 -0
  172. data/site/img/logo-rss.png +0 -0
  173. data/site/img/octojekyll.png +0 -0
  174. data/site/index.html +0 -267
  175. data/site/issues.html +0 -10
  176. data/site/js/html5shiv.min.js +0 -4
  177. data/site/js/respond.min.js +0 -5
  178. data/site/latest_version.txt +0 -1
  179. data/site/news/2013/05/05/jekyll-1-0-0-released/index.html +0 -570
  180. data/site/news/2013/05/08/jekyll-1-0-1-released/index.html +0 -570
  181. data/site/news/2013/05/12/jekyll-1-0-2-released/index.html +0 -571
  182. data/site/news/2013/06/07/jekyll-1-0-3-released/index.html +0 -568
  183. data/site/news/2013/07/14/jekyll-1-1-0-released/index.html +0 -570
  184. data/site/news/2013/07/24/jekyll-1-1-1-released/index.html +0 -569
  185. data/site/news/2013/07/25/jekyll-1-0-4-released/index.html +0 -565
  186. data/site/news/2013/07/25/jekyll-1-1-2-released/index.html +0 -565
  187. data/site/news/2013/09/06/jekyll-1-2-0-released/index.html +0 -572
  188. data/site/news/2013/09/14/jekyll-1-2-1-released/index.html +0 -566
  189. data/site/news/2013/10/28/jekyll-1-3-0-rc1-released/index.html +0 -564
  190. data/site/news/2013/11/04/jekyll-1-3-0-released/index.html +0 -599
  191. data/site/news/2013/11/26/jekyll-1-3-1-released/index.html +0 -568
  192. data/site/news/2013/12/07/jekyll-1-4-0-released/index.html +0 -583
  193. data/site/news/2013/12/09/jekyll-1-4-1-released/index.html +0 -565
  194. data/site/news/2013/12/16/jekyll-1-4-2-released/index.html +0 -564
  195. data/site/news/2014/01/13/jekyll-1-4-3-released/index.html +0 -573
  196. data/site/news/2014/03/24/jekyll-1-5-0-released/index.html +0 -564
  197. data/site/news/2014/03/27/jekyll-1-5-1-released/index.html +0 -569
  198. data/site/news/2014/05/06/jekyll-turns-2-0-0/index.html +0 -585
  199. data/site/news/2014/05/08/jekyll-2-0-3-released/index.html +0 -565
  200. data/site/news/2014/06/04/jekyll-stickers-1-dollar-stickermule/index.html +0 -567
  201. data/site/news/2014/06/28/jekyll-turns-21-i-mean-2-1-0/index.html +0 -582
  202. data/site/news/2014/07/01/jekyll-2-1-1-released/index.html +0 -579
  203. data/site/news/2014/07/29/jekyll-2-2-0-released/index.html +0 -568
  204. data/site/news/2014/08/10/jekyll-2-3-0-released/index.html +0 -588
  205. data/site/news/2014/09/09/jekyll-2-4-0-released/index.html +0 -574
  206. data/site/news/2014/11/05/jekylls-midlife-crisis-jekyll-turns-2-5-0/index.html +0 -597
  207. data/site/news/2014/11/09/jekyll-2-5-1-released/index.html +0 -575
  208. data/site/news/2014/11/12/jekyll-2-5-2-released/index.html +0 -565
  209. data/site/news/2014/12/17/alfredxing-welcome-to-jekyll-core/index.html +0 -572
  210. data/site/news/2014/12/22/jekyll-2-5-3-released/index.html +0 -567
  211. data/site/news/2015/01/20/jekyll-meet-and-greet/index.html +0 -568
  212. data/site/news/2015/01/24/jekyll-3-0-0-beta1-released/index.html +0 -588
  213. data/site/news/2015/02/26/introducing-jekyll-talk/index.html +0 -563
  214. data/site/news/2015/10/26/jekyll-3-0-released/index.html +0 -592
  215. data/site/news/2015/11/17/jekyll-3-0-1-released/index.html +0 -576
  216. data/site/news/2016/01/20/jekyll-3-0-2-released/index.html +0 -566
  217. data/site/news/2016/01/24/jekyll-3-1-0-released/index.html +0 -599
  218. data/site/news/2016/01/28/jekyll-3-1-1-released/index.html +0 -583
  219. data/site/news/2016/02/08/jekyll-3-0-3-released/index.html +0 -578
  220. data/site/news/2016/02/19/jekyll-3-1-2-released/index.html +0 -569
  221. data/site/news/2016/03/10/making-it-easier-to-contribute-to-jekyll/index.html +0 -565
  222. data/site/news/2016/04/19/jekyll-3-0-4-released/index.html +0 -571
  223. data/site/news/2016/04/19/jekyll-3-1-3-released/index.html +0 -566
  224. data/site/news/2016/04/26/jekyll-3-0-5-released/index.html +0 -572
  225. data/site/news/2016/05/18/jekyll-3-1-4-released/index.html +0 -576
  226. data/site/news/2016/05/18/jekyll-3-1-5-released/index.html +0 -564
  227. data/site/news/2016/05/19/jekyll-3-1-6-released/index.html +0 -566
  228. data/site/news/2016/06/03/update-on-jekyll-s-google-summer-of-code-projects/index.html +0 -567
  229. data/site/news/2016/07/26/jekyll-3-2-0-released/index.html +0 -676
  230. data/site/news/2016/08/02/jekyll-3-2-1-released/index.html +0 -571
  231. data/site/news/2016/08/24/jekyll-admin-initial-release/index.html +0 -566
  232. data/site/news/2016/10/06/jekyll-3-3-is-here/index.html +0 -645
  233. data/site/news/2016/11/14/jekyll-3-3-1-released/index.html +0 -569
  234. data/site/news/2017/01/18/jekyll-3-4-0-released/index.html +0 -592
  235. data/site/news/2017/03/02/jekyll-3-4-1-released/index.html +0 -649
  236. data/site/news/2017/03/09/jekyll-3-4-2-released/index.html +0 -598
  237. data/site/news/2017/03/21/jekyll-3-4-3-released/index.html +0 -594
  238. data/site/news/2017/06/15/jekyll-3-5-0-released/index.html +0 -589
  239. data/site/news/2017/07/17/jekyll-3-5-1-released/index.html +0 -569
  240. data/site/news/2017/08/12/jekyll-3-5-2-released/index.html +0 -573
  241. data/site/news/2017/09/21/jekyll-3-6-0-released/index.html +0 -565
  242. data/site/news/index.html +0 -3609
  243. data/site/news/releases/index.html +0 -3344
  244. data/site/philosophy.html +0 -46
  245. data/site/readme.md +0 -23
  246. data/site/robots.txt +0 -1
  247. data/site/sitemap.xml +0 -485
  248. data/site/tutorials/convert-site-to-jekyll/index.html +0 -793
  249. data/site/tutorials/custom-404-page/index.html +0 -358
  250. data/site/tutorials/home/index.html +0 -323
  251. data/site/tutorials/index.html +0 -10
  252. data/site/tutorials/navigation/index.html +0 -872
  253. data/site/tutorials/orderofinterpretation/index.html +0 -441
@@ -0,0 +1,54 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ class Converter < Plugin
5
+ # Public: Get or set the highlighter prefix. When an argument is specified,
6
+ # the prefix will be set. If no argument is specified, the current prefix
7
+ # will be returned.
8
+ #
9
+ # highlighter_prefix - The String prefix (default: nil).
10
+ #
11
+ # Returns the String prefix.
12
+ def self.highlighter_prefix(highlighter_prefix = nil)
13
+ unless defined?(@highlighter_prefix) && highlighter_prefix.nil?
14
+ @highlighter_prefix = highlighter_prefix
15
+ end
16
+ @highlighter_prefix
17
+ end
18
+
19
+ # Public: Get or set the highlighter suffix. When an argument is specified,
20
+ # the suffix will be set. If no argument is specified, the current suffix
21
+ # will be returned.
22
+ #
23
+ # highlighter_suffix - The String suffix (default: nil).
24
+ #
25
+ # Returns the String suffix.
26
+ def self.highlighter_suffix(highlighter_suffix = nil)
27
+ unless defined?(@highlighter_suffix) && highlighter_suffix.nil?
28
+ @highlighter_suffix = highlighter_suffix
29
+ end
30
+ @highlighter_suffix
31
+ end
32
+
33
+ # Initialize the converter.
34
+ #
35
+ # Returns an initialized Converter.
36
+ def initialize(config = {})
37
+ @config = config
38
+ end
39
+
40
+ # Get the highlighter prefix.
41
+ #
42
+ # Returns the String prefix.
43
+ def highlighter_prefix
44
+ self.class.highlighter_prefix
45
+ end
46
+
47
+ # Get the highlighter suffix.
48
+ #
49
+ # Returns the String suffix.
50
+ def highlighter_suffix
51
+ self.class.highlighter_suffix
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Converters
5
+ class Identity < Converter
6
+ safe true
7
+
8
+ priority :lowest
9
+
10
+ def matches(_ext)
11
+ true
12
+ end
13
+
14
+ def output_ext(ext)
15
+ ext
16
+ end
17
+
18
+ def convert(content)
19
+ content
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Converters
5
+ class Markdown < Converter
6
+ highlighter_prefix "\n"
7
+ highlighter_suffix "\n"
8
+ safe true
9
+
10
+ def setup
11
+ return if @setup ||= false
12
+ unless (@parser = get_processor)
13
+ Jekyll.logger.error "Invalid Markdown processor given:", @config["markdown"]
14
+ if @config["safe"]
15
+ Jekyll.logger.info "", "Custom processors are not loaded in safe mode"
16
+ end
17
+ Jekyll.logger.error(
18
+ "",
19
+ "Available processors are: #{valid_processors.join(", ")}"
20
+ )
21
+ raise Errors::FatalException, "Bailing out; invalid Markdown processor."
22
+ end
23
+
24
+ @setup = true
25
+ end
26
+
27
+ # Rubocop does not allow reader methods to have names starting with `get_`
28
+ # To ensure compatibility, this check has been disabled on this method
29
+ #
30
+ # rubocop:disable Naming/AccessorMethodName
31
+ def get_processor
32
+ case @config["markdown"].downcase
33
+ when "redcarpet" then return RedcarpetParser.new(@config)
34
+ when "kramdown" then return KramdownParser.new(@config)
35
+ when "rdiscount" then return RDiscountParser.new(@config)
36
+ else
37
+ custom_processor
38
+ end
39
+ end
40
+ # rubocop:enable Naming/AccessorMethodName
41
+
42
+ # Public: Provides you with a list of processors, the ones we
43
+ # support internally and the ones that you have provided to us (if you
44
+ # are not in safe mode.)
45
+
46
+ def valid_processors
47
+ %W(rdiscount kramdown redcarpet) + third_party_processors
48
+ end
49
+
50
+ # Public: A list of processors that you provide via plugins.
51
+ # This is really only available if you are not in safe mode, if you are
52
+ # in safe mode (re: GitHub) then there will be none.
53
+
54
+ def third_party_processors
55
+ self.class.constants - \
56
+ %w(KramdownParser RDiscountParser RedcarpetParser PRIORITIES).map(
57
+ &:to_sym
58
+ )
59
+ end
60
+
61
+ def extname_list
62
+ @extname_list ||= @config["markdown_ext"].split(",").map do |e|
63
+ ".#{e.downcase}"
64
+ end
65
+ end
66
+
67
+ def matches(ext)
68
+ extname_list.include?(ext.downcase)
69
+ end
70
+
71
+ def output_ext(_ext)
72
+ ".html"
73
+ end
74
+
75
+ def convert(content)
76
+ setup
77
+ @parser.convert(content)
78
+ end
79
+
80
+ private
81
+ def custom_processor
82
+ converter_name = @config["markdown"]
83
+ if custom_class_allowed?(converter_name)
84
+ self.class.const_get(converter_name).new(@config)
85
+ end
86
+ end
87
+
88
+ # Private: Determine whether a class name is an allowed custom
89
+ # markdown class name.
90
+ #
91
+ # parser_name - the name of the parser class
92
+ #
93
+ # Returns true if the parser name contains only alphanumeric
94
+ # characters and is defined within Jekyll::Converters::Markdown
95
+
96
+ private
97
+ def custom_class_allowed?(parser_name)
98
+ parser_name !~ %r![^A-Za-z0-9_]! && self.class.constants.include?(
99
+ parser_name.to_sym
100
+ )
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,123 @@
1
+ # Frozen-string-literal: true
2
+ # Encoding: utf-8
3
+
4
+ module Jekyll
5
+ module Converters
6
+ class Markdown
7
+ class KramdownParser
8
+ CODERAY_DEFAULTS = {
9
+ "css" => "style",
10
+ "bold_every" => 10,
11
+ "line_numbers" => "inline",
12
+ "line_number_start" => 1,
13
+ "tab_width" => 4,
14
+ "wrap" => "div",
15
+ }.freeze
16
+
17
+ def initialize(config)
18
+ Jekyll::External.require_with_graceful_fail "kramdown"
19
+ @main_fallback_highlighter = config["highlighter"] || "rouge"
20
+ @config = config["kramdown"] || {}
21
+ @highlighter = nil
22
+ setup
23
+ end
24
+
25
+ # Setup and normalize the configuration:
26
+ # * Create Kramdown if it doesn't exist.
27
+ # * Set syntax_highlighter, detecting enable_coderay and merging
28
+ # highlighter if none.
29
+ # * Merge kramdown[coderay] into syntax_highlighter_opts stripping coderay_.
30
+ # * Make sure `syntax_highlighter_opts` exists.
31
+
32
+ def setup
33
+ @config["syntax_highlighter"] ||= highlighter
34
+ @config["syntax_highlighter_opts"] ||= {}
35
+ @config["coderay"] ||= {} # XXX: Legacy.
36
+ modernize_coderay_config
37
+ make_accessible
38
+ end
39
+
40
+ def convert(content)
41
+ Kramdown::Document.new(content, @config).to_html
42
+ end
43
+
44
+ private
45
+ # rubocop:disable Performance/HashEachMethods
46
+ def make_accessible(hash = @config)
47
+ hash.keys.each do |key|
48
+ hash[key.to_sym] = hash[key]
49
+ make_accessible(hash[key]) if hash[key].is_a?(Hash)
50
+ end
51
+ end
52
+ # rubocop:enable Performance/HashEachMethods
53
+
54
+ # config[kramdown][syntax_higlighter] >
55
+ # config[kramdown][enable_coderay] >
56
+ # config[highlighter]
57
+ # Where `enable_coderay` is now deprecated because Kramdown
58
+ # supports Rouge now too.
59
+
60
+ private
61
+ def highlighter
62
+ return @highlighter if @highlighter
63
+
64
+ if @config["syntax_highlighter"]
65
+ return @highlighter = @config[
66
+ "syntax_highlighter"
67
+ ]
68
+ end
69
+
70
+ @highlighter = begin
71
+ if @config.key?("enable_coderay") && @config["enable_coderay"]
72
+ Jekyll::Deprecator.deprecation_message(
73
+ "You are using 'enable_coderay', " \
74
+ "use syntax_highlighter: coderay in your configuration file."
75
+ )
76
+
77
+ "coderay"
78
+ else
79
+ @main_fallback_highlighter
80
+ end
81
+ end
82
+ end
83
+
84
+ private
85
+ def strip_coderay_prefix(hash)
86
+ hash.each_with_object({}) do |(key, val), hsh|
87
+ cleaned_key = key.to_s.gsub(%r!\Acoderay_!, "")
88
+
89
+ if key != cleaned_key
90
+ Jekyll::Deprecator.deprecation_message(
91
+ "You are using '#{key}'. Normalizing to #{cleaned_key}."
92
+ )
93
+ end
94
+
95
+ hsh[cleaned_key] = val
96
+ end
97
+ end
98
+
99
+ # If our highlighter is CodeRay we go in to merge the CodeRay defaults
100
+ # with your "coderay" key if it's there, deprecating it in the
101
+ # process of you using it.
102
+
103
+ private
104
+ def modernize_coderay_config
105
+ unless @config["coderay"].empty?
106
+ Jekyll::Deprecator.deprecation_message(
107
+ "You are using 'kramdown.coderay' in your configuration, " \
108
+ "please use 'syntax_highlighter_opts' instead."
109
+ )
110
+
111
+ @config["syntax_highlighter_opts"] = begin
112
+ strip_coderay_prefix(
113
+ @config["syntax_highlighter_opts"] \
114
+ .merge(CODERAY_DEFAULTS) \
115
+ .merge(@config["coderay"])
116
+ )
117
+ end
118
+ end
119
+ end
120
+ end
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module Converters
5
+ class Markdown
6
+ class RDiscountParser
7
+ def initialize(config)
8
+ Jekyll::External.require_with_graceful_fail "rdiscount"
9
+ @config = config
10
+ @rdiscount_extensions = @config["rdiscount"]["extensions"].map(&:to_sym)
11
+ end
12
+
13
+ def convert(content)
14
+ rd = RDiscount.new(content, *@rdiscount_extensions)
15
+ html = rd.to_html
16
+ if @config["rdiscount"]["toc_token"]
17
+ html = replace_generated_toc(rd, html, @config["rdiscount"]["toc_token"])
18
+ end
19
+ html
20
+ end
21
+
22
+ private
23
+ def replace_generated_toc(rd, html, toc_token)
24
+ if rd.generate_toc && html.include?(toc_token)
25
+ utf8_toc = rd.toc_content
26
+ utf8_toc.force_encoding("utf-8") if utf8_toc.respond_to?(:force_encoding)
27
+ html.gsub(toc_token, utf8_toc)
28
+ else
29
+ html
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,108 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Jekyll::Converters::Markdown::RedcarpetParser
4
+ module CommonMethods
5
+ def add_code_tags(code, lang)
6
+ code = code.to_s
7
+ code = code.sub(
8
+ %r!<pre>!,
9
+ "<pre><code class=\"language-#{lang}\" data-lang=\"#{lang}\">"
10
+ )
11
+ code = code.sub(%r!</pre>!, "</code></pre>")
12
+ code
13
+ end
14
+ end
15
+
16
+ module WithPygments
17
+ include CommonMethods
18
+ def block_code(code, lang)
19
+ Jekyll::External.require_with_graceful_fail("pygments")
20
+ lang = lang && lang.split.first || "text"
21
+ add_code_tags(
22
+ Pygments.highlight(
23
+ code,
24
+ {
25
+ :lexer => lang,
26
+ :options => { :encoding => "utf-8" },
27
+ }
28
+ ),
29
+ lang
30
+ )
31
+ end
32
+ end
33
+
34
+ module WithoutHighlighting
35
+ require "cgi"
36
+
37
+ include CommonMethods
38
+
39
+ def code_wrap(code)
40
+ "<figure class=\"highlight\"><pre>#{CGI.escapeHTML(code)}</pre></figure>"
41
+ end
42
+
43
+ def block_code(code, lang)
44
+ lang = lang && lang.split.first || "text"
45
+ add_code_tags(code_wrap(code), lang)
46
+ end
47
+ end
48
+
49
+ module WithRouge
50
+ def block_code(code, lang)
51
+ code = "<pre>#{super}</pre>"
52
+
53
+ "<div class=\"highlight\">#{add_code_tags(code, lang)}</div>"
54
+ end
55
+
56
+ protected
57
+ def rouge_formatter(_lexer)
58
+ Jekyll::Utils::Rouge.html_formatter(:wrap => false)
59
+ end
60
+ end
61
+
62
+ def initialize(config)
63
+ Jekyll::External.require_with_graceful_fail("redcarpet")
64
+ @config = config
65
+ @redcarpet_extensions = {}
66
+ @config["redcarpet"]["extensions"].each do |e|
67
+ @redcarpet_extensions[e.to_sym] = true
68
+ end
69
+
70
+ @renderer ||= class_with_proper_highlighter(@config["highlighter"])
71
+ end
72
+
73
+ def class_with_proper_highlighter(highlighter)
74
+ Class.new(Redcarpet::Render::HTML) do
75
+ case highlighter
76
+ when "pygments"
77
+ include WithPygments
78
+ when "rouge"
79
+ Jekyll::External.require_with_graceful_fail(%w(
80
+ rouge rouge/plugins/redcarpet
81
+ ))
82
+
83
+ unless Gem::Version.new(Rouge.version) > Gem::Version.new("1.3.0")
84
+ abort "Please install Rouge 1.3.0 or greater and try running Jekyll again."
85
+ end
86
+
87
+ include Rouge::Plugins::Redcarpet
88
+ include CommonMethods
89
+ include WithRouge
90
+ else
91
+ include WithoutHighlighting
92
+ end
93
+ end
94
+ end
95
+
96
+ def convert(content)
97
+ @redcarpet_extensions[:fenced_code_blocks] = \
98
+ !@redcarpet_extensions[:no_fenced_code_blocks]
99
+ if @redcarpet_extensions[:smart]
100
+ @renderer.send :include, Redcarpet::Render::SmartyPants
101
+ end
102
+ markdown = Redcarpet::Markdown.new(
103
+ @renderer.new(@redcarpet_extensions),
104
+ @redcarpet_extensions
105
+ )
106
+ markdown.render(content)
107
+ end
108
+ end