mdocs_kramdown 0.1.1.47369 → 0.1.2.70482

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: 72734abb74e939045fdc76a2688cf7fff8a0d5aa253e49769b166a1f60c8643d
4
- data.tar.gz: d0b4e067945af7db84fb70128a4739e5b263986cc8e38cb8175427e00beed5ca
3
+ metadata.gz: cd2a495be39459521396c9034cb9664178a3d82ea2d710bf4e682b975b5271a9
4
+ data.tar.gz: 3d739f1df808ce4106aa01cb887a84dc23055a184a51e4a4a4d8165ed27fea23
5
5
  SHA512:
6
- metadata.gz: a477c291b75bb183e55777de71ab09751025c638c8a04f83c79a9758a723f726f0c81c3d9a4d661f5557db7fe215ec053b2d6ac6164e508cbf16f66581ebae45
7
- data.tar.gz: 47a347a5e47bc24ba8fe1e6a41db2ac76d3c192f78e04f51c9f7a073b504cdef594016a84f8925d17afc90a2feefa4cd7e9609587ebcbd52a67927bdb41a4030
6
+ metadata.gz: 3e61bb221ffe05931740c08c5ab6d64acce133e0e6ba0a4cd1f69a671df5a67cb66a77be0eee49a993bf9d9c608c82ab7bfb3d70d0bfe085108711f13f9e1829
7
+ data.tar.gz: fd06f37954f8651de7320223fe63e52e4d9434816413fd89015d89d4e807bc1ddb6a599c1d5bdb94ba8eb40eadaddd361780a1818b60d725e68008589c5579cc
@@ -4,11 +4,13 @@ module Kramdown
4
4
  module Parser
5
5
  class MdocsKramdown < ::Kramdown::Parser::GitlabKramdown
6
6
  include ::MdocsKramdown::Parser::FencedAdmonitions
7
+ include ::MdocsKramdown::Parser::FencedCollapsibleAdmonitions
7
8
 
8
9
  def initialize(source, options)
9
10
  super
10
11
 
11
12
  prepend_block_parsers(:fenced_admonitions)
13
+ prepend_block_parsers(:fenced_collapsible_admonitions)
12
14
  end
13
15
  end
14
16
  end
@@ -10,13 +10,27 @@ module MdocsKramdown
10
10
 
11
11
  classes = el.attr[:types]
12
12
  title = el.attr[:title]
13
+
14
+ if el.options[:collapsible]
15
+ element_id = Digest::MD5.hexdigest el.inspect
16
+
17
+ format_as_indented_block_html('div', { class: "card #{classes.join(' ')} collapsible" },
18
+ (title ? format_as_indented_block_html('div', { class: 'card-header collapsed', 'data-bs-toggle'=>'collapse','data-bs-target'=>"#collapse-#{element_id}"}, title.strip, indent + 2) : '') +
19
+ format_as_indented_block_html('div', { class: 'collapse', id: "collapse-#{element_id}" },
20
+ format_as_indented_block_html('div', { class: 'card-body' },
21
+ format_as_indented_block_html('div', { class: 'card-text' }, inner(el, indent + 2), indent + 2),
22
+ indent + 1),
23
+ indent + 1),
24
+ indent)
13
25
 
14
- format_as_indented_block_html('div', { class: "card #{classes.join(' ')}" },
15
- (title ? format_as_indented_block_html('div', { class: 'card-header' }, title.strip, indent + 2) : '') +
16
- format_as_indented_block_html('div', { class: 'card-body' },
17
- format_as_indented_block_html('div', { class: 'card-text' }, inner(el, indent + 2), indent + 2),
18
- indent + 1),
19
- indent)
26
+ else
27
+ format_as_indented_block_html('div', { class: "card #{classes.join(' ')}" },
28
+ (title ? format_as_indented_block_html('div', { class: 'card-header' }, title.strip, indent + 2) : '') +
29
+ format_as_indented_block_html('div', { class: 'card-body' },
30
+ format_as_indented_block_html('div', { class: 'card-text' }, inner(el, indent + 2), indent + 2),
31
+ indent + 1),
32
+ indent)
33
+ end
20
34
  end
21
35
 
22
36
  def convert_table(el, indent)
@@ -4,19 +4,17 @@ module MdocsKramdown
4
4
  FENCED_ADMONITIONS_START = /^\s{0,}!{3}/x.freeze
5
5
 
