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
@@ -0,0 +1,33 @@
|
|
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
|
+
@[markdown](hello.rb)
|
10
|
+
|
11
|
+
#### Includer File
|
12
|
+
|
13
|
+
Here's a template file that includes it:
|
14
|
+
|
15
|
+
@[markdown](includer.md)
|
16
|
+
|
17
|
+
The treatment token ```:code_block``` specifies that the included text is to be treated as a code block.
|
18
|
+
|
19
|
+
@[:markdown](../interface.md)
|
20
|
+
|
21
|
+
#### File with Inclusion
|
22
|
+
|
23
|
+
Here's the finished file with the included code block:
|
24
|
+
|
25
|
+
@[:pre](included.md)
|
26
|
+
|
27
|
+
And here's the finished markdown, as rendered on this page:
|
28
|
+
|
29
|
+
---
|
30
|
+
|
31
|
+
@[:markdown](included.md)
|
32
|
+
|
33
|
+
---
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require_relative '../include_use_case'
|
2
|
+
|
3
|
+
class IncludeGeneratedText < 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.files_to_write.store(
|
11
|
+
TEMPLATE_FILE_NAME,
|
12
|
+
<<EOT
|
13
|
+
### Include Generated Text
|
14
|
+
|
15
|
+
#### Generate Includable Text
|
16
|
+
|
17
|
+
A handy use of file inclusion is seen in including generated text.
|
18
|
+
|
19
|
+
That is, the markdown "build" generates files that are then included in the finished markdown document.
|
20
|
+
|
21
|
+
The use cases documented here take advantage of that. Each use case has an executable Ruby file that has [Here Documents](https://ruby-doc.org/core-2.2.0/doc/syntax/literals_rdoc.html#label-Here+Documents) containing all the relevant text. The build emits the files that are them used to illustrate the use case.
|
22
|
+
|
23
|
+
#### Keeping Example Code "Green"
|
24
|
+
|
25
|
+
An especially handy use of file inclusion is seen in including example code and output.
|
26
|
+
|
27
|
+
1. Example code in its own file is executed, and its output captured into another file.
|
28
|
+
2. Then both are included in markdown that uses the example.
|
29
|
+
|
30
|
+
Running the example each time the markdown is built keeps the example code "green," because it confirms that the code still works.
|
31
|
+
EOT
|
32
|
+
)
|
33
|
+
|
34
|
+
use_case.build
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
### Include Generated Text
|
2
|
+
|
3
|
+
#### Generate Includable Text
|
4
|
+
|
5
|
+
A handy use of file inclusion is seen in including generated text.
|
6
|
+
|
7
|
+
That is, the markdown "build" generates files that are then included in the finished markdown document.
|
8
|
+
|
9
|
+
The use cases documented here take advantage of that. Each use case has an executable Ruby file that has [Here Documents](https://ruby-doc.org/core-2.2.0/doc/syntax/literals_rdoc.html#label-Here+Documents) containing all the relevant text. The build emits the files that are them used to illustrate the use case.
|
10
|
+
|
11
|
+
#### Keeping Example Code "Green"
|
12
|
+
|
13
|
+
An especially handy use of file inclusion is seen in including example code and output.
|
14
|
+
|
15
|
+
1. Example code in its own file is executed, and its output captured into another file.
|
16
|
+
2. Then both are included in markdown that uses the example.
|
17
|
+
|
18
|
+
Running the example each time the markdown is built keeps the example code "green," because it confirms that the code still works.
|
@@ -0,0 +1,18 @@
|
|
1
|
+
### Include Generated Text
|
2
|
+
|
3
|
+
#### Generate Includable Text
|
4
|
+
|
5
|
+
A handy use of file inclusion is seen in including generated text.
|
6
|
+
|
7
|
+
That is, the markdown "build" generates files that are then included in the finished markdown document.
|
8
|
+
|
9
|
+
The use cases documented here take advantage of that. Each use case has an executable Ruby file that has [Here Documents](https://ruby-doc.org/core-2.2.0/doc/syntax/literals_rdoc.html#label-Here+Documents) containing all the relevant text. The build emits the files that are them used to illustrate the use case.
|
10
|
+
|
11
|
+
#### Keeping Example Code "Green"
|
12
|
+
|
13
|
+
An especially handy use of file inclusion is seen in including example code and output.
|
14
|
+
|
15
|
+
1. Example code in its own file is executed, and its output captured into another file.
|
16
|
+
2. Then both are included in markdown that uses the example.
|
17
|
+
|
18
|
+
Running the example each time the markdown is built keeps the example code "green," because it confirms that the code still works.
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require_relative '../include_use_case'
|
2
|
+
|
3
|
+
class IncludeHighlightedCode < 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_includer_file
|
11
|
+
|
12
|
+
includee_file_name = 'hello.rb'
|
13
|
+
|
14
|
+
use_case.files_to_write.store(
|
15
|
+
includee_file_name,
|
16
|
+
<<EOT
|
17
|
+
class HelloWorld
|
18
|
+
def initialize(name)
|
19
|
+
@name = name.capitalize
|
20
|
+
end
|
21
|
+
def sayHi
|
22
|
+
puts "Hello #{@name}!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
EOT
|
26
|
+
)
|
27
|
+
|
28
|
+
use_case.files_to_write.store(
|
29
|
+
INCLUDER_FILE_NAME,
|
30
|
+
<<EOT
|
31
|
+
This file includes the code as highlighted code.
|
32
|
+
|
33
|
+
@[ruby](#{includee_file_name})
|
34
|
+
|
35
|
+
EOT
|
36
|
+
)
|
37
|
+
|
38
|
+
use_case.files_to_write.store(
|
39
|
+
TEMPLATE_FILE_NAME,
|
40
|
+
<<EOT
|
41
|
+
### Include Highlighted Code
|
42
|
+
|
43
|
+
Use file inclusion to include text as highlighted code.
|
44
|
+
|
45
|
+
#### File to Be Included
|
46
|
+
|
47
|
+
Here's a file containing Ruby code to be included:
|
48
|
+
|
49
|
+
@[markdown](#{includee_file_name})
|
50
|
+
|
51
|
+
#### Includer File
|
52
|
+
|
53
|
+
Here's a template file that includes it:
|
54
|
+
|
55
|
+
@[markdown](#{INCLUDER_FILE_NAME})
|
56
|
+
|
57
|
+
The treatment token ```ruby``` specifies that the included text is to be highlighted as Ruby code.
|
58
|
+
|
59
|
+
The treatment token can be any Ace mode mentioned in [GitHub Languages](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). The file lists about 100 Ace modes, covering just about every language and format.
|
60
|
+
|
61
|
+
@[:markdown](../interface.md)
|
62
|
+
|
63
|
+
#### File with Inclusion
|
64
|
+
|
65
|
+
Here's the finished file with the included highlighted code:
|
66
|
+
|
67
|
+
@[:pre](#{INCLUDED_FILE_NAME})
|
68
|
+
|
69
|
+
And here's the finished markdown, as rendered on this page:
|
70
|
+
|
71
|
+
---
|
72
|
+
|
73
|
+
@[:markdown](#{INCLUDED_FILE_NAME})
|
74
|
+
|
75
|
+
---
|
76
|
+
EOT
|
77
|
+
)
|
78
|
+
|
79
|
+
use_case.build
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
### Include Highlighted Code
|
2
|
+
|
3
|
+
Use file inclusion to include text as highlighted code.
|
4
|
+
|
5
|
+
#### File to Be Included
|
6
|
+
|
7
|
+
Here's a file containing Ruby 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 highlighted code.
|
28
|
+
|
29
|
+
@[ruby](hello.rb)
|
30
|
+
|
31
|
+
```
|
32
|
+
|
33
|
+
The treatment token ```ruby``` specifies that the included text is to be highlighted as Ruby code.
|
34
|
+
|
35
|
+
The treatment token can be any Ace mode mentioned in [GitHub Languages](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). The file lists about 100 Ace modes, covering just about every language and format.
|
36
|
+
|
37
|
+
#### CLI
|
38
|
+
|
39
|
+
You can use the command-line interface to perform the inclusion.
|
40
|
+
|
41
|
+
##### Command
|
42
|
+
|
43
|
+
```sh
|
44
|
+
markdown_helper include --pristine includer.md included.md
|
45
|
+
```
|
46
|
+
|
47
|
+
(Option ```--pristine``` suppresses comment insertion.)
|
48
|
+
|
49
|
+
#### API
|
50
|
+
|
51
|
+
You can use the API to perform the inclusion.
|
52
|
+
|
53
|
+
##### Ruby Code
|
54
|
+
|
55
|
+
```include.rb```:
|
56
|
+
```ruby
|
57
|
+
require 'markdown_helper'
|
58
|
+
|
59
|
+
# Option :pristine suppresses comment insertion.
|
60
|
+
markdown_helper = MarkdownHelper.new(:pristine => true)
|
61
|
+
markdown_helper.include('includer.md', 'included.md')
|
62
|
+
```
|
63
|
+
|
64
|
+
##### Command
|
65
|
+
|
66
|
+
```sh
|
67
|
+
ruby include.rb
|
68
|
+
```
|
69
|
+
|
70
|
+
#### File with Inclusion
|
71
|
+
|
72
|
+
Here's the finished file with the included highlighted code:
|
73
|
+
|
74
|
+
<pre>
|
75
|
+
This file includes the code as highlighted code.
|
76
|
+
|
77
|
+
```hello.rb```:
|
78
|
+
```ruby
|
79
|
+
class HelloWorld
|
80
|
+
def initialize(name)
|
81
|
+
@name = name.capitalize
|
82
|
+
end
|
83
|
+
def sayHi
|
84
|
+
puts "Hello !"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
```
|
88
|
+
|
89
|
+
</pre>
|
90
|
+
|
91
|
+
And here's the finished markdown, as rendered on this page:
|
92
|
+
|
93
|
+
---
|
94
|
+
|
95
|
+
This file includes the code as highlighted code.
|
96
|
+
|
97
|
+
```hello.rb```:
|
98
|
+
```ruby
|
99
|
+
class HelloWorld
|
100
|
+
def initialize(name)
|
101
|
+
@name = name.capitalize
|
102
|
+
end
|
103
|
+
def sayHi
|
104
|
+
puts "Hello !"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
```
|
108
|
+
|
109
|
+
|
110
|
+
---
|
@@ -0,0 +1,35 @@
|
|
1
|
+
### Include Highlighted Code
|
2
|
+
|
3
|
+
Use file inclusion to include text as highlighted code.
|
4
|
+
|
5
|
+
#### File to Be Included
|
6
|
+
|
7
|
+
Here's a file containing Ruby code to be included:
|
8
|
+
|
9
|
+
@[markdown](hello.rb)
|
10
|
+
|
11
|
+
#### Includer File
|
12
|
+
|
13
|
+
Here's a template file that includes it:
|
14
|
+
|
15
|
+
@[markdown](includer.md)
|
16
|
+
|
17
|
+
The treatment token ```ruby``` specifies that the included text is to be highlighted as Ruby code.
|
18
|
+
|
19
|
+
The treatment token can be any Ace mode mentioned in [GitHub Languages](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml). The file lists about 100 Ace modes, covering just about every language and format.
|
20
|
+
|
21
|
+
@[:markdown](../interface.md)
|
22
|
+
|
23
|
+
#### File with Inclusion
|
24
|
+
|
25
|
+
Here's the finished file with the included highlighted code:
|
26
|
+
|
27
|
+
@[:pre](included.md)
|
28
|
+
|
29
|
+
And here's the finished markdown, as rendered on this page:
|
30
|
+
|
31
|
+
---
|
32
|
+
|
33
|
+
@[:markdown](included.md)
|
34
|
+
|
35
|
+
---
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require_relative '../include_use_case'
|
2
|
+
|
3
|
+
class IncludeMarkdown < 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 = 'markdown.md'
|
11
|
+
|
12
|
+
use_case.files_to_write.store(
|
13
|
+
includee_file_name,
|
14
|
+
<<EOT
|
15
|
+
This fiie, to be included, is markdown.
|
16
|
+
|
17
|
+
### This is a level-three title.
|
18
|
+
|
19
|
+
Here's a [link](http://yahoo.com).
|
20
|
+
|
21
|
+
This is an unordered list:
|
22
|
+
* One.
|
23
|
+
* Two.
|
24
|
+
* Three.
|
25
|
+
EOT
|
26
|
+
)
|
27
|
+
|
28
|
+
use_case.files_to_write.store(
|
29
|
+
INCLUDER_FILE_NAME,
|
30
|
+
<<EOT
|
31
|
+
This file includes the markdown file.
|
32
|
+
|
33
|
+
@[:markdown](#{includee_file_name})
|
34
|
+
|
35
|
+
EOT
|
36
|
+
)
|
37
|
+
|
38
|
+
use_case.files_to_write.store(
|
39
|
+
TEMPLATE_FILE_NAME,
|
40
|
+
<<EOT
|
41
|
+
### Include Markdown
|
42
|
+
|
43
|
+
Use file inclusion to include markdown. The whole page, includer and includee, will be rendered when it's pushed to GitHub.
|
44
|
+
|
45
|
+
#### File to Be Included
|
46
|
+
|
47
|
+
Here's a file containing markdown to be included:
|
48
|
+
|
49
|
+
@[markdown](#{includee_file_name})
|
50
|
+
|
51
|
+
#### Includer File
|
52
|
+
|
53
|
+
Here's a template file that includes it:
|
54
|
+
|
55
|
+
@[markdown](#{INCLUDER_FILE_NAME})
|
56
|
+
|
57
|
+
The treatment token ```:markdown``` specifies that the included text is to be treated as markdown.
|
58
|
+
|
59
|
+
@[:markdown](../interface.md)
|
60
|
+
|
61
|
+
#### File with Inclusion
|
62
|
+
|
63
|
+
Here's the finished file with the inclusion:
|
64
|
+
|
65
|
+
@[markdown](#{INCLUDED_FILE_NAME})
|
66
|
+
|
67
|
+
And here's the finished markdown, as rendered on this page:
|
68
|
+
|
69
|
+
---
|
70
|
+
|
71
|
+
@[:markdown](#{includee_file_name})
|
72
|
+
|
73
|
+
---
|
74
|
+
EOT
|
75
|
+
)
|
76
|
+
|
77
|
+
use_case.build
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|