gitlab_kramdown 0.5.0 → 0.10.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 863ff5cdca8cd14c9de1619a1fcb4512ad12ae602a688097a4f3a03d85483d77
4
- data.tar.gz: 4adb0e3732d0bf380c1e8b7afc0bc6ae4db90a39d51a6a81489d02025a5c9629
3
+ metadata.gz: 46edf71a2cbaa91e378788b9ff7b369c2fe864211cf1d6b8ba673b77a9a13bca
4
+ data.tar.gz: 9d9411975cb4f61ece5f8033db432a4f1cd6236c99c606aa4fc953654c941572
5
5
  SHA512:
6
- metadata.gz: c8d9d12504b784b056dd2ef6e49bfb9664b454b1fefd6242c388a3e6ffc52bc18d0706bd08eb907b3a5759e8cf4ac84647e4a4ac3c55334d862b65042181f6b7
7
- data.tar.gz: 131c9a44c743e52ddcb74684c2236155ad89c54b073b80b1887e4213a043c821a56fcc042b1e27eb69596ae54032e17be5a71474a8adf2ecc25a057c140fe452
6
+ metadata.gz: ee0f367f0d723917d0c5a96650c5a2a9e7e78cbf4c7da762e4f42a3ba563b77562e4cb020f3e67ff67671d345de8b93e046b338d9eb857e955ae230184c685d1
7
+ data.tar.gz: a302ab1dbc1cb14c1ca4e08087268ca144af2e1c00282ff13bd8ec80f83c96c25e1a3c4e829027fdc97758d67d5ace9c38b38043c80f54e0115d735cda5a6e73
@@ -0,0 +1,100 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.10.0] - 2020-08-27
10
+
11
+ - Update Gem dependencies
12
+
13
+ ## [0.9.0] - 2019-10-17
14
+
15
+ ### Fixed
16
+ - Fix very long IDs for headers that include links.
17
+
18
+ ### Added
19
+ - Images should be clickable and linked to itself
20
+ - Clickable images behavior is configurable
21
+
22
+ ### [0.8.0] - 2019-10-14
23
+
24
+ ### Changed
25
+ - Revert "Fix very long IDs for headers that include links"
26
+
27
+ ### [0.7.0] - 2019-10-11
28
+
29
+ ### Added
30
+ - Add support for PlantUML
31
+
32
+ ### Changed
33
+ - Ruby 2.4 support is dropped.
34
+ - Fix very long IDs for headers that include links.
35
+
36
+ ## [0.6.0] - 2019-05-07
37
+ ### Changed
38
+ - URL Autolinks are now disabled by default (you can re-enable with `autolink: true` configuration param)
39
+
40
+ ### Added
41
+ - Added support for rendering Mermaid when their JS is available
42
+
43
+ ## [0.5.0] - 2019-04-09
44
+ ### Added
45
+ - Strikethrough support
46
+
47
+ ## [0.4.2] - 2018-11-21
48
+ ### Changed
49
+ - URL autolinks will not execute inside `[]()` or `[]` blocks
50
+ - Freezing `kramdown` version to allow only patchlevel changes
51
+
52
+ ## [0.4.1] - 2018-11-02
53
+ ### Added
54
+ - Codebase now have a benchmark utility to compare with plain Kramdown
55
+
56
+ ### Changed
57
+ - Many performance improvements on existing RegExp rules
58
+ - Improve gemspec metadata and include only needed files on gem
59
+
60
+ ## [0.4.0] - 2018-04-12
61
+ ### Added
62
+ - URL auto-linking support
63
+
64
+ ### Changed
65
+ - Fixed many inconsistencies in references autolink
66
+
67
+ ## [0.3.0] - 2018-03-23
68
+ ### Added
69
+ - Headers will include by default an anchor tag (you can disable with `linkable_headers: false`)
70
+
71
+ ### Changed
72
+ - Fixed multiline blockquote delimiter
73
+ - GitLab URL is not customizable with `gitlab_url: 'http://yourcustomgitlab.com'`
74
+
75
+ ## [0.2.0] - 2018-03-19
76
+ ### Added
77
+ - Syntax highlighter uses ``` or ~~~
78
+
79
+ ### Changed
80
+ - Requires Ruby 2.4
81
+ - Requires rouge `~> 3.0`
82
+
83
+ ## [0.1.0] - 2018-03-17
84
+ ### Added
85
+ - The initial version of the Gem
86
+ - Special GitLab References
87
+ - Multiline Blockquote
88
+
89
+ [0.10.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.9.0...v0.10.0
90
+ [0.9.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.8.0...v0.9.0
91
+ [0.8.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.7.0...v0.8.0
92
+ [0.7.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.6.0...v0.7.0
93
+ [0.6.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.5.0...v0.6.0
94
+ [0.5.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.4.2...v0.5.0
95
+ [0.4.2]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.4.1...v0.4.2
96
+ [0.4.1]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.4.0...v0.4.1
97
+ [0.4.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.3.0...v0.4.0
98
+ [0.3.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.2.0...v0.3.0
99
+ [0.2.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/v0.1.0...v0.2.0
100
+ [0.1.0]: https://gitlab.com/gitlab-org/gitlab_kramdown/compare/15b5e4b46aa0e42974ec2e5ee36c68d97219736f...v0.1.0
@@ -1,20 +1,21 @@
1
+ The MIT License (MIT)
2
+
1
3
  Copyright (c) 2018-2019 Gabriel Mazetto
2
4
 
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
10
11
 
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
13
14
 
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -25,7 +25,8 @@ This is a list of GitLab Flavored Markdown (GFM) extensions and their status of
25
25
  | [Videos] | No |
26
26
  | [Math] | No |
27
27
  | [Colors] | No |
28
- | [Mermaid] | No |
28
+ | [Mermaid] | **Yes** |
29
+ | [PlantUML] | **Yes** |
29
30
 
30
31
  > **Note**: Extensions marked as `Kramdown` in the `Implemented?` means behavior already exists
31
32
  in Kramdown flavor.
@@ -36,6 +37,8 @@ This is a list of GitLab Flavored Markdown (GFM) extensions and their status of
36
37
  | :------------------| :------------------: | -------------------------------------------- |
37
38
  | `gitlab_url` | `https://gitlab.com` | GitLab instance URL to build reference links |
