commonmarker-pluggable 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: aa4b2bb80b5f12bd72456d32c883de8fb976bead241c346861a84dc4ee7ec29b
4
+ data.tar.gz: c71b2ad1322a6a834937d4b9e268e6ad44d4fa83bff803907201cd3b4fd8e933
5
+ SHA512:
6
+ metadata.gz: 1ad84469f15a6319e5b7333b4d11471109105c59e261389d99b7ae673dfeb365a088d25ba60494d49c2987e3c7f58bf9c5d339dfe4ee0c39595ae90bf7965526
7
+ data.tar.gz: 0d5d04b17eb6d7e65262d58338a2a0747a84d5350600622f721a041f210b07f1c6fb3a518cd76d99d73239e14ea84835441d5fcf979f9b107858ad9f7d422b95
@@ -0,0 +1,18 @@
1
+ /.bundle
2
+ /.ruby-version
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_commands/
6
+ /_site/
7
+ /_yardoc/
8
+ /backup/
9
+ /blog/
10
+ /coverage/
11
+ /doc/
12
+ /pkg/
13
+ /spec/reports/
14
+ /vendor/
15
+ /tmp/
16
+ *.swp
17
+ .jekyll-metadata
18
+ .sass-cache/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in taipo.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
4
+ software, either in source code form or as a compiled binary, for any purpose,
5
+ commercial or non-commercial, and by any means.
6
+
7
+ In jurisdictions that recognize copyright laws, the author or authors of this
8
+ software dedicate any and all copyright interest in the software to the public
9
+ domain. We make this dedication for the benefit of the public at large and to
10
+ the detriment of our heirs and successors. We intend this dedication to be an
11
+ overt act of relinquishment in perpetuity of all present and future rights to
12
+ this software under copyright law.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
18
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
19
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+
21
+ For more information, please refer to <http://unlicense.org/>
@@ -0,0 +1,98 @@
1
+ [![Gem Version][badge-img]][badge-link]
2
+
3
+ [badge-img]: https://badge.fury.io/rb/commonmarker-pluggable.svg
4
+ [badge-link]: https://badge.fury.io/rb/commonmarker-pluggable
5
+
6
+ # commonmarker-pluggable
7
+
8
+ commonmarker-pluggable adds support for plugins to CommonMarker.
9
+
10
+ The `cmark` reference parser used by CommonMarker supports extensions to the
11
+ CommonMark specification but these are written in C. The commonmarker-pluggable
12
+ plugin allows users to extend CommonMarker's parsing capabilities with plugins
13
+ written in Ruby.
14
+
15
+ ## Installation
16
+
17
+ The commonmarker-pluggable plugin requires the commonmarker plugin to
18
+ be installed and configured ([instructions here][cmp]). The only additional
19
+ step is to add commonmarker-pluggable to your `Gemfile` like so:
20
+
21
+ [cmp]: https://github.com/gjtorikian/commonmarker
22
+
23
+ ```ruby
24
+ gem 'commonmarker'
25
+ gem 'commonmarker-pluggable'
26
+ ```
27
+
28
+ ## Writing Plugins
29
+
30
+ Once commonmarker-pluggable is installed, you can add plugins that manipulate
31
+ the Markdown document parsed by `cmark`.
32
+
33
+ Plugins are automatically detected by commonmark-pluggable if they are within
34
+ the `Commonmarker::Plugin` namespace as demonstrated below. Please note that the
35
+ plugin itself must be of type `Module`.
36
+
37
+ A plugin must implement the `self.call()` module method. This method takes one
38
+ argument: `doc`. This is a `CommonMarker::Node` object representing the
39
+ top-most node of a parsed Markdown document.
40
+
41
+ An example plugin is set out below:
42
+
43
+ ```ruby
44
+ module CommonMarker
45
+ module Plugin
46
+ module Example
47
+ def self.call(doc)
48
+ doc.walk do |node|
49
+ node.delete if node.string_content == 'To be deleted'
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ ```
56
+
57
+ ## Using with Jekyll
58
+
59
+ commonmarker-pluggable was originally written for use with Jekyll. If you want
60
+ to write a plugin that is both a CommonMarker plugin _and_ a Jekyll plugin, you
61
+ need to ensure that commonmarker-pluggable is installed as a Jekyll plugin.
62
+ There are [other ways][jk-pl] to do this, but the easiest method is to include
63
+ commonmarker-pluggable in the `:jekyll_plugins` group in your Gemfile:
64
+
65
+ [jk-pl]: https://jekyllrb.com/docs/plugins/installation/
66
+
67
+ ```ruby
68
+ group :jekyll_plugins do
69
+ gem 'commonmarker-pluggable'
70
+ gem 'jekyll-commonmark'
71
+ ...
72
+ end
73
+ ```
74
+
75
+ ## Bugs
76
+
77
+ Found a bug? I'd love to know about it. The best way is to report them in the
78
+ [Issues section][gh-i] on GitHub.
79
+
80
+ [gh-i]: https://github.com/pyrmont/commonmarker-pluggable/issues
81
+
82
+ ## Contributing
83
+
84
+ If you're interested in contributing to commonmarker-pluggable, feel free to
85
+ fork and submit a pull request.
86
+
87
+ ## Versioning
88
+
89
+ The commonmarker-pluggable plugin uses [Semantic Versioning 2.0.0][sv2].
90
+
91
+ [sv2]: http://semver.org/
92
+
93
+ ## Licence
94
+
95
+ The commonmarker-pluggable plugin is released into the public domain. See
96
+ [LICENSE.md][lc] for more details.
97
+
98
+ [lc]: https://github.com/pyrmont/commonmarker-pluggable/blob/master/LICENSE.md
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'commonmarker-pluggable/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "commonmarker-pluggable"
8
+ spec.version = CommonMarkerPluggable::VERSION
9
+ spec.authors = ["Michael Camilleri"]
10
+ spec.email = ["mike@inqk.net"]
11
+
12
+ spec.summary = %q{A plugin that extends commonmarker to support plugins}
13
+ spec.description = %q{The commonmarker-pluggable plugin provides a simple way to extend the CommonMark parser using plugins.}
14
+ spec.homepage = "https://github.com/pyrmont/commonmarker-pluggable/"
15
+ spec.license = "Unlicense"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+ spec.required_ruby_version = '>= 2.4.0'
20
+
21
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
22
+
23
+ spec.add_dependency "commonmarker", "~> 0.20"
24
+ end
@@ -0,0 +1,38 @@
1
+ # frozen-string-literal: true
2
+
3
+ require 'commonmarker'
4
+
5
+ # An extension to CommonMarker that adds plugin support
6
+ #
7
+ # CommonMarkerPluggable is a shim that adds itself to CommonMarker and
8
+ # intercepts calls to `CommonMarker.render_doc`. After a document object is
9
+ # created, CommonMarkerPluggable calls the `.call` method of each plugin,
10
+ # passing the updated document object each time.
11
+ #
12
+ # @since 0.2.0
13
+ # @see https://github.com/pyrmont/jekyll-commonmarker-pluggable
14
+ module CommonMarkerPluggable
15
+
16
+ # Collect the plugins
17
+ #
18
+ # @since 0.2.0
19
+ def self.plugins
20
+ @plugins ||= CommonMarker::Plugin.constants.reduce(Array.new) do |total,c|
21
+ next total unless (m = CommonMarker::Plugin.const_get(c)).is_a? Module
22
+ total.push m
23
+ end
24
+ end
25
+
26
+ # Render the CommonMark document
27
+ #
28
+ # @since 0.2.0
29
+ def render_doc(text, options = :DEFAULT, extensions = [])
30
+ doc = super(text, options, extensions)
31
+ CommonMarkerPluggable.plugins.each do |plugin|
32
+ plugin.call doc
33
+ end
34
+ doc
35
+ end
36
+ end
37
+
38
+ CommonMarker.singleton_class.prepend CommonMarkerPluggable
@@ -0,0 +1,3 @@
1
+ module CommonMarkerPluggable
2
+ VERSION = "0.3.0"
3
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: commonmarker-pluggable
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Camilleri
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commonmarker
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.20'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.20'
27
+ description: The commonmarker-pluggable plugin provides a simple way to extend the
28
+ CommonMark parser using plugins.
29
+ email:
30
+ - mike@inqk.net
31
+ executables: []
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - Gemfile
37
+ - LICENSE.md
38
+ - README.md
39
+ - Rakefile
40
+ - commonmarker-pluggable.gemspec
41
+ - lib/commonmarker-pluggable.rb
42
+ - lib/commonmarker-pluggable/version.rb
43
+ homepage: https://github.com/pyrmont/commonmarker-pluggable/
44
+ licenses:
45
+ - Unlicense
46
+ metadata:
47
+ allowed_push_host: https://rubygems.org
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.4.0
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 3.0.3
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: A plugin that extends commonmarker to support plugins
67
+ test_files: []