markdown_helper 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -5
- data/CODE_OF_CONDUCT.md +74 -74
- data/Gemfile.lock +2 -1
- data/LICENSE.txt +21 -21
- data/README.md +60 -47
- data/Rakefile +16 -13
- data/bin/_include +0 -1
- data/bin/_resolve +0 -1
- data/bin/markdown_helper +3 -0
- data/bin/setup +8 -8
- data/lib/markdown_helper.rb +329 -97
- data/lib/markdown_helper/version.rb +1 -1
- data/markdown/{README.template.md → readme/README.template.md} +25 -12
- data/markdown/{code_block_ruby_template.md → readme/code_block_ruby_template.md} +0 -0
- data/markdown/{highlight_ruby_template.md → readme/highlight_ruby_template.md} +0 -0
- data/markdown/readme/highlighted_ruby.md +12 -0
- data/markdown/{include.md → readme/include.md} +0 -0
- data/markdown/{include.rb → readme/include.rb} +0 -0
- data/markdown/{include_usage.rb → readme/include_usage.rb} +0 -0
- data/markdown/{resolve.md → readme/resolve.md} +0 -0
- data/markdown/{resolve_usage.rb → readme/resolve_usage.rb} +0 -0
- data/markdown/{verbatim_ruby_template.md → readme/verbatim_ruby_template.md} +0 -0
- data/markdown/use_cases/Rakefile +53 -23
- data/markdown/use_cases/include/diagnose_circular_includes/diagnose_circular_includes.err +26 -0
- data/markdown/use_cases/include/diagnose_circular_includes/diagnose_circular_includes.rb +65 -0
- data/markdown/use_cases/include/diagnose_circular_includes/include.rb +5 -0
- data/markdown/use_cases/include/diagnose_circular_includes/includer.md +1 -0
- data/markdown/use_cases/include/diagnose_circular_includes/includer_0.md +1 -0
- data/markdown/use_cases/include/diagnose_circular_includes/includer_1.md +1 -0
- data/markdown/use_cases/include/diagnose_circular_includes/includer_2.md +1 -0
- data/markdown/use_cases/include/diagnose_circular_includes/use_case.md +98 -0
- data/markdown/use_cases/include/diagnose_circular_includes/use_case_template.md +27 -0
- data/markdown/use_cases/include/diagnose_missing_includee/diagnose_missing_includee.err +26 -0
- data/markdown/use_cases/include/diagnose_missing_includee/diagnose_missing_includee.rb +67 -0
- data/markdown/use_cases/include/diagnose_missing_includee/include.rb +5 -0
- data/markdown/use_cases/include/diagnose_missing_includee/included.md +1 -0
- data/markdown/use_cases/include/diagnose_missing_includee/includer.md +1 -0
- data/markdown/use_cases/include/diagnose_missing_includee/includer_0.md +1 -0
- data/markdown/use_cases/include/diagnose_missing_includee/includer_1.md +1 -0
- data/markdown/use_cases/include/diagnose_missing_includee/includer_2.md +1 -0
- data/markdown/use_cases/include/diagnose_missing_includee/use_case.md +100 -0
- data/markdown/use_cases/include/diagnose_missing_includee/use_case_template.md +29 -0
- data/markdown/use_cases/include/include.rb +5 -0
- data/markdown/use_cases/include/include_code_block/hello.rb +8 -0
- data/markdown/use_cases/include/include_code_block/include_code_block.rb +79 -0
- data/markdown/use_cases/include/include_code_block/included.md +14 -0
- data/markdown/use_cases/include/include_code_block/includer.md +4 -0
- data/markdown/use_cases/include/include_code_block/use_case.md +108 -0
- data/markdown/use_cases/include/include_code_block/use_case_template.md +33 -0
- data/markdown/use_cases/include/include_generated_text/include_generated_text.rb +38 -0
- data/markdown/use_cases/include/include_generated_text/use_case.md +18 -0
- data/markdown/use_cases/include/include_generated_text/use_case_template.md +18 -0
- data/markdown/use_cases/include/include_highlighted_code/hello.rb +8 -0
- data/markdown/use_cases/include/include_highlighted_code/include_highlighted_code.rb +83 -0
- data/markdown/use_cases/include/include_highlighted_code/included.md +14 -0
- data/markdown/use_cases/include/include_highlighted_code/includer.md +4 -0
- data/markdown/use_cases/include/include_highlighted_code/use_case.md +110 -0
- data/markdown/use_cases/include/include_highlighted_code/use_case_template.md +35 -0
- data/markdown/use_cases/include/include_markdown/include_markdown.rb +81 -0
- data/markdown/use_cases/include/include_markdown/included.md +13 -0
- data/markdown/use_cases/include/include_markdown/includer.md +4 -0
- data/markdown/use_cases/include/include_markdown/markdown.md +10 -0
- data/markdown/use_cases/include/include_markdown/use_case.md +106 -0
- data/markdown/use_cases/include/include_markdown/use_case_template.md +33 -0
- data/markdown/use_cases/include/include_use_case.rb +110 -0
- data/markdown/use_cases/include/include_with_added_comments/include_with_added_comments.rb +43 -60
- data/markdown/use_cases/include/include_with_added_comments/included.md +2 -2
- data/markdown/use_cases/include/include_with_added_comments/use_case.md +56 -0
- data/markdown/use_cases/include/include_with_added_comments/{template.md → use_case_template.md} +20 -1
- data/markdown/use_cases/include/interface.md +25 -0
- data/markdown/use_cases/include/nest_inclusions/included.md +5 -0
- data/markdown/use_cases/include/nest_inclusions/includee.md +3 -0
- data/markdown/use_cases/include/nest_inclusions/includer.md +3 -0
- data/markdown/use_cases/include/nest_inclusions/nest_inclusions.rb +61 -0
- data/markdown/use_cases/include/nest_inclusions/nested_includee.md +1 -0
- data/markdown/use_cases/include/nest_inclusions/use_case.md +74 -0
- data/markdown/use_cases/include/nest_inclusions/use_case_template.md +23 -0
- data/markdown/use_cases/include/reuse_text/include.rb +5 -0
- data/markdown/use_cases/include/reuse_text/included.md +2 -5
- data/markdown/use_cases/include/reuse_text/includee.md +1 -0
- data/markdown/use_cases/include/reuse_text/includer.md +2 -5
- data/markdown/use_cases/include/reuse_text/reuse_text.rb +24 -77
- data/markdown/use_cases/include/reuse_text/use_case.md +69 -0
- data/markdown/use_cases/include/reuse_text/use_case_template.md +23 -0
- data/markdown/use_cases/resolve/gemify_images/gemify_images.rb +58 -29
- data/markdown/use_cases/resolve/gemify_images/template.md +4 -0
- data/markdown/use_cases/use_case.rb +45 -0
- data/markdown/use_cases/use_cases.md +9 -2
- data/markdown_helper.gemspec +1 -1
- metadata +70 -19
- data/markdown/highlighted_ruby.md +0 -12
- data/markdown/use_cases/include/include_generated_text/build.rb +0 -46
- data/markdown/use_cases/include/include_with_added_comments/include_with_added_comments.md +0 -37
- data/markdown/use_cases/include/reuse_text/reusable_text.md +0 -1
- data/markdown/use_cases/include/reuse_text/reuse_text.md +0 -54
- data/markdown/use_cases/include/reuse_text/template.md +0 -33
@@ -0,0 +1,26 @@
|
|
1
|
+
include.rb: Could not read include file, (MarkdownHelper::MissingIncludeeError)
|
2
|
+
Backtrace (innermost include first):
|
3
|
+
Level 0:
|
4
|
+
Includer:
|
5
|
+
Location: markdown/use_cases/include/diagnose_missing_includee/includer_2.md:1
|
6
|
+
Include description: @[:markdown](includer_3.md)
|
7
|
+
Includee:
|
8
|
+
File path: markdown/use_cases/include/diagnose_missing_includee/includer_3.md
|
9
|
+
Level 1:
|
10
|
+
Includer:
|
11
|
+
Location: markdown/use_cases/include/diagnose_missing_includee/includer_1.md:1
|
12
|
+
Include description: @[:markdown](includer_2.md)
|
13
|
+
Includee:
|
14
|
+
File path: markdown/use_cases/include/diagnose_missing_includee/includer_2.md
|
15
|
+
Level 2:
|
16
|
+
Includer:
|
17
|
+
Location: markdown/use_cases/include/diagnose_missing_includee/includer_0.md:1
|
18
|
+
Include description: @[:markdown](includer_1.md)
|
19
|
+
Includee:
|
20
|
+
File path: markdown/use_cases/include/diagnose_missing_includee/includer_1.md
|
21
|
+
Level 3:
|
22
|
+
Includer:
|
23
|
+
Location: includer.md:1
|
24
|
+
Include description: @[:markdown](includer_0.md)
|
25
|
+
Includee:
|
26
|
+
File path: markdown/use_cases/include/diagnose_missing_includee/includer_0.md
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative '../include_use_case'
|
2
|
+
|
3
|
+
class DiagnoseMissingIncludee < IncludeUseCase
|
4
|
+
|
5
|
+
def self.build
|
6
|
+
|
7
|
+
use_case_name = File.basename(__FILE__, '.rb')
|
8
|
+
use_case = self.new(use_case_name)
|
9
|
+
|
10
|
+
use_case.write_ruby_file(pristine = true)
|
11
|
+
|
12
|
+
[
|
13
|
+
[0, 1],
|
14
|
+
[1, 2],
|
15
|
+
[2, 3],
|
16
|
+
].each do |indexes|
|
17
|
+
includer_index, includee_index = *indexes
|
18
|
+
includer_file_name = "includer_#{includer_index}.md"
|
19
|
+
includee_file_name = "includer_#{includee_index}.md"
|
20
|
+
if includer_index == 0
|
21
|
+
include_description = "@[:markdown](#{includer_file_name})\n"
|
22
|
+
File.write(INCLUDER_FILE_NAME, include_description)
|
23
|
+
end
|
24
|
+
include_description = "@[:markdown](#{includee_file_name})\n"
|
25
|
+
File.write(includer_file_name, include_description)
|
26
|
+
end
|
27
|
+
|
28
|
+
File.write(
|
29
|
+
TEMPLATE_FILE_NAME,
|
30
|
+
<<EOT
|
31
|
+
### Diagnose Missing Includee
|
32
|
+
|
33
|
+
Use the backtrace of inclusions to diagnose and correct a missing or otherwise unreadable includee file.
|
34
|
+
|
35
|
+
The backtrace is especially useful for errors in nested includes.
|
36
|
+
|
37
|
+
#### Files To Be Included
|
38
|
+
|
39
|
+
These files demonstrate nested inclusion, with a missing includee file.
|
40
|
+
|
41
|
+
@[markdown](includer_0.md)
|
42
|
+
|
43
|
+
@[markdown](includer_1.md)
|
44
|
+
|
45
|
+
@[markdown](includer_2.md)
|
46
|
+
|
47
|
+
#### Includer File
|
48
|
+
|
49
|
+
This file initiates the nested inclusions.
|
50
|
+
|
51
|
+
@[markdown](#{INCLUDER_FILE_NAME})
|
52
|
+
|
53
|
+
@[:markdown](../interface.md)
|
54
|
+
|
55
|
+
#### Error and Backtrace
|
56
|
+
|
57
|
+
Here's the resulting backtrace of inclusions.
|
58
|
+
|
59
|
+
@[:code_block](diagnose_missing_includee.err)
|
60
|
+
EOT
|
61
|
+
)
|
62
|
+
|
63
|
+
use_case.build
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
@[:markdown](includer_1.md}
|
@@ -0,0 +1 @@
|
|
1
|
+
@[:markdown](includer_0.md)
|
@@ -0,0 +1 @@
|
|
1
|
+
@[:markdown](includer_1.md)
|
@@ -0,0 +1 @@
|
|
1
|
+
@[:markdown](includer_2.md)
|
@@ -0,0 +1 @@
|
|
1
|
+
@[:markdown](includer_3.md)
|
@@ -0,0 +1,100 @@
|
|
1
|
+
### Diagnose Missing Includee
|
2
|
+
|
3
|
+
Use the backtrace of inclusions to diagnose and correct a missing or otherwise unreadable includee file.
|
4
|
+
|
5
|
+
The backtrace is especially useful for errors in nested includes.
|
6
|
+
|
7
|
+
#### Files To Be Included
|
8
|
+
|
9
|
+
These files demonstrate nested inclusion, with a missing includee file.
|
10
|
+
|
11
|
+
```includer_0.md```:
|
12
|
+
```markdown
|
13
|
+
@[:markdown](includer_1.md)
|
14
|
+
```
|
15
|
+
|
16
|
+
```includer_1.md```:
|
17
|
+
```markdown
|
18
|
+
@[:markdown](includer_2.md)
|
19
|
+
```
|
20
|
+
|
21
|
+
```includer_2.md```:
|
22
|
+
```markdown
|
23
|
+
@[:markdown](includer_3.md)
|
24
|
+
```
|
25
|
+
|
26
|
+
#### Includer File
|
27
|
+
|
28
|
+
This file initiates the nested inclusions.
|
29
|
+
|
30
|
+
```includer.md```:
|
31
|
+
```markdown
|
32
|
+
@[:markdown](includer_0.md)
|
33
|
+
```
|
34
|
+
|
35
|
+
#### CLI
|
36
|
+
|
37
|
+
You can use the command-line interface to perform the inclusion.
|
38
|
+
|
39
|
+
##### Command
|
40
|
+
|
41
|
+
```sh
|
42
|
+
markdown_helper include --pristine includer.md included.md
|
43
|
+
```
|
44
|
+
|
45
|
+
(Option ```--pristine``` suppresses comment insertion.)
|
46
|
+
|
47
|
+
#### API
|
48
|
+
|
49
|
+
You can use the API to perform the inclusion.
|
50
|
+
|
51
|
+
##### Ruby Code
|
52
|
+
|
53
|
+
```include.rb```:
|
54
|
+
```ruby
|
55
|
+
require 'markdown_helper'
|
56
|
+
|
57
|
+
# Option :pristine suppresses comment insertion.
|
58
|
+
markdown_helper = MarkdownHelper.new(:pristine => true)
|
59
|
+
markdown_helper.include('includer.md', 'included.md')
|
60
|
+
```
|
61
|
+
|
62
|
+
##### Command
|
63
|
+
|
64
|
+
```sh
|
65
|
+
ruby include.rb
|
66
|
+
```
|
67
|
+
|
68
|
+
#### Error and Backtrace
|
69
|
+
|
70
|
+
Here's the resulting backtrace of inclusions.
|
71
|
+
|
72
|
+
```diagnose_missing_includee.err```:
|
73
|
+
```
|
74
|
+
include.rb: Could not read include file, (MarkdownHelper::MissingIncludeeError)
|
75
|
+
Backtrace (innermost include first):
|
76
|
+
Level 0:
|
77
|
+
Includer:
|
78
|
+
Location: markdown/use_cases/include/diagnose_missing_includee/includer_2.md:1
|
79
|
+
Include description: @[:markdown](includer_3.md)
|
80
|
+
Includee:
|
81
|
+
File path: markdown/use_cases/include/diagnose_missing_includee/includer_3.md
|
82
|
+
Level 1:
|
83
|
+
Includer:
|
84
|
+
Location: markdown/use_cases/include/diagnose_missing_includee/includer_1.md:1
|
85
|
+
Include description: @[:markdown](includer_2.md)
|
86
|
+
Includee:
|
87
|
+
File path: markdown/use_cases/include/diagnose_missing_includee/includer_2.md
|
88
|
+
Level 2:
|
89
|
+
Includer:
|
90
|
+
Location: markdown/use_cases/include/diagnose_missing_includee/includer_0.md:1
|
91
|
+
Include description: @[:markdown](includer_1.md)
|
92
|
+
Includee:
|
93
|
+
File path: markdown/use_cases/include/diagnose_missing_includee/includer_1.md
|
94
|
+
Level 3:
|
95
|
+
Includer:
|
96
|
+
Location: includer.md:1
|
97
|
+
Include description: @[:markdown](includer_0.md)
|
98
|
+
Includee:
|
99
|
+
File path: markdown/use_cases/include/diagnose_missing_includee/includer_0.md
|
100
|
+
```
|
@@ -0,0 +1,29 @@
|
|
1
|
+
### Diagnose Missing Includee
|
2
|
+
|
3
|
+
Use the backtrace of inclusions to diagnose and correct a missing or otherwise unreadable includee file.
|
4
|
+
|
5
|
+
The backtrace is especially useful for errors in nested includes.
|
6
|
+
|
7
|
+
#### Files To Be Included
|
8
|
+
|
9
|
+
These files demonstrate nested inclusion, with a missing includee file.
|
10
|
+
|
11
|
+
@[markdown](includer_0.md)
|
12
|
+
|
13
|
+
@[markdown](includer_1.md)
|
14
|
+
|
15
|
+
@[markdown](includer_2.md)
|
16
|
+
|
17
|
+
#### Includer File
|
18
|
+
|
19
|
+
This file initiates the nested inclusions.
|
20
|
+
|
21
|
+
@[markdown](includer.md)
|
22
|
+
|
23
|
+
@[:markdown](../interface.md)
|
24
|
+
|
25
|
+
#### Error and Backtrace
|
26
|
+
|
27
|
+
Here's the resulting backtrace of inclusions.
|
28
|
+
|
29
|
+
@[:code_block](diagnose_missing_includee.err)
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require_relative '../include_use_case'
|
2
|
+
|
3
|
+
class IncludeCodeBlock < IncludeUseCase
|
4
|
+
|
5
|
+
def self.build
|
6
|
+
|
7
|
+
use_case_name = File.basename(__FILE__, '.rb')
|
8
|
+
use_case = self.new(use_case_name)
|
9
|
+
|
10
|
+
includee_file_name = 'hello.rb'
|
11
|
+
|
12
|
+
use_case.files_to_write.store(
|
13
|
+
includee_file_name,
|
14
|
+
<<EOT
|
15
|
+
class HelloWorld
|
16
|
+
def initialize(name)
|
17
|
+
@name = name.capitalize
|
18
|
+
end
|
19
|
+
def sayHi
|
20
|
+
puts "Hello #{@name}!"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
EOT
|
24
|
+
)
|
25
|
+
|
26
|
+
use_case.files_to_write.store(
|
27
|
+
INCLUDER_FILE_NAME,
|
28
|
+
<<EOT
|
29
|
+
This file includes the code as a code block.
|
30
|
+
|
31
|
+
@[:code_block](#{includee_file_name})
|
32
|
+
|
33
|
+
EOT
|
34
|
+
)
|
35
|
+
|
36
|
+
use_case.files_to_write.store(
|
37
|
+
TEMPLATE_FILE_NAME,
|
38
|
+
<<EOT
|
39
|
+
### Include a Code Block
|
40
|
+
|
41
|
+
Use file inclusion to include text as a code block.
|
42
|
+
|
43
|
+
#### File to Be Included
|
44
|
+
|
45
|
+
Here's a file containing code to be included:
|
46
|
+
|
47
|
+
@[markdown](#{includee_file_name})
|
48
|
+
|
49
|
+
#### Includer File
|
50
|
+
|
51
|
+
Here's a template file that includes it:
|
52
|
+
|
53
|
+
@[markdown](#{INCLUDER_FILE_NAME})
|
54
|
+
|
55
|
+
The treatment token ```:code_block``` specifies that the included text is to be treated as a code block.
|
56
|
+
|
57
|
+
@[:markdown](../interface.md)
|
58
|
+
|
59
|
+
#### File with Inclusion
|
60
|
+
|
61
|
+
Here's the finished file with the included code block:
|
62
|
+
|
63
|
+
@[:pre](#{INCLUDED_FILE_NAME})
|
64
|
+
|
65
|
+
And here's the finished markdown, as rendered on this page:
|
66
|
+
|
67
|
+
---
|
68
|
+
|
69
|
+
@[:markdown](#{INCLUDED_FILE_NAME})
|
70
|
+
|
71
|
+
---
|
72
|
+
EOT
|
73
|
+
)
|
74
|
+
|
75
|
+
use_case.build
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
### Include a Code Block
|
2
|
+
|
3
|
+
Use file inclusion to include text as a code block.
|
4
|
+
|
5
|
+
#### File to Be Included
|
6
|
+
|
7
|
+
Here's a file containing code to be included:
|
8
|
+
|
9
|
+
```hello.rb```:
|
10
|
+
```markdown
|
11
|
+
class HelloWorld
|
12
|
+
def initialize(name)
|
13
|
+
@name = name.capitalize
|
14
|
+
end
|
15
|
+
def sayHi
|
16
|
+
puts "Hello !"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
```
|
20
|
+
|
21
|
+
#### Includer File
|
22
|
+
|
23
|
+
Here's a template file that includes it:
|
24
|
+
|
25
|
+
```includer.md```:
|
26
|
+
```markdown
|
27
|
+
This file includes the code as a code block.
|
28
|
+
|
29
|
+
@[:code_block](hello.rb)
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
The treatment token ```:code_block``` specifies that the included text is to be treated as a code block.
|
34
|
+
|
35
|
+
#### CLI
|
36
|
+
|
37
|
+
You can use the command-line interface to perform the inclusion.
|
38
|
+
|
39
|
+
##### Command
|
40
|
+
|
41
|
+
```sh
|
42
|
+
markdown_helper include --pristine includer.md included.md
|
43
|
+
```
|
44
|
+
|
45
|
+
(Option ```--pristine``` suppresses comment insertion.)
|
46
|
+
|
47
|
+
#### API
|
48
|
+
|
49
|
+
You can use the API to perform the inclusion.
|
50
|
+
|
51
|
+
##### Ruby Code
|
52
|
+
|
53
|
+
```include.rb```:
|
54
|
+
```ruby
|
55
|
+
require 'markdown_helper'
|
56
|
+
|
57
|
+
# Option :pristine suppresses comment insertion.
|
58
|
+
markdown_helper = MarkdownHelper.new(:pristine => true)
|
59
|
+
markdown_helper.include('includer.md', 'included.md')
|
60
|
+
```
|
61
|
+
|
62
|
+
##### Command
|
63
|
+
|
64
|
+
```sh
|
65
|
+
ruby include.rb
|
66
|
+
```
|
67
|
+
|
68
|
+
#### File with Inclusion
|
69
|
+
|
70
|
+
Here's the finished file with the included code block:
|
71
|
+
|
72
|
+
<pre>
|
73
|
+
This file includes the code as a code block.
|
74
|
+
|
75
|
+
```hello.rb```:
|
76
|
+
```
|
77
|
+
class HelloWorld
|
78
|
+
def initialize(name)
|
79
|
+
@name = name.capitalize
|
80
|
+
end
|
81
|
+
def sayHi
|
82
|
+
puts "Hello !"
|
83
|
+
end
|
84
|
+
end
|
85
|
+
```
|
86
|
+
|
87
|
+
</pre>
|
88
|
+
|
89
|
+
And here's the finished markdown, as rendered on this page:
|
90
|
+
|
91
|
+
---
|
92
|
+
|
93
|
+
This file includes the code as a code block.
|
94
|
+
|
95
|
+
```hello.rb```:
|
96
|
+
```
|
97
|
+
class HelloWorld
|
98
|
+
def initialize(name)
|
99
|
+
@name = name.capitalize
|
100
|
+
end
|
101
|
+
def sayHi
|
102
|
+
puts "Hello !"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
```
|
106
|
+
|
107
|
+
|
108
|
+
---
|