gitlab_kramdown 0.5.0 → 0.6.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: cd0ca6d723ef2cfbc3cc3ec87d184561abea8d451172a0bb4a3a9a136e243eb7
4
+ data.tar.gz: 8e322c9cda56f6f730a0cae0823cf27ad2bf3092f33ef5bba04760b725e64cdc
5
5
  SHA512:
6
- metadata.gz: c8d9d12504b784b056dd2ef6e49bfb9664b454b1fefd6242c388a3e6ffc52bc18d0706bd08eb907b3a5759e8cf4ac84647e4a4ac3c55334d862b65042181f6b7
7
- data.tar.gz: 131c9a44c743e52ddcb74684c2236155ad89c54b073b80b1887e4213a043c821a56fcc042b1e27eb69596ae54032e17be5a71474a8adf2ecc25a057c140fe452
6
+ metadata.gz: f31f20474eabfe807f33e33a36cedf1487f44c0cec1a4298c7852fe68237fb7638130fdb1603e790b60a60eb1db9c0e5a2af30509b25cb387346c22247cd5a03
7
+ data.tar.gz: 7cf6232f7840fd12e17c294e332213b226cdbe6bcee554ccc6e6ec9e30c12333b185bdc2746cf28d3d91f97a284f63fe8583aeee0cfed9afdcb8fe26130be906
data/README.md CHANGED
@@ -25,7 +25,7 @@ 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
29
 
30
30
  > **Note**: Extensions marked as `Kramdown` in the `Implemented?` means behavior already exists
31
31
  in Kramdown flavor.
@@ -36,6 +36,7 @@ This is a list of GitLab Flavored Markdown (GFM) extensions and their status of
36
36
  | :------------------| :------------------: | -------------------------------------------- |
37
37
  | `gitlab_url` | `https://gitlab.com` | GitLab instance URL to build reference links |
38
38
  | `linkable_headers` | true | Generate anchor tags with headers? |
39
+ | `autolink` | false | Converts URLs to HTML links (can be slow) |
39
40
 
40
41
  ## Usage example
41
42
 
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'kramdown/converter/html'
4
+
5
+ module GitlabKramdown
6
+ module Converter
7
+ # Converts a Kramdown::Document to HTML.
8
+ #
9
+ # This includes GitLab custom elements from GitLab Flavored Markdown syntax
10
+ module GitlabHtml
11
+ # Codeblock is customized in order to implement a different output to Mermaid
12
+ #
13
+ # Mermaid requires `<div class="mermaid"></div>` surrounding the content in order
14
+ # to trigger the unobtrusive JS.
15
+ def convert_codeblock(element, opts)
16
+ if element.options[:lang] == 'mermaid'
17
+ %(<div class="mermaid">#{element.value}</div>\n)
18
+ else
19
+ super
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GitlabKramdown
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
@@ -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)
@@ -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.6.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-04-09 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kramdown
@@ -162,6 +162,7 @@ files:
162
162
  - LICENSE.txt
163
163
  - README.md
164
164
  - lib/gitlab_kramdown.rb
165
+ - lib/gitlab_kramdown/converter/gitlab_html.rb
165
166
  - lib/gitlab_kramdown/parser.rb
166
167
  - lib/gitlab_kramdown/parser/autolink.rb
167
168
  - lib/gitlab_kramdown/parser/escape.rb
@@ -195,7 +196,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
196
  - !ruby/object:Gem::Version
196
197
  version: '0'
197
198
  requirements: []
198
- rubygems_version: 3.0.3
199
+ rubyforge_project:
200
+ rubygems_version: 2.7.6.2
199
201
  signing_key:
200
202
  specification_version: 4
201
203
  summary: GitLab Flavored Kramdown