markdown_helper 2.4.0 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/markdown_helper/markdown_includer.rb +12 -6
- data/lib/markdown_helper/markdown_irb_runner.rb +1 -1
- data/lib/markdown_helper/version.rb +1 -1
- data/markdown/use_cases/include/diagnose_circular_includes/diagnose_circular_includes.err +1 -1
- data/markdown/use_cases/include/diagnose_circular_includes/use_case.md +1 -1
- data/markdown/use_cases/include/diagnose_missing_includee/diagnose_missing_includee.err +1 -1
- data/markdown/use_cases/include/diagnose_missing_includee/use_case.md +1 -1
- data/markdown/use_cases/run_irb/run_irb/use_case.md +2 -2
- data/markdown/use_cases/run_irb/run_irb/use_case_template.md +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 124d093de5339a00fe47c99c1f90136659cf21d3922baedc61e5a9aea7fe15ec
|
4
|
+
data.tar.gz: 077e4d99acaff53d4bf5f8ec1886c8b396c375dcb2ae6229fd04ca7941b2c19f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b8ef5e11f12671e0a11faf819c3ae51a29ee3956d66c1e66405913a834b6b7ad95dfb5a581d41c02bcfa12e694d00b18237b19be0ca4929d606dca14484cb52
|
7
|
+
data.tar.gz: '0981351b0c5458fedc5ce0803ed999519e55c289fb0534d3b679356f3b4e68a4266c2038aa6462d03a30654cf1d1bb2f9952ccc542c64e71f86e0f5bba6b9da9'
|
data/Gemfile.lock
CHANGED
@@ -92,6 +92,7 @@ class MarkdownIncluder < MarkdownHelper
|
|
92
92
|
def include_page_toc(template_lines)
|
93
93
|
toc_line_index = nil
|
94
94
|
toc_title = nil
|
95
|
+
anchor_counts = Hash.new(0)
|
95
96
|
template_lines.each_with_index do |template_line, i|
|
96
97
|
match_data = template_line.match(INCLUDE_REGEXP)
|
97
98
|
next unless match_data
|
@@ -113,13 +114,16 @@ class MarkdownIncluder < MarkdownHelper
|
|
113
114
|
toc_lines = [toc_title]
|
114
115
|
first_heading_level = nil
|
115
116
|
template_lines.each_with_index do |input_line, i|
|
116
|
-
next if i < toc_line_index
|
117
117
|
line = input_line.chomp
|
118
118
|
heading = Heading.parse(line)
|
119
119
|
next unless heading
|
120
|
+
if i < toc_line_index
|
121
|
+
heading.link(anchor_counts)
|
122
|
+
next
|
123
|
+
end
|
120
124
|
first_heading_level ||= heading.level
|
121
125
|
indentation = ' ' * (heading.level - first_heading_level)
|
122
|
-
toc_line = "#{indentation}- #{heading.link}"
|
126
|
+
toc_line = "#{indentation}- #{heading.link(anchor_counts)}"
|
123
127
|
toc_lines.push(toc_line)
|
124
128
|
end
|
125
129
|
template_lines.delete_at(toc_line_index)
|
@@ -198,16 +202,18 @@ class MarkdownIncluder < MarkdownHelper
|
|
198
202
|
end
|
199
203
|
|
200
204
|
|
201
|
-
def link
|
202
|
-
remove_regexp = /[
|
205
|
+
def link(anchor_counts = Hash.new(0))
|
206
|
+
remove_regexp = /[\=\#\(\)\[\]\{\}\.\?\+\*\`\"\']+/
|
203
207
|
to_hyphen_regexp = /\W+/
|
204
208
|
anchor = title.
|
205
209
|
gsub(remove_regexp, '').
|
206
210
|
gsub(to_hyphen_regexp, '-').
|
207
211
|
downcase
|
208
|
-
|
212
|
+
anchor_count = anchor_counts[anchor]
|
213
|
+
anchor_counts[anchor] += 1
|
214
|
+
suffix = (anchor_count == 0) ? '' : "-#{anchor_count}"
|
215
|
+
"[#{title}](##{anchor}#{suffix})"
|
209
216
|
end
|
210
|
-
|
211
217
|
end
|
212
218
|
|
213
219
|
def check_circularity(inclusion)
|
@@ -36,7 +36,7 @@ class MarkdownIrbRunner < MarkdownHelper
|
|
36
36
|
Dir.mktmpdir do |dir|
|
37
37
|
Dir.chdir(dir) do
|
38
38
|
File.write('irb_input', irb_input)
|
39
|
-
command = 'irb --noecho irb_input | tail +2 | head --lines=-2 > irb_output'
|
39
|
+
command = 'irb --noecho --noprompt irb_input | tail +2 | head --lines=-2 > irb_output'
|
40
40
|
system(command )
|
41
41
|
File.read('irb_output')
|
42
42
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.
|
1
|
+
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.4.0/bin/_include: Includes are circular: (MarkdownHelper::CircularIncludeError)
|
2
2
|
Backtrace (innermost include first):
|
3
3
|
Level 0:
|
4
4
|
Includer:
|
@@ -60,7 +60,7 @@ Here's the resulting backtrace of inclusions.
|
|
60
60
|
|
61
61
|
```diagnose_circular_includes.err```:
|
62
62
|
```
|
63
|
-
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.
|
63
|
+
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.4.0/bin/_include: Includes are circular: (MarkdownHelper::CircularIncludeError)
|
64
64
|
Backtrace (innermost include first):
|
65
65
|
Level 0:
|
66
66
|
Includer:
|
@@ -1,4 +1,4 @@
|
|
1
|
-
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.
|
1
|
+
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.4.0/bin/_include: Could not read includee file: (MarkdownHelper::UnreadableIncludeeError)
|
2
2
|
Backtrace (innermost include first):
|
3
3
|
Level 0:
|
4
4
|
Includer:
|
@@ -62,7 +62,7 @@ Here's the resulting backtrace of inclusions.
|
|
62
62
|
|
63
63
|
```diagnose_missing_includee.err```:
|
64
64
|
```
|
65
|
-
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.
|
65
|
+
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.4.0/bin/_include: Could not read includee file: (MarkdownHelper::UnreadableIncludeeError)
|
66
66
|
Backtrace (innermost include first):
|
67
67
|
Level 0:
|
68
68
|
Includer:
|
@@ -1,8 +1,8 @@
|
|
1
1
|
### Run Irb
|
2
2
|
|
3
|
-
Use the ```run_irb``` feature to execute
|
3
|
+
Use the ```run_irb``` feature to execute markdown-embedded Ruby snippets in the Ruby interactive shell, ```irb```.
|
4
4
|
|
5
|
-
This allows you to interleave *any* markdown (usually explanatory text, but actually anything)
|
5
|
+
This allows you to interleave Ruby snippets with *any* markdown (usually explanatory text, but actually anything).
|
6
6
|
|
7
7
|
In the example template below, snippets of Ruby are interleaved with other markdown elements.
|
8
8
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
### Run Irb
|
2
2
|
|
3
|
-
Use the ```run_irb``` feature to execute
|
3
|
+
Use the ```run_irb``` feature to execute markdown-embedded Ruby snippets in the Ruby interactive shell, ```irb```.
|
4
4
|
|
5
|
-
This allows you to interleave *any* markdown (usually explanatory text, but actually anything)
|
5
|
+
This allows you to interleave Ruby snippets with *any* markdown (usually explanatory text, but actually anything).
|
6
6
|
|
7
7
|
In the example template below, snippets of Ruby are interleaved with other markdown elements.
|
8
8
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- burdettelamar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|