gitlab_kramdown 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/gitlab_kramdown/converter/gitlab_html.rb +19 -0
- data/lib/gitlab_kramdown/parser/header.rb +2 -1
- metadata +31 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eebbee8080599cb68aad9d143671a0f34ca95423451cb142f30fa588ec5049a1
|
4
|
+
data.tar.gz: 5f6d65ebfdb900317718453cdc920ebc590fc9b69f32bfdb65226d2b7600ddf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dae794a6ddc7c4e10dca80b89bb23e4df7bdf2b6d9558c12fcd614a02bd6d708f5b1f89c9a72772e10bc66205cd28a74b9c4ce0fc4599321f73943b2c4f3efa
|
7
|
+
data.tar.gz: 62035dbc3f5b36bad3ebd8f92a9699fa6603a8cbf03b4437c0356e823dd6430ae54964ae3c822524fae3e9c30182fca872767c08c2aaac39f022f38fcec806f6
|
data/README.md
CHANGED
@@ -26,6 +26,7 @@ This is a list of GitLab Flavored Markdown (GFM) extensions and their status of
|
|
26
26
|
| [Math] | No |
|
27
27
|
| [Colors] | No |
|
28
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.
|
@@ -69,6 +70,11 @@ To have also syntax highlighting using the same engine GitLab use, you need to d
|
|
69
70
|
Kramdown::Document.new(source, input: 'GitlabKramdown', syntax_highlighter: :rouge).to_html
|
70
71
|
```
|
71
72
|
|
73
|
+
## Supported and tested Ruby versions:
|
74
|
+
|
75
|
+
- Ruby 2.5
|
76
|
+
- Ruby 2.6
|
77
|
+
|
72
78
|
## Contributing to gitlab_kramdown
|
73
79
|
|
74
80
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
@@ -102,3 +108,4 @@ further details.
|
|
102
108
|
[Math]: https://docs.gitlab.com/ee/user/markdown.html#math
|
103
109
|
[Colors]: https://docs.gitlab.com/ee/user/markdown.html#colors
|
104
110
|
[Mermaid]: https://docs.gitlab.com/ee/user/markdown.html#mermaid
|
111
|
+
[PlantUML]: https://docs.gitlab.com/ee/administration/integration/plantuml.html#creating-diagrams
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'kramdown/converter/html'
|
4
|
+
require 'nokogiri'
|
5
|
+
require 'asciidoctor-plantuml'
|
4
6
|
|
5
7
|
module GitlabKramdown
|
6
8
|
module Converter
|
@@ -15,10 +17,27 @@ module GitlabKramdown
|
|
15
17
|
def convert_codeblock(element, opts)
|
16
18
|
if element.options[:lang] == 'mermaid'
|
17
19
|
%(<div class="mermaid">#{element.value}</div>\n)
|
20
|
+
elsif element.options[:lang] == 'plantuml'
|
21
|
+
plantuml_setup
|
22
|
+
|
23
|
+
img_tag = Nokogiri::HTML::DocumentFragment.parse(
|
24
|
+
Asciidoctor::PlantUml::Processor.plantuml_content(element.value, {})
|
25
|
+
)
|
26
|
+
|
27
|
+
%(#{img_tag}\n)
|
18
28
|
else
|
19
29
|
super
|
20
30
|
end
|
21
31
|
end
|
32
|
+
|
33
|
+
def plantuml_setup
|
34
|
+
Asciidoctor::PlantUml.configure do |conf|
|
35
|
+
conf.url = 'https://plantuml.gitlab-static.net'
|
36
|
+
conf.png_enable = true
|
37
|
+
conf.svg_enable = false
|
38
|
+
conf.txt_enable = false
|
39
|
+
end
|
40
|
+
end
|
22
41
|
end
|
23
42
|
end
|
24
43
|
end
|
@@ -73,10 +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
|
79
|
-
result.gsub!(NON_WORD_RE, '')
|
80
|
+
result.gsub!(MARKDOWN_LINK_TEXT) { |s| MARKDOWN_LINK_TEXT.match(s)[:link_text].gsub(NON_WORD_RE, '') }
|
80
81
|
result.tr!(" \t", '-')
|
81
82
|
@id_counter[result] += 1
|
82
83
|
result << (@id_counter[result].positive? ? "-#{@id_counter[result]}" : '')
|
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.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gabriel Mazetto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: nokogiri
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.10.4
|
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.4
|
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.9
|
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.9
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rdoc
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,7 +217,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
189
217
|
requirements:
|
190
218
|
- - "~>"
|
191
219
|
- !ruby/object:Gem::Version
|
192
|
-
version: '2.
|
220
|
+
version: '2.5'
|
193
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
222
|
requirements:
|
195
223
|
- - ">="
|