mdocs_kramdown 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2860d96b7bd355f3a172b31640f0579c24929511d53d6de9bdd5cea290d8ab5b
4
+ data.tar.gz: b242350e158ae5dfc5e5a55e8f224a342e07ef8806cf0163f76035f62363bce8
5
+ SHA512:
6
+ metadata.gz: 4fc530ee6998adbff6c6a46155f3acf58aee1b47286d9bbcb2f1179fd1b97b6c4f9952c966bd4ceac45d1db013c87e9ecf7001160499c641d7098991d0f20982
7
+ data.tar.gz: 31272ac1996afbd7602072c5ea0cf818588cdba1a23f8eceb61a7acd62d72c9c5c0f027d7569e62c0f77c8b411885cea356c32de9ed7442ee41edd8e5fdfe18d
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014-2019 Рнд Софт
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1 @@
1
+ в процессе...
@@ -0,0 +1,15 @@
1
+ require 'gitlab_kramdown'
2
+
3
+ module Kramdown
4
+ module Parser
5
+ class MdocsKramdown < ::Kramdown::Parser::GitlabKramdown
6
+ include ::MdocsKramdown::Parser::FencedAdmonitions
7
+
8
+ def initialize(source, options)
9
+ super
10
+
11
+ prepend_block_parsers(:fenced_admonitions)
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ require 'gitlab_kramdown'
2
+
3
+ module MdocsKramdown
4
+ autoload :VERSION, 'mdocs_kramdown/version'
5
+ autoload :Parser, 'mdocs_kramdown/parser'
6
+
7
+ module Converter
8
+ autoload :MdocsHtml, 'mdocs_kramdown/converter/mdocs_html'
9
+ end
10
+ end
11
+
12
+ # Autoload extensions
13
+ Kramdown::Parser.autoload :MdocsKramdown, 'kramdown/parser/mdocs_kramdown'
14
+
15
+ # Custom HTML extensions
16
+ Kramdown::Converter::Html.prepend(MdocsKramdown::Converter::MdocsHtml)
@@ -0,0 +1,28 @@
1
+ module MdocsKramdown
2
+ module Converter
3
+ module MdocsHtml
4
+ def initialize(root, options)
5
+ super(root, options)
6
+ end
7
+
8
+ def convert_blockquote(el, indent)
9
+ return super unless el.options[:admonition]
10
+
11
+ classes = el.attr[:types]
12
+ title = el.attr[:title]
13
+
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)
20
+ end
21
+
22
+ def convert_table(el, indent)
23
+ el.attr[:class] = 'table'
24
+ super
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,5 @@
1
+ module MdocsKramdown
2
+ module Parser
3
+ autoload :FencedAdmonitions, 'mdocs_kramdown/parser/admonitions'
4
+ end
5
+ end
@@ -0,0 +1,44 @@
1
+ module MdocsKramdown
2
+ module Parser
3
+ module FencedAdmonitions
4
+ FENCED_ADMONITIONS_START = /^\s{0,}!{3}/x.freeze
5
+
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
15
+ \n
16
+ }x.freeze
17
+
18
+ def self.included(klass)
19
+ klass.define_parser(:fenced_admonitions, FENCED_BLOCKQUOTE_START)
20
+ end
21
+
22
+ def parse_fenced_admonitions
23
+ if @src.check(FENCED_ADMONITIONS_MATCH)
24
+ start_line_number = @src.current_line_number
25
+ @src.pos += @src.matched_size
26
+
27
+ el = new_block_el(:blockquote, nil, { types: @src[:type].to_s.split(','), title: @src[:title] }, location: start_line_number, admonition: true)
28
+
29
+ content = parse_inner_alert_content(@src[:content].gsub(/^\s{4}/, ''))
30
+ el.children = content
31
+ @tree.children << el
32
+ true
33
+ else
34
+ false
35
+ end
36
+ end
37
+
38
+ def parse_inner_alert_content(content)
39
+ parsed = ::Kramdown::Parser::MdocsKramdown.parse(content, @options)
40
+ parsed[0].children
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,3 @@
1
+ module MdocsKramdown
2
+ VERSION = '0.1.1'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,155 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mdocs_kramdown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Samoilenko Yuri
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gitlab_kramdown
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '6.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '6.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.21'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.21'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec_junit_formatter
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.4'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.4'
111
+ description: Mdocs Flavored Markdown extensions on top of Kramdown markup. Tries to
112
+ be as close as possible to existing extensions.
113
+ email:
114
+ - kinnalru@gmail.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - LICENSE.txt
120
+ - README.md
121
+ - lib/kramdown/parser/mdocs_kramdown.rb
122
+ - lib/mdocs_kramdown.rb
123
+ - lib/mdocs_kramdown/converter/mdocs_html.rb
124
+ - lib/mdocs_kramdown/parser.rb
125
+ - lib/mdocs_kramdown/parser/fenced_admonitions.rb
126
+ - lib/mdocs_kramdown/version.rb
127
+ homepage: https://br.rnds.pro/ruby/mdocs_kramdown
128
+ licenses:
129
+ - MIT
130
+ metadata:
131
+ homepage_uri: https://br.rnds.pro/ruby/mdocs_kramdown
132
+ source_code_uri: https://br.rnds.pro/ruby/mdocs_kramdown
133
+ changelog_uri: https://br.rnds.pro/ruby/mdocs_kramdown/blob/master/CHANGELOG.md
134
+ bug_tracker_uri: https://br.rnds.pro/ruby/mdocs_kramdown/-/issues
135
+ post_install_message:
136
+ rdoc_options: []
137
+ require_paths:
138
+ - lib
139
+ required_ruby_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: 2.5.7
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ requirements:
146
+ - - ">="
147
+ - !ruby/object:Gem::Version
148
+ version: '0'
149
+ requirements: []
150
+ rubyforge_project:
151
+ rubygems_version: 2.7.10
152
+ signing_key:
153
+ specification_version: 4
154
+ summary: Mdocs Flavored Kramdown
155
+ test_files: []