markdown_helper 2.0.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +1 -1
- data/README.md +74 -208
- data/Rakefile +0 -1
- data/lib/markdown_helper.rb +115 -248
- data/lib/markdown_helper/version.rb +1 -1
- data/markdown/readme/README.template.md +43 -101
- data/markdown/readme/include.md +4 -0
- data/markdown/readme/include_usage.rb +1 -2
- data/markdown/use_cases/Rakefile +28 -31
- data/markdown/use_cases/include_files/diagnose_circular_includes/diagnose_circular_includes.err +1 -1
- data/markdown/use_cases/include_files/diagnose_circular_includes/use_case.md +1 -1
- data/markdown/use_cases/include_files/diagnose_circular_includes/{diagnose_circular_includes.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/include_files/diagnose_missing_includee/diagnose_missing_includee.err +1 -1
- data/markdown/use_cases/include_files/diagnose_missing_includee/use_case.md +1 -1
- data/markdown/use_cases/include_files/diagnose_missing_includee/{diagnose_missing_includee.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/include_files/include_code_block/{include_code_block.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/include_files/include_generated_text/{include_generated_text.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/include_files/include_highlighted_code/{include_highlighted_code.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/include_files/include_markdown/{include_markdown.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/include_files/include_page_toc/included.md +48 -0
- data/markdown/use_cases/include_files/include_page_toc/includer.md +16 -0
- data/markdown/use_cases/include_files/include_page_toc/markdown_0.md +8 -0
- data/markdown/use_cases/include_files/include_page_toc/markdown_1.md +8 -0
- data/markdown/use_cases/include_files/include_page_toc/use_case.md +212 -0
- data/markdown/use_cases/include_files/include_page_toc/use_case_builder.rb +121 -0
- data/markdown/use_cases/include_files/include_page_toc/use_case_template.md +46 -0
- data/markdown/use_cases/include_files/include_text_as_comment/{include_text_as_comment.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/include_files/include_text_as_pre/{include_text_as_pre.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/include_files/include_use_case.rb +2 -8
- data/markdown/use_cases/include_files/include_with_added_comments/{include_with_added_comments.rb → use_case_builder.rb} +2 -3
- data/markdown/use_cases/include_files/nest_inclusions/{nest_inclusions.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/include_files/reuse_text/{reuse_text.rb → use_case_builder.rb} +3 -2
- data/markdown/use_cases/structure.md +10 -0
- data/markdown/use_cases/tables_of_contents/create_and_include_page_toc/included.md +44 -0
- data/markdown/use_cases/tables_of_contents/create_and_include_page_toc/page.md +7 -7
- data/markdown/use_cases/tables_of_contents/create_and_include_page_toc/toc.md +7 -7
- data/markdown/use_cases/tables_of_contents/create_and_include_page_toc/{create_and_include_page_toc.rb → use_case_builder.rb} +1 -2
- data/markdown/use_cases/tables_of_contents/create_page_toc_use_case.rb +1 -1
- data/markdown/use_cases/use_case.rb +14 -15
- data/markdown/use_cases/use_cases.md +2 -4
- data/markdown_helper.gemspec +0 -2
- metadata +24 -29
- data/bin/_resolve +0 -46
- data/bin/resolve +0 -49
- data/bin/usage/resolve.txt +0 -14
- data/images/html.png +0 -0
- data/markdown/readme/resolve_usage.rb +0 -12
- data/markdown/use_cases/include_files/diagnose_missing_includee/included.md +0 -1
- data/markdown/use_cases/resolve/gemify_images/gemify_images.md +0 -11
- data/markdown/use_cases/resolve/gemify_images/gemify_images.rb +0 -68
- data/markdown/use_cases/resolve/gemify_images/relative_image.md +0 -1
- data/markdown/use_cases/resolve/gemify_images/resolved_image.md +0 -1
- data/markdown/use_cases/resolve/gemify_images/template.md +0 -15
- data/markdown/use_cases/resolve/resize_images/template.md +0 -8
@@ -0,0 +1,16 @@
|
|
1
|
+
# Page Title
|
2
|
+
|
3
|
+
@[:page_toc](## Page Contents)
|
4
|
+
|
5
|
+
## Includer level-two title.
|
6
|
+
|
7
|
+
### Includer level-three title.
|
8
|
+
|
9
|
+
### Another includer level-three title.
|
10
|
+
|
11
|
+
## Another includer level-two title.
|
12
|
+
|
13
|
+
@[:markdown](markdown_0.md)
|
14
|
+
|
15
|
+
@[:markdown](markdown_1.md)
|
16
|
+
|
@@ -0,0 +1,212 @@
|
|
1
|
+
### Include Page TOC
|
2
|
+
|
3
|
+
Use file inclusion to include a page table of contents (page TOC).
|
4
|
+
|
5
|
+
The page TOC is a tree of links:
|
6
|
+
|
7
|
+
- Each link goes to a corresponding markdown title.
|
8
|
+
- The tree structure reflects the relative depths of the linked headers.
|
9
|
+
|
10
|
+
Below are files to be included and an includer file that will generate the page TOC.
|
11
|
+
|
12
|
+
Note that all file inclusion (even nested inclusions) will be performed before the page TOC is built, so the page TOC covers all the included material.
|
13
|
+
|
14
|
+
#### Files to Be Included
|
15
|
+
|
16
|
+
Here's a file containing markdown to be included:
|
17
|
+
|
18
|
+
```markdown_0.md```:
|
19
|
+
```markdown
|
20
|
+
|
21
|
+
## Includee 0 level-two title.
|
22
|
+
|
23
|
+
### Includee 0 level-three title.
|
24
|
+
|
25
|
+
### Another includee 0 level-three title.
|
26
|
+
|
27
|
+
## Another includee 0 level-two title.
|
28
|
+
```
|
29
|
+
|
30
|
+
Here's another:
|
31
|
+
|
32
|
+
```markdown_1.md```:
|
33
|
+
```markdown
|
34
|
+
|
35
|
+
## Includee 1 level-two title.
|
36
|
+
|
37
|
+
### Includee 1 level-three title.
|
38
|
+
|
39
|
+
### Another includee 1 level-three title.
|
40
|
+
|
41
|
+
## Another includee 1 level-two title.
|
42
|
+
```
|
43
|
+
|
44
|
+
#### Includer File
|
45
|
+
|
46
|
+
Here's a template file that includes them:
|
47
|
+
|
48
|
+
```includer.md```:
|
49
|
+
```markdown
|
50
|
+
# Page Title
|
51
|
+
|
52
|
+
@[:page_toc](## Page Contents)
|
53
|
+
|
54
|
+
## Includer level-two title.
|
55
|
+
|
56
|
+
### Includer level-three title.
|
57
|
+
|
58
|
+
### Another includer level-three title.
|
59
|
+
|
60
|
+
## Another includer level-two title.
|
61
|
+
|
62
|
+
@[:markdown](markdown_0.md)
|
63
|
+
|
64
|
+
@[:markdown](markdown_1.md)
|
65
|
+
|
66
|
+
```
|
67
|
+
|
68
|
+
The treatment token ```:page_toc``` specifies where the page TOC is to be inserted.
|
69
|
+
|
70
|
+
#### CLI
|
71
|
+
|
72
|
+
You can use the command-line interface to perform the inclusion.
|
73
|
+
|
74
|
+
##### Command
|
75
|
+
|
76
|
+
```sh
|
77
|
+
markdown_helper include --pristine includer.md included.md
|
78
|
+
```
|
79
|
+
|
80
|
+
(Option ```--pristine``` suppresses comment insertion.)
|
81
|
+
|
82
|
+
#### API
|
83
|
+
|
84
|
+
You can use the API to perform the inclusion.
|
85
|
+
|
86
|
+
##### Ruby Code
|
87
|
+
|
88
|
+
```include.rb```:
|
89
|
+
```ruby
|
90
|
+
require 'markdown_helper'
|
91
|
+
|
92
|
+
# Option :pristine suppresses comment insertion.
|
93
|
+
markdown_helper = MarkdownHelper.new(:pristine => true)
|
94
|
+
markdown_helper.include('includer.md', 'included.md')
|
95
|
+
```
|
96
|
+
|
97
|
+
##### Command
|
98
|
+
|
99
|
+
```sh
|
100
|
+
ruby include.rb
|
101
|
+
```
|
102
|
+
|
103
|
+
#### File with Inclusion
|
104
|
+
|
105
|
+
Here's the finished file with the inclusion:
|
106
|
+
|
107
|
+
```included.md```:
|
108
|
+
```markdown
|
109
|
+
<!-- >>>>>> BEGIN GENERATED FILE (include): SOURCE includer.md -->
|
110
|
+
# Page Title
|
111
|
+
|
112
|
+
## Page Contents
|
113
|
+
- [Includer level-two title.](#includer-level-two-title)
|
114
|
+
- [Includer level-three title.](#includer-level-three-title)
|
115
|
+
- [Another includer level-three title.](#another-includer-level-three-title)
|
116
|
+
- [Another includer level-two title.](#another-includer-level-two-title)
|
117
|
+
- [Includee 0 level-two title.](#includee-0-level-two-title)
|
118
|
+
- [Includee 0 level-three title.](#includee-0-level-three-title)
|
119
|
+
- [Another includee 0 level-three title.](#another-includee-0-level-three-title)
|
120
|
+
- [Another includee 0 level-two title.](#another-includee-0-level-two-title)
|
121
|
+
- [Includee 1 level-two title.](#includee-1-level-two-title)
|
122
|
+
- [Includee 1 level-three title.](#includee-1-level-three-title)
|
123
|
+
- [Another includee 1 level-three title.](#another-includee-1-level-three-title)
|
124
|
+
- [Another includee 1 level-two title.](#another-includee-1-level-two-title)
|
125
|
+
|
126
|
+
## Includer level-two title.
|
127
|
+
|
128
|
+
### Includer level-three title.
|
129
|
+
|
130
|
+
### Another includer level-three title.
|
131
|
+
|
132
|
+
## Another includer level-two title.
|
133
|
+
|
134
|
+
<!-- >>>>>> BEGIN INCLUDED FILE (markdown): SOURCE markdown/use_cases/include_files/include_page_toc/markdown_0.md -->
|
135
|
+
|
136
|
+
## Includee 0 level-two title.
|
137
|
+
|
138
|
+
### Includee 0 level-three title.
|
139
|
+
|
140
|
+
### Another includee 0 level-three title.
|
141
|
+
|
142
|
+
## Another includee 0 level-two title.
|
143
|
+
<!-- <<<<<< END INCLUDED FILE (markdown): SOURCE markdown/use_cases/include_files/include_page_toc/markdown_0.md -->
|
144
|
+
|
145
|
+
<!-- >>>>>> BEGIN INCLUDED FILE (markdown): SOURCE markdown/use_cases/include_files/include_page_toc/markdown_1.md -->
|
146
|
+
|
147
|
+
## Includee 1 level-two title.
|
148
|
+
|
149
|
+
### Includee 1 level-three title.
|
150
|
+
|
151
|
+
### Another includee 1 level-three title.
|
152
|
+
|
153
|
+
## Another includee 1 level-two title.
|
154
|
+
<!-- <<<<<< END INCLUDED FILE (markdown): SOURCE markdown/use_cases/include_files/include_page_toc/markdown_1.md -->
|
155
|
+
|
156
|
+
<!-- <<<<<< END GENERATED FILE (include): SOURCE includer.md -->
|
157
|
+
```
|
158
|
+
|
159
|
+
And here's the finished markdown, as rendered on this page:
|
160
|
+
|
161
|
+
---
|
162
|
+
|
163
|
+
<!-- >>>>>> BEGIN GENERATED FILE (include): SOURCE includer.md -->
|
164
|
+
# Page Title
|
165
|
+
|
166
|
+
## Page Contents
|
167
|
+
- [Includer level-two title.](#includer-level-two-title)
|
168
|
+
- [Includer level-three title.](#includer-level-three-title)
|
169
|
+
- [Another includer level-three title.](#another-includer-level-three-title)
|
170
|
+
- [Another includer level-two title.](#another-includer-level-two-title)
|
171
|
+
- [Includee 0 level-two title.](#includee-0-level-two-title)
|
172
|
+
- [Includee 0 level-three title.](#includee-0-level-three-title)
|
173
|
+
- [Another includee 0 level-three title.](#another-includee-0-level-three-title)
|
174
|
+
- [Another includee 0 level-two title.](#another-includee-0-level-two-title)
|
175
|
+
- [Includee 1 level-two title.](#includee-1-level-two-title)
|
176
|
+
- [Includee 1 level-three title.](#includee-1-level-three-title)
|
177
|
+
- [Another includee 1 level-three title.](#another-includee-1-level-three-title)
|
178
|
+
- [Another includee 1 level-two title.](#another-includee-1-level-two-title)
|
179
|
+
|
180
|
+
## Includer level-two title.
|
181
|
+
|
182
|
+
### Includer level-three title.
|
183
|
+
|
184
|
+
### Another includer level-three title.
|
185
|
+
|
186
|
+
## Another includer level-two title.
|
187
|
+
|
188
|
+
<!-- >>>>>> BEGIN INCLUDED FILE (markdown): SOURCE markdown/use_cases/include_files/include_page_toc/markdown_0.md -->
|
189
|
+
|
190
|
+
## Includee 0 level-two title.
|
191
|
+
|
192
|
+
### Includee 0 level-three title.
|
193
|
+
|
194
|
+
### Another includee 0 level-three title.
|
195
|
+
|
196
|
+
## Another includee 0 level-two title.
|
197
|
+
<!-- <<<<<< END INCLUDED FILE (markdown): SOURCE markdown/use_cases/include_files/include_page_toc/markdown_0.md -->
|
198
|
+
|
199
|
+
<!-- >>>>>> BEGIN INCLUDED FILE (markdown): SOURCE markdown/use_cases/include_files/include_page_toc/markdown_1.md -->
|
200
|
+
|
201
|
+
## Includee 1 level-two title.
|
202
|
+
|
203
|
+
### Includee 1 level-three title.
|
204
|
+
|
205
|
+
### Another includee 1 level-three title.
|
206
|
+
|
207
|
+
## Another includee 1 level-two title.
|
208
|
+
<!-- <<<<<< END INCLUDED FILE (markdown): SOURCE markdown/use_cases/include_files/include_page_toc/markdown_1.md -->
|
209
|
+
|
210
|
+
<!-- <<<<<< END GENERATED FILE (include): SOURCE includer.md -->
|
211
|
+
|
212
|
+
---
|
@@ -0,0 +1,121 @@
|
|
1
|
+
require_relative '../include_use_case'
|
2
|
+
|
3
|
+
class IncludePageToc < IncludeUseCase
|
4
|
+
|
5
|
+
def self.build
|
6
|
+
|
7
|
+
use_case = self.new
|
8
|
+
|
9
|
+
include_command = IncludeUseCase.construct_include_command(INCLUDER_FILE_NAME, INCLUDED_FILE_NAME, pristine = false)
|
10
|
+
use_case.commands_to_execute.unshift(include_command)
|
11
|
+
|
12
|
+
includee_0_file_name = 'markdown_0.md'
|
13
|
+
includee_1_file_name = 'markdown_1.md'
|
14
|
+
|
15
|
+
use_case.files_to_write.store(
|
16
|
+
includee_0_file_name,
|
17
|
+
<<EOT
|
18
|
+
|
19
|
+
## Includee 0 level-two title.
|
20
|
+
|
21
|
+
### Includee 0 level-three title.
|
22
|
+
|
23
|
+
### Another includee 0 level-three title.
|
24
|
+
|
25
|
+
## Another includee 0 level-two title.
|
26
|
+
EOT
|
27
|
+
)
|
28
|
+
|
29
|
+
use_case.files_to_write.store(
|
30
|
+
includee_1_file_name,
|
31
|
+
<<EOT
|
32
|
+
|
33
|
+
## Includee 1 level-two title.
|
34
|
+
|
35
|
+
### Includee 1 level-three title.
|
36
|
+
|
37
|
+
### Another includee 1 level-three title.
|
38
|
+
|
39
|
+
## Another includee 1 level-two title.
|
40
|
+
EOT
|
41
|
+
)
|
42
|
+
|
43
|
+
use_case.files_to_write.store(
|
44
|
+
INCLUDER_FILE_NAME,
|
45
|
+
<<EOT
|
46
|
+
# Page Title
|
47
|
+
|
48
|
+
@[:page_toc](## Page Contents)
|
49
|
+
|
50
|
+
## Includer level-two title.
|
51
|
+
|
52
|
+
### Includer level-three title.
|
53
|
+
|
54
|
+
### Another includer level-three title.
|
55
|
+
|
56
|
+
## Another includer level-two title.
|
57
|
+
|
58
|
+
@[:markdown](#{includee_0_file_name})
|
59
|
+
|
60
|
+
@[:markdown](#{includee_1_file_name})
|
61
|
+
|
62
|
+
EOT
|
63
|
+
)
|
64
|
+
|
65
|
+
use_case.files_to_write.store(
|
66
|
+
TEMPLATE_FILE_NAME,
|
67
|
+
<<EOT
|
68
|
+
### Include Page TOC
|
69
|
+
|
70
|
+
Use file inclusion to include a page table of contents (page TOC).
|
71
|
+
|
72
|
+
The page TOC is a tree of links:
|
73
|
+
|
74
|
+
- Each link goes to a corresponding markdown title.
|
75
|
+
- The tree structure reflects the relative depths of the linked headers.
|
76
|
+
|
77
|
+
Below are files to be included and an includer file that will generate the page TOC.
|
78
|
+
|
79
|
+
Note that all file inclusion (even nested inclusions) will be performed before the page TOC is built, so the page TOC covers all the included material.
|
80
|
+
|
81
|
+
#### Files to Be Included
|
82
|
+
|
83
|
+
Here's a file containing markdown to be included:
|
84
|
+
|
85
|
+
@[markdown](#{includee_0_file_name})
|
86
|
+
|
87
|
+
Here's another:
|
88
|
+
|
89
|
+
@[markdown](#{includee_1_file_name})
|
90
|
+
|
91
|
+
#### Includer File
|
92
|
+
|
93
|
+
Here's a template file that includes them:
|
94
|
+
|
95
|
+
@[markdown](#{INCLUDER_FILE_NAME})
|
96
|
+
|
97
|
+
The treatment token ```:page_toc``` specifies where the page TOC is to be inserted.
|
98
|
+
|
99
|
+
@[:markdown](../interface.md)
|
100
|
+
|
101
|
+
#### File with Inclusion
|
102
|
+
|
103
|
+
Here's the finished file with the inclusion:
|
104
|
+
|
105
|
+
@[markdown](#{INCLUDED_FILE_NAME})
|
106
|
+
|
107
|
+
And here's the finished markdown, as rendered on this page:
|
108
|
+
|
109
|
+
---
|
110
|
+
|
111
|
+
@[:markdown](#{INCLUDED_FILE_NAME})
|
112
|
+
|
113
|
+
---
|
114
|
+
EOT
|
115
|
+
)
|
116
|
+
|
117
|
+
use_case.build
|
118
|
+
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
### Include Page TOC
|
2
|
+
|
3
|
+
Use file inclusion to include a page table of contents (page TOC).
|
4
|
+
|
5
|
+
The page TOC is a tree of links:
|
6
|
+
|
7
|
+
- Each link goes to a corresponding markdown title.
|
8
|
+
- The tree structure reflects the relative depths of the linked headers.
|
9
|
+
|
10
|
+
Below are files to be included and an includer file that will generate the page TOC.
|
11
|
+
|
12
|
+
Note that all file inclusion (even nested inclusions) will be performed before the page TOC is built, so the page TOC covers all the included material.
|
13
|
+
|
14
|
+
#### Files to Be Included
|
15
|
+
|
16
|
+
Here's a file containing markdown to be included:
|
17
|
+
|
18
|
+
@[markdown](markdown_0.md)
|
19
|
+
|
20
|
+
Here's another:
|
21
|
+
|
22
|
+
@[markdown](markdown_1.md)
|
23
|
+
|
24
|
+
#### Includer File
|
25
|
+
|
26
|
+
Here's a template file that includes them:
|
27
|
+
|
28
|
+
@[markdown](includer.md)
|
29
|
+
|
30
|
+
The treatment token ```:page_toc``` specifies where the page TOC is to be inserted.
|
31
|
+
|
32
|
+
@[:markdown](../interface.md)
|
33
|
+
|
34
|
+
#### File with Inclusion
|
35
|
+
|
36
|
+
Here's the finished file with the inclusion:
|
37
|
+
|
38
|
+
@[markdown](included.md)
|
39
|
+
|
40
|
+
And here's the finished markdown, as rendered on this page:
|
41
|
+
|
42
|
+
---
|
43
|
+
|
44
|
+
@[:markdown](included.md)
|
45
|
+
|
46
|
+
---
|
@@ -17,16 +17,10 @@ class IncludeUseCase < UseCase
|
|
17
17
|
|
18
18
|
BUILD_COMMAND = UseCase.construct_include_command(TEMPLATE_FILE_NAME, USE_CASE_FILE_NAME, pristine = true)
|
19
19
|
|
20
|
-
def initialize
|
21
|
-
|
20
|
+
def initialize
|
22
21
|
super
|
23
|
-
|
24
|
-
commands_to_execute.push(RUBY_COMMAND) if File.exist?(RUBY_FILE_NAME)
|
25
|
-
commands_to_execute.push(BUILD_COMMAND) if File.exist?(TEMPLATE_FILE_NAME)
|
26
|
-
|
22
|
+
commands_to_execute.push(BUILD_COMMAND)
|
27
23
|
self.use_case_dir_name = use_case_dir_name
|
28
|
-
|
29
|
-
|
30
24
|
end
|
31
25
|
|
32
26
|
def use_case_dir_path
|