38
39
  | `linkable_headers` | true | Generate anchor tags with headers? |
40
+ | `autolink` | false | Converts URLs to HTML links (can be slow) |
41
+ | `clickable_images` | true | Autolink images to themselves |
39
42
 
40
43
  ## Usage example
41
44
 
@@ -68,6 +71,11 @@ To have also syntax highlighting using the same engine GitLab use, you need to d
68
71
  Kramdown::Document.new(source, input: 'GitlabKramdown', syntax_highlighter: :rouge).to_html
69
72
  ```
70
73
 
74
+ ## Supported and tested Ruby versions:
75
+
76
+ - Ruby 2.5
77
+ - Ruby 2.6
78
+
71
79
  ## Contributing to gitlab_kramdown
72
80
 
73
81
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
@@ -101,3 +109,4 @@ further details.
101
109
  [Math]: https://docs.gitlab.com/ee/user/markdown.html#math
102
110
  [Colors]: https://docs.gitlab.com/ee/user/markdown.html#colors
103
111
  [Mermaid]: https://docs.gitlab.com/ee/user/markdown.html#mermaid
112
+ [PlantUML]: https://docs.gitlab.com/ee/administration/integration/plantuml.html#creating-diagrams
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'kramdown/parser'
4
+ require 'kramdown/converter'
4
5
 
5
6
  # GitLab Kramdown implements Markdown flavored extensions on top of Kramdown
6
7
  #
@@ -17,7 +18,15 @@ require 'kramdown/parser'
17
18
  module GitlabKramdown
18
19
  autoload :VERSION, 'gitlab_kramdown/version'
19
20
  autoload :Parser, 'gitlab_kramdown/parser'
21
+
22
+ # Gitlab Kramdown custom Converters
23
+ module Converter
24
+ autoload :GitlabHtml, 'gitlab_kramdown/converter/gitlab_html'
25
+ end
20
26
  end
21
27
 
22
28
  # Autoload extensions
23
29
  Kramdown::Parser.autoload :GitlabKramdown, 'kramdown/parser/gitlab_kramdown'
30
+
31
+ # Custom HTML extensions
32
+ Kramdown::Converter::Html.prepend(GitlabKramdown::Converter::GitlabHtml)
@@ -0,0 +1,72 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kramdown/converter/html'
4
+ require 'nokogiri'
5
+ require 'asciidoctor-plantuml'
6
+
7
+ module GitlabKramdown
8
+ module Converter
9
+ # Converts a Kramdown::Document to HTML.
10
+ #
11
+ # This includes GitLab custom elements from GitLab Flavored Markdown syntax
12
+ module GitlabHtml
13
+ # Initializes a GitLab custom HTML converter with a given document
14
+ #
15
+ # It accepts all existing options for HTML converter with our custom ones:
16
+ #
17
+ # * +clickable_images+ (default: true) - whether images will have a link to itself
18
+ #
19
+ # @param [Kramdown::Document] root
20
+ # @param [Hash] options
21
+ def initialize(root, options)
22
+ super(root, options)
23
+
24
+ @clickable_images = options[:clickable_images] != false
25
+ end
26
+
27
+ # Codeblock is customized in order to implement a different output to Mermaid
28
+ #
29
+ # Mermaid requires `<div class="mermaid"></div>` surrounding the content in order
30
+ # to trigger the unobtrusive JS.
31
+ def convert_codeblock(element, opts)
32
+ if element.options[:lang] == 'mermaid'
33
+ %(<div class="mermaid">#{element.value}</div>\n)
34
+ elsif element.options[:lang] == 'plantuml'
35
+ plantuml_setup
36
+
37
+ img_tag = Nokogiri::HTML::DocumentFragment.parse(
38
+ Asciidoctor::PlantUml::Processor.plantuml_content(element.value, {})
39
+ )
40
+
41
+ %(#{img_tag}\n)
42
+ else
43
+ super
44
+ end
45
+ end
46
+
47
+ def plantuml_setup
48
+ Asciidoctor::PlantUml.configure do |conf|
49
+ conf.url = 'https://plantuml.gitlab-static.net'
50
+ conf.png_enable = true
51
+ conf.svg_enable = false
52
+ conf.txt_enable = false
53
+ end
54
+ end
55
+
56
+ # Images can have a link to themselves when configuration allows
57
+ #
58
+ # We don't autolink when image is already linked to something-else
59
+ #
60
+ # @param [Kramdown::Element] element
61
+ # @param [Integer] _indent
62
+ def convert_img(element, _indent)
63
+ return super unless @clickable_images
64
+ return super if @stack.last.type == :a
65
+
66
+ href = element.attr['src']
67
+
68
+ %(<a href="#{href}" target="_blank" rel="noopener noreferrer">#{super}</a>)
69
+ end
70
+ end
71
+ end
72
+ end
@@ -73,9 +73,11 @@ module GitlabKramdown
73
73
  end
74
74
 
75
75
  NON_WORD_RE = /[^\p{Word}\- \t]/.freeze
76
+ MARKDOWN_LINK_TEXT = /\[(?<link_text>[^\]]+)\]\((?<link_url>[^\)]+)\)/.freeze
76
77
 
77
78
  def generate_header_id(text)
78
79
  result = text.downcase
80
+ result.gsub!(MARKDOWN_LINK_TEXT) { |s| MARKDOWN_LINK_TEXT.match(s)[:link_text].gsub(NON_WORD_RE, '') }
79
81
  result.gsub!(NON_WORD_RE, '')
80
82
  result.tr!(" \t", '-')
81
83
  @id_counter[result] += 1
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitlabKramdown
4
- VERSION = '0.5.0'
4
+ VERSION = '0.10.0'
5
5
  end
@@ -21,11 +21,13 @@ module Kramdown
21
21
  super
22
22
 
23
23
  @options[:gitlab_url] ||= 'https://gitlab.com'
24
+ @options[:autolink] = false if @options[:autolink].nil?
24
25
  @options[:linkable_headers] = true if @options[:linkable_headers].nil?
25
26
  @id_counter = Hash.new(-1)
26
27
 
28
+ prepend_span_parsers(:gitlab_autolink) if @options[:autolink]
27
29
  prepend_span_parsers(:escape_chars_gitlab, :commit_diff, :commit, :user_group_mention,
28
- :issue, :merge_request, :snippet, :label, :gitlab_autolink, :strikethrough_gitlab)
30
+ :issue, :merge_request, :snippet, :label, :strikethrough_gitlab)
29
31
  prepend_block_parsers(:fenced_blockquote)
30
32
  replace_block_parser!(:codeblock_fenced, :codeblock_fenced_gitlab)
31
33
  replace_block_parser!(:atx_header, :atx_gitlab_header)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab_kramdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Mazetto
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2019-04-09 00:00:00.000000000 Z
11
+ date: 2020-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -16,70 +16,98 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.16.2
19
+ version: 2.3.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.16.2
26
+ version: 2.3.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rouge
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
33
+ version: '3.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '3.0'
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rdoc
42
+ name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.12'
47
+ version: 1.10.10
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.10.10
55
+ - !ruby/object:Gem::Dependency
56
+ name: asciidoctor-plantuml
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.12
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.12
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '13.0'
48
76
  type: :development
49
77
  prerelease: false
50
78
  version_requirements: !ruby/object:Gem::Requirement
51
79
  requirements:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
- version: '3.12'
82
+ version: '13.0'
55
83
  - !ruby/object:Gem::Dependency
56
- name: bundler
84
+ name: rdoc
57
85
  requirement: !ruby/object:Gem::Requirement
58
86
  requirements:
59
87
  - - "~>"
60
88
  - !ruby/object:Gem::Version
61
- version: '1.0'
89
+ version: '6.2'
62
90
  type: :development
63
91
  prerelease: false
64
92
  version_requirements: !ruby/object:Gem::Requirement
65
93
  requirements:
66
94
  - - "~>"
67
95
  - !ruby/object:Gem::Version
68
- version: '1.0'
96
+ version: '6.2'
69
97
  - !ruby/object:Gem::Dependency
70
- name: juwelier
98
+ name: bundler
71
99
  requirement: !ruby/object:Gem::Requirement
72
100
  requirements:
73
101
  - - "~>"
74
102
  - !ruby/object:Gem::Version
75
- version: 2.1.0
103
+ version: '1.0'
76
104
  type: :development
77
105
  prerelease: false
78
106
  version_requirements: !ruby/object:Gem::Requirement
79
107
  requirements:
80
108
  - - "~>"
81
109
  - !ruby/object:Gem::Version
82
- version: 2.1.0
110
+ version: '1.0'
83
111
  - !ruby/object:Gem::Dependency
84
112
  name: simplecov
85
113
  requirement: !ruby/object:Gem::Requirement
@@ -152,16 +180,17 @@ dependencies:
152
180
  version: '2.7'
153
181
  description: GitLab Flavored Markdown extensions on top of Kramdown markup. Tries
154
182
  to be as close as possible to existing extensions.
155
- email: brodock@gmail.com
183
+ email:
184
+ - brodock@gmail.com
156
185
  executables: []
157
186
  extensions: []
158
- extra_rdoc_files:
159
- - LICENSE.txt
160
- - README.md
187
+ extra_rdoc_files: []
161
188
  files:
189
+ - CHANGELOG.md
162
190
  - LICENSE.txt
163
191
  - README.md
164
192
  - lib/gitlab_kramdown.rb
193
+ - lib/gitlab_kramdown/converter/gitlab_html.rb
165
194
  - lib/gitlab_kramdown/parser.rb
166
195
  - lib/gitlab_kramdown/parser/autolink.rb
167
196
  - lib/gitlab_kramdown/parser/escape.rb
@@ -172,23 +201,23 @@ files:
172
201
  - lib/gitlab_kramdown/parser/strikethrough.rb
173
202
  - lib/gitlab_kramdown/version.rb
174
203
  - lib/kramdown/parser/gitlab_kramdown.rb
175
- homepage: http://gitlab.com/gitlab-org/gitlab_kramdown
204
+ homepage: https://gitlab.com/gitlab-org/gitlab_kramdown
176
205
  licenses:
177
206
  - MIT
178
207
  metadata:
179
- bug_tracker_uri: http://gitlab.com/gitlab-org/gitlab_kramdown/issues
180
- changelog_uri: http://gitlab.com/gitlab-org/gitlab_kramdown/blob/master/CHANGELOG.md
181
- homepage_uri: http://gitlab.com/gitlab-org/gitlab_kramdown
182
- source_code_uri: http://gitlab.com/gitlab-org/gitlab_kramdown
208
+ homepage_uri: https://gitlab.com/gitlab-org/gitlab_kramdown
209
+ source_code_uri: https://gitlab.com/gitlab-org/gitlab_kramdown
210
+ changelog_uri: https://gitlab.com/gitlab-org/gitlab_kramdown/blob/master/CHANGELOG.md
211
+ bug_tracker_uri: https://gitlab.com/gitlab-org/gitlab_kramdown/-/issues
183
212
  post_install_message:
184
213
  rdoc_options: []
185
214
  require_paths:
186
215
  - lib
187
216
  required_ruby_version: !ruby/object:Gem::Requirement
188
217
  requirements:
189
- - - "~>"
218
+ - - ">="
190
219
  - !ruby/object:Gem::Version
191
- version: '2.4'
220
+ version: 2.5.0
192
221
  required_rubygems_version: !ruby/object:Gem::Requirement
193
222
  requirements:
194
223
  - - ">="