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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd0ca6d723ef2cfbc3cc3ec87d184561abea8d451172a0bb4a3a9a136e243eb7
4
- data.tar.gz: 8e322c9cda56f6f730a0cae0823cf27ad2bf3092f33ef5bba04760b725e64cdc
3
+ metadata.gz: eebbee8080599cb68aad9d143671a0f34ca95423451cb142f30fa588ec5049a1
4
+ data.tar.gz: 5f6d65ebfdb900317718453cdc920ebc590fc9b69f32bfdb65226d2b7600ddf1
5
5
  SHA512:
6
- metadata.gz: f31f20474eabfe807f33e33a36cedf1487f44c0cec1a4298c7852fe68237fb7638130fdb1603e790b60a60eb1db9c0e5a2af30509b25cb387346c22247cd5a03
7
- data.tar.gz: 7cf6232f7840fd12e17c294e332213b226cdbe6bcee554ccc6e6ec9e30c12333b185bdc2746cf28d3d91f97a284f63fe8583aeee0cfed9afdcb8fe26130be906
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.6.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-05-07 00:00:00.000000000 Z
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.4'
220
+ version: '2.5'
193
221
  required_rubygems_version: !ruby/object:Gem::Requirement
194
222
  requirements:
195
223
  - - ">="