markdown_helper 1.8.0 → 1.9.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 +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
data/markdown/use_cases/include/include_with_added_comments/{template.md → use_case_template.md}
RENAMED
@@ -13,12 +13,31 @@ By default (that is, without option ```--pristine```) file inclusion adds commen
|
|
13
13
|
|
14
14
|
@[markdown](includer.md)
|
15
15
|
|
16
|
-
####
|
16
|
+
#### CLI
|
17
|
+
|
18
|
+
You can use the command-line interface to perform the inclusion.
|
19
|
+
|
20
|
+
##### Command
|
17
21
|
|
18
22
|
```sh
|
19
23
|
markdown_helper include includer.md included.md
|
20
24
|
```
|
21
25
|
|
26
|
+
#### API
|
27
|
+
|
28
|
+
You can use the API to perform the inclusion.
|
29
|
+
|
30
|
+
##### Ruby Code
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'markdown_helper'
|
34
|
+
|
35
|
+
markdown_helper = MarkdownHelper.new
|
36
|
+
markdown_helper.include(includer.md, included.md)
|
37
|
+
```
|
38
|
+
|
22
39
|
#### File with Inclusion and Added Comments
|
23
40
|
|
24
41
|
@[markdown](included.md)
|
42
|
+
|
43
|
+
The file path for the included file is relative to the .git directory.
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#### CLI
|
2
|
+
|
3
|
+
You can use the command-line interface to perform the inclusion.
|
4
|
+
|
5
|
+
##### Command
|
6
|
+
|
7
|
+
```sh
|
8
|
+
markdown_helper include --pristine includer.md included.md
|
9
|
+
```
|
10
|
+
|
11
|
+
@[:markdown](../pristine.md)
|
12
|
+
|
13
|
+
#### API
|
14
|
+
|
15
|
+
You can use the API to perform the inclusion.
|
16
|
+
|
17
|
+
##### Ruby Code
|
18
|
+
|
19
|
+
@[ruby](include.rb)
|
20
|
+
|
21
|
+
##### Command
|
22
|
+
|
23
|
+
```sh
|
24
|
+
ruby include.rb
|
25
|
+
```
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require_relative '../include_use_case'
|
2
|
+
|
3
|
+
class NestInclusions < 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
|
+
nested_includee_file_name = 'nested_includee.md'
|
11
|
+
|
12
|
+
use_case.files_to_write.store(
|
13
|
+
nested_includee_file_name,
|
14
|
+
<<EOT
|
15
|
+
Text for nested inclusion.
|
16
|
+
EOT
|
17
|
+
)
|
18
|
+
|
19
|
+
use_case.files_to_write.store(
|
20
|
+
INCLUDER_FILE_NAME,
|
21
|
+
<<EOT
|
22
|
+
File to do nested inclusion.
|
23
|
+
|
24
|
+
@[:markdown](#{INCLUDEE_FILE_NAME})
|
25
|
+
EOT
|
26
|
+
)
|
27
|
+
|
28
|
+
use_case.files_to_write.store(
|
29
|
+
TEMPLATE_FILE_NAME,
|
30
|
+
<<EOT
|
31
|
+
### Nest Inclusions
|
32
|
+
|
33
|
+
An included markdown file can itself include more files.
|
34
|
+
|
35
|
+
#### File To Be Included
|
36
|
+
|
37
|
+
@[markdown](#{INCLUDEE_FILE_NAME})
|
38
|
+
|
39
|
+
#### File For Nested Inclusion
|
40
|
+
|
41
|
+
@[markdown](#{nested_includee_file_name})
|
42
|
+
|
43
|
+
#### Includer File
|
44
|
+
|
45
|
+
@[markdown](#{INCLUDER_FILE_NAME})
|
46
|
+
|
47
|
+
@[:markdown](../interface.md)
|
48
|
+
|
49
|
+
#### File with Inclusion
|
50
|
+
|
51
|
+
Here's the finished file with the inclusion and nested inclusion:
|
52
|
+
|
53
|
+
@[markdown](#{INCLUDED_FILE_NAME})
|
54
|
+
EOT
|
55
|
+
)
|
56
|
+
|
57
|
+
use_case.build
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Text for nested inclusion.
|
@@ -0,0 +1,74 @@
|
|
1
|
+
### Nest Inclusions
|
2
|
+
|
3
|
+
An included markdown file can itself include more files.
|
4
|
+
|
5
|
+
#### File To Be Included
|
6
|
+
|
7
|
+
```includee.md```:
|
8
|
+
```markdown
|
9
|
+
Text for inclusion, and a nested inclusion.
|
10
|
+
|
11
|
+
@[:markdown](nested_includee.md)
|
12
|
+
```
|
13
|
+
|
14
|
+
#### File For Nested Inclusion
|
15
|
+
|
16
|
+
```nested_includee.md```:
|
17
|
+
```markdown
|
18
|
+
Text for nested inclusion.
|
19
|
+
```
|
20
|
+
|
21
|
+
#### Includer File
|
22
|
+
|
23
|
+
```includer.md```:
|
24
|
+
```markdown
|
25
|
+
File to do nested inclusion.
|
26
|
+
|
27
|
+
@[:markdown](includee.md)
|
28
|
+
```
|
29
|
+
|
30
|
+
#### CLI
|
31
|
+
|
32
|
+
You can use the command-line interface to perform the inclusion.
|
33
|
+
|
34
|
+
##### Command
|
35
|
+
|
36
|
+
```sh
|
37
|
+
markdown_helper include --pristine includer.md included.md
|
38
|
+
```
|
39
|
+
|
40
|
+
(Option ```--pristine``` suppresses comment insertion.)
|
41
|
+
|
42
|
+
#### API
|
43
|
+
|
44
|
+
You can use the API to perform the inclusion.
|
45
|
+
|
46
|
+
##### Ruby Code
|
47
|
+
|
48
|
+
```include.rb```:
|
49
|
+
```ruby
|
50
|
+
require 'markdown_helper'
|
51
|
+
|
52
|
+
# Option :pristine suppresses comment insertion.
|
53
|
+
markdown_helper = MarkdownHelper.new(:pristine => true)
|
54
|
+
markdown_helper.include('includer.md', 'included.md')
|
55
|
+
```
|
56
|
+
|
57
|
+
##### Command
|
58
|
+
|
59
|
+
```sh
|
60
|
+
ruby include.rb
|
61
|
+
```
|
62
|
+
|
63
|
+
#### File with Inclusion
|
64
|
+
|
65
|
+
Here's the finished file with the inclusion and nested inclusion:
|
66
|
+
|
67
|
+
```included.md```:
|
68
|
+
```markdown
|
69
|
+
File to do nested inclusion.
|
70
|
+
|
71
|
+
Text for inclusion, and a nested inclusion.
|
72
|
+
|
73
|
+
Text for nested inclusion.
|
74
|
+
```
|
@@ -0,0 +1,23 @@
|
|
1
|
+
### Nest Inclusions
|
2
|
+
|
3
|
+
An included markdown file can itself include more files.
|
4
|
+
|
5
|
+
#### File To Be Included
|
6
|
+
|
7
|
+
@[markdown](includee.md)
|
8
|
+
|
9
|
+
#### File For Nested Inclusion
|
10
|
+
|
11
|
+
@[markdown](nested_includee.md)
|
12
|
+
|
13
|
+
#### Includer File
|
14
|
+
|
15
|
+
@[markdown](includer.md)
|
16
|
+
|
17
|
+
@[:markdown](../interface.md)
|
18
|
+
|
19
|
+
#### File with Inclusion
|
20
|
+
|
21
|
+
Here's the finished file with the inclusion and nested inclusion:
|
22
|
+
|
23
|
+
@[markdown](included.md)
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
1
|
+
Text in includer file.
|
2
2
|
|
3
|
-
|
3
|
+
Text in includee file.
|
4
4
|
|
5
|
-
Then includes it again.
|
6
|
-
|
7
|
-
This is some reusable text that can be included in more than one place (actually, in more than one file).
|
@@ -0,0 +1 @@
|
|
1
|
+
Text in includee file.
|
@@ -1,100 +1,47 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
use_case_dir_path = File.absolute_path(File.dirname(__FILE__))
|
4
|
-
|
5
|
-
reusable_text_file_name = 'reusable_text.md'
|
6
|
-
reusable_text_file_path = File.join(
|
7
|
-
use_case_dir_path,
|
8
|
-
reusable_text_file_name,
|
9
|
-
)
|
10
|
-
|
11
|
-
includer_file_name = 'includer.md'
|
12
|
-
includer_file_path = File.join(
|
13
|
-
use_case_dir_path,
|
14
|
-
includer_file_name,
|
15
|
-
)
|
16
|
-
|
17
|
-
included_file_name = 'included.md'
|
18
|
-
|
19
|
-
use_case_file_name = 'reuse_text.md'
|
20
|
-
use_case_file_path = File.join(
|
21
|
-
use_case_dir_path,
|
22
|
-
use_case_file_name,
|
23
|
-
)
|
24
|
-
|
25
|
-
template_file_name = 'template.md'
|
26
|
-
template_file_path = File.join(
|
27
|
-
use_case_dir_path,
|
28
|
-
template_file_name,
|
29
|
-
)
|
30
|
-
|
31
|
-
include_command = "markdown_helper include --pristine #{includer_file_name} #{included_file_name}"
|
32
|
-
|
33
|
-
File.write(
|
34
|
-
reusable_text_file_path,
|
35
|
-
<<EOT
|
36
|
-
This is some reusable text that can be included in more than one place (actually, in more than one file).
|
37
|
-
EOT
|
38
|
-
)
|
39
|
-
|
40
|
-
|
41
|
-
File.write(
|
42
|
-
includer_file_path,
|
43
|
-
<<EOT
|
44
|
-
This file includes the useful text.
|
1
|
+
require_relative '../include_use_case'
|
45
2
|
|
46
|
-
|
3
|
+
class ReuseText < IncludeUseCase
|
47
4
|
|
48
|
-
|
5
|
+
def self.build
|
49
6
|
|
50
|
-
|
51
|
-
|
52
|
-
)
|
7
|
+
use_case_name = File.basename(__FILE__, '.rb')
|
8
|
+
use_case = self.new(use_case_name)
|
53
9
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
end
|
10
|
+
use_case.write_includee_file
|
11
|
+
use_case.write_includer_file
|
12
|
+
use_case.write_ruby_file(pristine = true)
|
58
13
|
|
59
|
-
File.write(
|
60
|
-
|
61
|
-
|
14
|
+
File.write(
|
15
|
+
TEMPLATE_FILE_NAME,
|
16
|
+
<<EOT
|
62
17
|
### Reuse Text
|
63
18
|
|
64
19
|
Use file inclusion to stay DRY (Don't Repeat Yourself).
|
65
20
|
|
66
21
|
Maintain reusable text in a separate file, then include it wherever it's needed.
|
67
22
|
|
68
|
-
#### File
|
69
|
-
|
70
|
-
Here's a file containing some text that can be included:
|
23
|
+
#### File To Be Included
|
71
24
|
|
72
|
-
@[markdown](#{
|
25
|
+
@[markdown](#{INCLUDEE_FILE_NAME})
|
73
26
|
|
74
27
|
#### Includer File
|
75
28
|
|
76
|
-
|
29
|
+
@[markdown](#{INCLUDER_FILE_NAME})
|
77
30
|
|
78
|
-
|
31
|
+
The treatment token ```:markdown``` specifies that the included text is to be treated as more markdown.
|
79
32
|
|
80
|
-
|
81
|
-
|
82
|
-
Here's the command to perform the inclusion:
|
83
|
-
|
84
|
-
```sh
|
85
|
-
#{include_command}
|
86
|
-
```
|
87
|
-
|
88
|
-
@[:markdown](../../pristine.md)
|
33
|
+
@[:markdown](../interface.md)
|
89
34
|
|
90
35
|
#### File with Inclusion
|
91
36
|
|
92
|
-
Here's the
|
37
|
+
Here's the output file, after inclusion.
|
93
38
|
|
94
|
-
@[markdown](#{
|
39
|
+
@[markdown](#{INCLUDED_FILE_NAME})
|
95
40
|
EOT
|
96
|
-
)
|
41
|
+
)
|
97
42
|
|
98
|
-
|
99
|
-
|
100
|
-
|
43
|
+
use_case.build
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
### Reuse Text
|
2
|
+
|
3
|
+
Use file inclusion to stay DRY (Don't Repeat Yourself).
|
4
|
+
|
5
|
+
Maintain reusable text in a separate file, then include it wherever it's needed.
|
6
|
+
|
7
|
+
#### File To Be Included
|
8
|
+
|
9
|
+
```includee.md```:
|
10
|
+
```markdown
|
11
|
+
Text in includee file.
|
12
|
+
```
|
13
|
+
|
14
|
+
#### Includer File
|
15
|
+
|
16
|
+
```includer.md```:
|
17
|
+
```markdown
|
18
|
+
Text in includer file.
|
19
|
+
|
20
|
+
@[:markdown](includee.md)
|
21
|
+
|
22
|
+
```
|
23
|
+
|
24
|
+
The treatment token ```:markdown``` specifies that the included text is to be treated as more markdown.
|
25
|
+
|
26
|
+
#### CLI
|
27
|
+
|
28
|
+
You can use the command-line interface to perform the inclusion.
|
29
|
+
|
30
|
+
##### Command
|
31
|
+
|
32
|
+
```sh
|
33
|
+
markdown_helper include --pristine includer.md included.md
|
34
|
+
```
|
35
|
+
|
36
|
+
(Option ```--pristine``` suppresses comment insertion.)
|
37
|
+
|
38
|
+
#### API
|
39
|
+
|
40
|
+
You can use the API to perform the inclusion.
|
41
|
+
|
42
|
+
##### Ruby Code
|
43
|
+
|
44
|
+
```include.rb```:
|
45
|
+
```ruby
|
46
|
+
require 'markdown_helper'
|
47
|
+
|
48
|
+
# Option :pristine suppresses comment insertion.
|
49
|
+
markdown_helper = MarkdownHelper.new(:pristine => true)
|
50
|
+
markdown_helper.include('includer.md', 'included.md')
|
51
|
+
```
|
52
|
+
|
53
|
+
##### Command
|
54
|
+
|
55
|
+
```sh
|
56
|
+
ruby include.rb
|
57
|
+
```
|
58
|
+
|
59
|
+
#### File with Inclusion
|
60
|
+
|
61
|
+
Here's the output file, after inclusion.
|
62
|
+
|
63
|
+
```included.md```:
|
64
|
+
```markdown
|
65
|
+
Text in includer file.
|
66
|
+
|
67
|
+
Text in includee file.
|
68
|
+
|
69
|
+
```
|