markdown_helper 2.4.0 → 2.5.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: f530c806dbcaa0885c405efa0f663800b9afb5cd758c9b9ab182aa129a588b77
4
- data.tar.gz: e53416b6a71deebd8c0dc6e11721eeeac8ee8bf18494c6fe66f8afb10a4f7bcc
3
+ metadata.gz: 124d093de5339a00fe47c99c1f90136659cf21d3922baedc61e5a9aea7fe15ec
4
+ data.tar.gz: 077e4d99acaff53d4bf5f8ec1886c8b396c375dcb2ae6229fd04ca7941b2c19f
5
5
  SHA512:
6
- metadata.gz: d052b01dcb0903bfacfb0b5b87b6eb5fc95540796786bf9cc2afbe047413139b9556fe1b5bfd1c1f1548c657f532dcd6a6a609b45d506f0778719266d30591d9
7
- data.tar.gz: 453e13f39dcd61fab4ac4217695518b972c6aeb7d00fecc826f1200aafad7d55c3f941873c49b45ce8674c23c44fa0e7f622f6a0e84ed069faba0afc33593c35
6
+ metadata.gz: 1b8ef5e11f12671e0a11faf819c3ae51a29ee3956d66c1e66405913a834b6b7ad95dfb5a581d41c02bcfa12e694d00b18237b19be0ca4929d606dca14484cb52
7
+ data.tar.gz: '0981351b0c5458fedc5ce0803ed999519e55c289fb0534d3b679356f3b4e68a4266c2038aa6462d03a30654cf1d1bb2f9952ccc542c64e71f86e0f5bba6b9da9'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- markdown_helper (2.4.0)
4
+ markdown_helper (2.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- "[#{title}](##{anchor})"
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,3 +1,3 @@
1
1
  class MarkdownHelper
2
- VERSION = '2.4.0'
2
+ VERSION = '2.5.0'
3
3
  end
@@ -1,4 +1,4 @@
1
- C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/markdown_helper-2.3.0/bin/_include: Includes are circular: (MarkdownHelper::CircularIncludeError)
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.3.0/bin/_include: Includes are circular: (MarkdownHelper::CircularIncludeError)
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.3.0/bin/_include: Could not read includee file: (MarkdownHelper::UnreadableIncludeeError)
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.3.0/bin/_include: Could not read includee file: (MarkdownHelper::UnreadableIncludeeError)
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 selected Ruby snippets in the Ruby interactive shell, ```irb```.
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) with the Ruby snippets.
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 selected Ruby snippets in the Ruby interactive shell, ```irb```.
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) with the Ruby snippets.
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.0
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-08-31 00:00:00.000000000 Z
11
+ date: 2019-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler