jekyll-is-hookdown 0.8.0.4

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: da37ba1fb35409ea8c632c8b1febf8817e2661ceab9274ba2bef23c020147826
4
+ data.tar.gz: 868079cadc51e00b6d19bedcbc0df7bf1640201259e0117300b5c09e199dd921
5
+ SHA512:
6
+ metadata.gz: b2c250e14593802d2c3af5cd6d930e565887f59cbd5d19bf2e99e7f50e6ffaa402089053cf1dda892ec04723509192146da477294cd96e16c5ca71aba40e5cd8
7
+ data.tar.gz: 6fa6ba530ea69d14144718491864d6a995ca0c3835c543c8e2b45b32a2b125943fb3f2ce84dbcef17ab257b52cea33bdf36b43c6d5a6bb9a551e16a33e49d89a
data/LICENSE ADDED
@@ -0,0 +1,166 @@
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
166
+
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # jekyll-is-hookdown
2
+
3
+ Hooked Kramdown for Jekyll
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+
5
+ require_relative 'jekyll_patch'
6
+
7
+ class Jekyll::Converters::Markdown::Hookdown < Jekyll::Converters::Markdown::KramdownParser
8
+
9
+ def convert content
10
+ document = Kramdown::JekyllDocument.new content, @config
11
+ page = JekyllIS::Hookdown::current_page
12
+ case page
13
+ when Jekyll::Page
14
+ Jekyll::Hooks::trigger :pages, :post_parse, page, document
15
+ when Jekyll::Document
16
+ Jekyll::Hooks::trigger :documents, :post_parse, page, document
17
+ if page.respond_to?(:collection) && page.collection&.label == 'posts'
18
+ Jekyll::Hooks::trigger :posts, :post_parse, page, document
19
+ end
20
+ else
21
+ Jekyll::logger.warn JekyllIS::Hookdown::Info::NAME, "Unknown page type: #{ page.inspect }"
22
+ end
23
+ html_output = document.to_html
24
+ if @config['show_warnings']
25
+ document.warnings.each do |warning|
26
+ Jekyll::logger.warn 'Kramdown warning:', warning
27
+ end
28
+ end
29
+ html_output
30
+ end
31
+
32
+ end
@@ -0,0 +1,91 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'set'
4
+ require 'kramdown'
5
+
6
+ require_relative 'jekyll_patch'
7
+
8
+ module JekyllIS::Hookdown
9
+
10
+ class << self
11
+
12
+ def register_element_hook owner, *elements, priority: Jekyll::Hooks::DEFAULT_PRIORITY, &block
13
+ if enabled?
14
+ priority = Jekyll::Hooks::priority_value(priority)
15
+ owners = owner.is_a?(Enumerable) ? owner.to_set : Set[ owner ]
16
+ setup_element_hooks
17
+ obj = { priority: priority, block: block, owners: owners, elements: elements.to_set }
18
+ idx = @hooks.find_index { priority <= it[:priority] }
19
+ if idx
20
+ @hooks.insert idx, obj
21
+ else
22
+ @hooks.push obj
23
+ end
24
+ block
25
+ else
26
+ false
27
+ end
28
+ end
29
+
30
+ def unregister_element_hook block
31
+ if @hooks
32
+ @hooks.reject! { it[:block] == block }
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def process_element page, kind, collection, element, parent: nil, index: nil
39
+ @hooks.reverse_each do |obj|
40
+ next unless obj[:elements].include?(element.type)
41
+ next unless obj[:owners].include?(kind) || obj[:owners].include?(collection)
42
+ block = obj[:block]
43
+ result = block.call page, element
44
+ case result
45
+ when Kramdown::Element
46
+ element = result
47
+ parent.children[index] = element if parent && parent.children && index
48
+ when nil
49
+ # do nothing
50
+ when :delete
51
+ element = nil
52
+ parent.children[index] = element if parent && parent.children && index
53
+ break
54
+ else
55
+ Jekyll::logger.error JekyllIS::Hookdown::Info::NAME, "Invalid hook response: #{ result.inspect }"
56
+ end
57
+ end
58
+ if element && element.children
59
+ element.children.each_with_index do |child, idx|
60
+ process_element page, kind, collection, child, parent: element, index: idx
61
+ end
62
+ element.children.compact!
63
+ end
64
+ element
65
+ end
66
+
67
+ def setup_element_hooks
68
+ unless @hooks
69
+ @hooks = []
70
+ Jekyll::Hooks.register [ :pages, :documents ], :post_parse do |page, document|
71
+ kind = case page
72
+ when Jekyll::Page
73
+ :pages
74
+ when Jekyll::Document
75
+ :documents
76
+ else
77
+ nil
78
+ end
79
+ collection = if page.respond_to?(:collection)
80
+ page.collection&.label&.to_sym
81
+ else
82
+ nil
83
+ end
84
+ process_element page, kind, collection, document.root
85
+ end
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllIS; end
4
+
5
+ module JekyllIS::Hookdown; end
6
+
7
+ module JekyllIS::Hookdown::Info
8
+
9
+ NAME = 'jekyll-is-hookdown'
10
+ VERSION = '0.8.0.4'
11
+ SUMMARY = 'Hooked Kramdown for Jekyll'
12
+ LICENSE = 'LGPL-3.0-or-later'
13
+ AUTHOR = 'Ivan Shikhalev'
14
+ EMAIL = 'shikhalev@gmail.com'
15
+ HOMEPAGE = 'https://github.com/jekyll-is/jekyll-is-hookdown'
16
+ PATH = File.expand_path '../../../..', __FILE__
17
+
18
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+
5
+ require_relative 'info'
6
+
7
+ module JekyllIS::Hookdown
8
+
9
+ class << self
10
+
11
+ def apply_patch
12
+ registry = Jekyll::Hooks.instance_variable_get :@registry
13
+ [ :pages, :posts, :documents ].each do |owner|
14
+ registry[owner][:post_parse] ||= [] if registry[owner]
15
+ end
16
+ end
17
+
18
+ def current_page
19
+ Thread::current[:hookdown_current_page]
20
+ end
21
+
22
+ def current_page= value
23
+ Thread::current[:hookdown_current_page] = value
24
+ end
25
+
26
+ def enabled?
27
+ Jekyll::configuration['markdown'] == 'Hookdown'
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+
34
+ if JekyllIS::Hookdown::enabled?
35
+
36
+ JekyllIS::Hookdown::apply_patch
37
+
38
+ Jekyll::Hooks::register [ :pages, :documents ], :pre_render do |page|
39
+ JekyllIS::Hookdown::current_page = page
40
+ end
41
+
42
+ Jekyll::Hooks::register [ :pages, :documents ], :post_render do |page|
43
+ if JekyllIS::Hookdown::current_page == page
44
+ JekyllIS::Hookdown::current_page = nil
45
+ else
46
+ Jekyll::logger.warn JekyllIS::Hookdown::Info::NAME, "Mismatch pages: #{ page.inspect } vs #{ JekyllIS::Hookdown::current_page.inspect }"
47
+ end
48
+ end
49
+
50
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'hookdown/jekyll_patch'
4
+ require_relative 'hookdown/converter'
5
+ require_relative 'hookdown/extra'
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'jekyll-is/hookdown'
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll-is-hookdown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Ivan Shikhalev
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: jekyll
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '4.4'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - "~>"
24
+ - !ruby/object:Gem::Version
25
+ version: '4.4'
26
+ - !ruby/object:Gem::Dependency
27
+ name: kramdown
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '2.5'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '2.5'
40
+ - !ruby/object:Gem::Dependency
41
+ name: rspec
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '3.13'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '3.13'
54
+ - !ruby/object:Gem::Dependency
55
+ name: rake
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '13.3'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '13.3'
68
+ - !ruby/object:Gem::Dependency
69
+ name: simplecov
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.1'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.1'
82
+ description: Hooked Kramdown for Jekyll.
83
+ email:
84
+ - shikhalev@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files: []
88
+ files:
89
+ - LICENSE
90
+ - README.md
91
+ - lib/jekyll-is-hookdown.rb
92
+ - lib/jekyll-is/hookdown.rb
93
+ - lib/jekyll-is/hookdown/converter.rb
94
+ - lib/jekyll-is/hookdown/extra.rb
95
+ - lib/jekyll-is/hookdown/info.rb
96
+ - lib/jekyll-is/hookdown/jekyll_patch.rb
97
+ homepage: https://github.com/jekyll-is/jekyll-is-hookdown
98
+ licenses:
99
+ - LGPL-3.0-or-later
100
+ metadata: {}
101
+ rdoc_options: []
102
+ require_paths:
103
+ - lib
104
+ required_ruby_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '3.4'
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ requirements: []
115
+ rubygems_version: 3.6.9
116
+ specification_version: 4
117
+ summary: Hooked Kramdown for Jekyll
118
+ test_files: []