6
6
  FENCED_ADMONITIONS_MATCH = %r{
7
- ^\s{0,}*(?<delimeter>!{3}) # line must start with [0..] spacing and !!!
8
- \s* # any amount of trailling whitespace
9
- (?<type>[^\s]+)? # type of admoniation any except space. Ex: info,class1
10
- \s* # any amount of trailling whitespace
11
- ("(?<title>[^\n]+)")? # title of the admoniation
12
- \s* # any amount of trailling whitespace
13
- \n # heading line completed
14
- (?<content>(\s{4}.*\n)+) # content must starts with 4 spaces
7
+ \s{0,}*(?<delimiter>!{3}) # line must start with [0..] spacing and !!!
8
+ \s?
9
+ (?<type>[^\s]+)? # type of admoniation any except space. Ex: info,class1
10
+ \s?
11
+ ("(?<title>[^\n]+)")? # title of the admoniation
15
12
  \n
16
- }x.freeze
13
+ (?<content>(\s{4}.+)+) # content must starts with 4 spaces
14
+ \n}x.freeze
17
15
 
18
16
  def self.included(klass)
19
- klass.define_parser(:fenced_admonitions, FENCED_BLOCKQUOTE_START)
17
+ klass.define_parser(:fenced_admonitions, FENCED_ADMONITIONS_START)
20
18
  end
21
19
 
22
20
  def parse_fenced_admonitions
@@ -0,0 +1,42 @@
1
+ module MdocsKramdown
2
+ module Parser
3
+ module FencedCollapsibleAdmonitions
4
+ FENCED_COLLAPSIBLE_ADMONITIONS_START = /^\s{0,}\?{3}/x.freeze
5
+
6
+ FENCED_COLLAPSIBLE_ADMONITIONS_MATCH = %r{
7
+ \s{0,}*(?<delimiter>\?{3}) # line must start with [0..] spacing and !!!
8
+ \s?
9
+ (?<type>[^\s]+)? # type of admoniation any except space. Ex: info,class1
10
+ \s?
11
+ ("(?<title>[^\n]+)")? # title of the admoniation
12
+ \n
13
+ (?<content>(\s{4}.+)+) # content must starts with 4 spaces
14
+ \n}x.freeze
15
+
16
+ def self.included(klass)
17
+ klass.define_parser(:fenced_collapsible_admonitions, FENCED_COLLAPSIBLE_ADMONITIONS_START)
18
+ end
19
+
20
+ def parse_fenced_collapsible_admonitions
21
+ if @src.check(FENCED_COLLAPSIBLE_ADMONITIONS_MATCH)
22
+ start_line_number = @src.current_line_number
23
+ @src.pos += @src.matched_size
24
+
25
+ el = new_block_el(:blockquote, nil, { types: @src[:type].to_s.split(','), title: @src[:title] }, location: start_line_number, admonition: true, collapsible: true)
26
+
27
+ content = parse_inner_alert_content(@src[:content].gsub(/^\s{4}/, ''))
28
+ el.children = content
29
+ @tree.children << el
30
+ true
31
+ else
32
+ false
33
+ end
34
+ end
35
+
36
+ def parse_inner_alert_content(content)
37
+ parsed = ::Kramdown::Parser::MdocsKramdown.parse(content, @options)
38
+ parsed[0].children
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,5 +1,6 @@
1
1
  module MdocsKramdown
2
2
  module Parser
3
- autoload :FencedAdmonitions, 'mdocs_kramdown/parser/admonitions'
3
+ autoload :FencedAdmonitions, 'mdocs_kramdown/parser/fenced_admonitions'
4
+ autoload :FencedCollapsibleAdmonitions, 'mdocs_kramdown/parser/fenced_collapsible_admonitions'
4
5
  end
5
6
  end
@@ -1,3 +1,3 @@
1
1
  module MdocsKramdown
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mdocs_kramdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.47369
4
+ version: 0.1.2.70482
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samoilenko Yuri
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-02-24 00:00:00.000000000 Z
11
+ date: 2021-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab_kramdown
@@ -122,6 +122,34 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: nokogiri
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: htmlbeautifier
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 1.3.0
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 1.3.0
125
153
  description: Mdocs Flavored Markdown extensions on top of Kramdown markup. Tries to
126
154
  be as close as possible to existing extensions.
127
155
  email:
@@ -137,6 +165,7 @@ files:
137
165
  - lib/mdocs_kramdown/converter/mdocs_html.rb
138
166
  - lib/mdocs_kramdown/parser.rb
139
167
  - lib/mdocs_kramdown/parser/fenced_admonitions.rb
168
+ - lib/mdocs_kramdown/parser/fenced_collapsible_admonitions.rb
140
169
  - lib/mdocs_kramdown/version.rb
141
170
  homepage: https://br.rnds.pro/ruby/mdocs_kramdown
142
171
  licenses: