markdown_helper 1.6.1 → 1.7.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/.gitignore +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +6 -6
- data/lib/markdown_helper.rb +28 -9
- data/lib/markdown_helper/version.rb +1 -1
- data/markdown/README.template.md +3 -3
- data/markdown/use_cases/{rubygem_images.md → gemify_images/template.md} +0 -0
- data/markdown/use_cases/{image_attributes.md → resize_images/template.md} +0 -0
- data/markdown/use_cases/reuse_text/included.md +7 -0
- data/markdown/use_cases/{reusable_text → reuse_text}/includer.md +0 -0
- data/markdown/use_cases/{reusable_text → reuse_text}/reusable_text.md +0 -0
- data/markdown/use_cases/{reusable_text/use_case.md → reuse_text/reuse_text.md} +10 -6
- data/markdown/use_cases/{reusable_text/build.rb → reuse_text/reuse_text.rb} +34 -32
- data/markdown/use_cases/{reusable_text → reuse_text}/template.md +6 -6
- data/markdown/use_cases/{evergreen_examples.md → verify_examples/template.md} +0 -0
- metadata +11 -12
- data/markdown/use_cases/generated_text.md +0 -5
- data/markdown/use_cases/reusable_text/included.md +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 271b429b2a0016330e36fb2afd2c59c141ffb875
|
4
|
+
data.tar.gz: cc509ab4b86e4eeb18a60b5ec435bdf6f840fad1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdfda83d3fecc8f4f80b0762b28878fa0ef3d4374df8bb10abeb1c7df638b42a97d180bda2388517091220a09bd55c5cd3c2a39da3f73e3d98ced011d4a9ca29
|
7
|
+
data.tar.gz: c9acebb1a64ca5f539da782cc451f70e96ef908567770a660e3e60c940714608fa5ae9723861f0fd16b327f444388602ec6f92c8e6ae35304e0042325c2b82d0
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -41,10 +41,10 @@ You can suppress those comments using the <code>pristine</code> option.
|
|
41
41
|
|
42
42
|
## File Inclusion
|
43
43
|
|
44
|
-
<!-- >>>>>> BEGIN RESOLVED IMAGES: INPUT-LINE '
|
44
|
+
<!-- >>>>>> BEGIN RESOLVED IMAGES: INPUT-LINE '
|
45
45
|
' -->
|
46
46
|
<img src="https://raw.githubusercontent.com/BurdetteLamar/markdown_helper/master/images/include.png" alt="include_icon" width="50">
|
47
|
-
<!-- <<<<<< END RESOLVED IMAGES: INPUT-LINE '
|
47
|
+
<!-- <<<<<< END RESOLVED IMAGES: INPUT-LINE '
|
48
48
|
' -->
|
49
49
|
|
50
50
|
This markdown helper enables file inclusion in GitHub markdown.
|
@@ -166,10 +166,10 @@ where:
|
|
166
166
|
|
167
167
|
## Image Path Resolution
|
168
168
|
|
169
|
-
<!-- >>>>>> BEGIN RESOLVED IMAGES: INPUT-LINE '
|
169
|
+
<!-- >>>>>> BEGIN RESOLVED IMAGES: INPUT-LINE '
|
170
170
|
' -->
|
171
171
|
<img src="https://raw.githubusercontent.com/BurdetteLamar/markdown_helper/master/images/image.png" alt="image_icon" width="50">
|
172
|
-
<!-- <<<<<< END RESOLVED IMAGES: INPUT-LINE '
|
172
|
+
<!-- <<<<<< END RESOLVED IMAGES: INPUT-LINE '
|
173
173
|
' -->
|
174
174
|
|
175
175
|
This markdown helper enables image path resolution in GitHub markdown.
|
@@ -251,10 +251,10 @@ where:
|
|
251
251
|
|
252
252
|
## Image Attributes
|
253
253
|
|
254
|
-
<!-- >>>>>> BEGIN RESOLVED IMAGES: INPUT-LINE '
|
254
|
+
<!-- >>>>>> BEGIN RESOLVED IMAGES: INPUT-LINE '
|
255
255
|
' -->
|
256
256
|
<img src="https://raw.githubusercontent.com/BurdetteLamar/markdown_helper/master/images/html.png" alt="html_icon" width="50">
|
257
|
-
<!-- <<<<<< END RESOLVED IMAGES: INPUT-LINE '
|
257
|
+
<!-- <<<<<< END RESOLVED IMAGES: INPUT-LINE '
|
258
258
|
' -->
|
259
259
|
|
260
260
|
This markdown helper enables HTML image attributes in GitHub markdown [image descriptions](https://github.github.com/gfm/#image-description).
|
data/lib/markdown_helper.rb
CHANGED
@@ -63,14 +63,14 @@ class MarkdownHelper
|
|
63
63
|
#
|
64
64
|
# The path resolves to:
|
65
65
|
#
|
66
|
-
#
|
66
|
+
# image_path = File.join(
|
67
67
|
# "https://raw.githubusercontent.com/#{repo_user}/#{repo_name}/master",
|
68
68
|
# relative_file_path,
|
69
69
|
# )
|
70
70
|
def resolve(template_file_path, markdown_file_path)
|
71
71
|
# Method :generate_file does the first things, yields the block, does the last things.
|
72
72
|
send(:generate_file, template_file_path, markdown_file_path, __method__) do |input_lines, output_lines|
|
73
|
-
send(:resolve_images, input_lines, output_lines)
|
73
|
+
send(:resolve_images, template_file_path, input_lines, output_lines)
|
74
74
|
end
|
75
75
|
end
|
76
76
|
alias resolve_image_urls resolve
|
@@ -175,7 +175,7 @@ class MarkdownHelper
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
def resolve_images(input_lines, output_lines)
|
178
|
+
def resolve_images(template_file_path, input_lines, output_lines)
|
179
179
|
input_lines.each do |input_line|
|
180
180
|
scan_data = input_line.scan(IMAGE_REGEXP)
|
181
181
|
if scan_data.empty?
|
@@ -185,7 +185,9 @@ class MarkdownHelper
|
|
185
185
|
output_lines.push(comment(" >>>>>> BEGIN RESOLVED IMAGES: INPUT-LINE '#{input_line}' ")) unless pristine
|
186
186
|
output_line = input_line
|
187
187
|
scan_data.each do |alt_text, path_and_attributes|
|
188
|
-
|
188
|
+
original_image_file_path, attributes_s = path_and_attributes.split(/\s?\|\s?/, 2)
|
189
|
+
|
190
|
+
# Attributes.
|
189
191
|
attributes = attributes_s ? attributes_s.split(/\s+/) : []
|
190
192
|
formatted_attributes = ['']
|
191
193
|
attributes.each do |attribute|
|
@@ -193,18 +195,35 @@ class MarkdownHelper
|
|
193
195
|
formatted_attributes.push(format('%s="%s"', name, value))
|
194
196
|
end
|
195
197
|
formatted_attributes_s = formatted_attributes.join(' ')
|
196
|
-
|
197
|
-
if
|
198
|
-
|
198
|
+
|
199
|
+
if original_image_file_path.start_with?('http')
|
200
|
+
image_path = original_image_file_path
|
199
201
|
else
|
202
|
+
git_dir = `git rev-parse --git-dir`.chomp
|
203
|
+
if git_dir == '.git'
|
204
|
+
git_clone_dir_path = `pwd`.chomp
|
205
|
+
else
|
206
|
+
git_clone_dir_path = git_dir.chomp
|
207
|
+
end
|
208
|
+
git_clone_dir_pathname = Pathname.new(git_clone_dir_path.sub(%r|/c/|, 'C:/')).realpath
|
209
|
+
git_clone_dir_path = git_clone_dir_pathname.to_s
|
210
|
+
absolute_template_file_path = File.absolute_path(template_file_path)
|
211
|
+
template_dir_path = File.dirname(absolute_template_file_path)
|
200
212
|
absolute_file_path = File.join(
|
213
|
+
template_dir_path,
|
214
|
+
original_image_file_path,
|
215
|
+
)
|
216
|
+
absolute_file_path = Pathname.new(absolute_file_path).cleanpath.to_s
|
217
|
+
relative_image_file_path = absolute_file_path.sub(git_clone_dir_path + '/', '')
|
218
|
+
repo_user, repo_name = repo_user_and_name
|
219
|
+
image_path = File.join(
|
201
220
|
"https://raw.githubusercontent.com/#{repo_user}/#{repo_name}/master",
|
202
|
-
|
221
|
+
relative_image_file_path,
|
203
222
|
)
|
204
223
|
end
|
205
224
|
img_element = format(
|
206
225
|
'<img src="%s" alt="%s"%s>',
|
207
|
-
|
226
|
+
image_path,
|
208
227
|
alt_text,
|
209
228
|
formatted_attributes_s,
|
210
229
|
)
|
data/markdown/README.template.md
CHANGED
@@ -35,7 +35,7 @@ You can suppress those comments using the <code>pristine</code> option.
|
|
35
35
|
|
36
36
|
## File Inclusion
|
37
37
|
|
38
|
-

|
38
|
+

|
39
39
|
|
40
40
|
This markdown helper enables file inclusion in GitHub markdown.
|
41
41
|
|
@@ -95,7 +95,7 @@ where:
|
|
95
95
|
|
96
96
|
## Image Path Resolution
|
97
97
|
|
98
|
-

|
98
|
+

|
99
99
|
|
100
100
|
This markdown helper enables image path resolution in GitHub markdown.
|
101
101
|
|
@@ -133,7 +133,7 @@ where:
|
|
133
133
|
|
134
134
|
## Image Attributes
|
135
135
|
|
136
|
-

|
136
|
+

|
137
137
|
|
138
138
|
This markdown helper enables HTML image attributes in GitHub markdown [image descriptions](https://github.github.com/gfm/#image-description).
|
139
139
|
|
File without changes
|
File without changes
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<!-- >>>>>> BEGIN GENERATED FILE (include): SOURCE includer.md -->
|
2
|
+
This file includes the useful text.
|
3
|
+
|
4
|
+
<!-- >>>>>> BEGIN INCLUDED FILE (verbatim): SOURCE ./reusable_text.md -->
|
5
|
+
This is some useful text that can be included in more than one place (actually, in more than one file).
|
6
|
+
<!-- <<<<<< END INCLUDED FILE (verbatim): SOURCE ./reusable_text.md -->
|
7
|
+
<!-- <<<<<< END GENERATED FILE (include): SOURCE includer.md -->
|
File without changes
|
File without changes
|
@@ -1,19 +1,19 @@
|
|
1
|
-
###
|
1
|
+
### Use Case: Reuse Text
|
2
2
|
|
3
3
|
Use file inclusion to stay DRY (Don't Repeat Yourself).
|
4
4
|
|
5
5
|
Maintain reusable text in a separate file, then include it wherever it's needed.
|
6
6
|
|
7
|
-
####
|
7
|
+
#### File to Be Included
|
8
8
|
|
9
|
-
Here's a file containing some text that can be included
|
9
|
+
Here's a file containing some text that can be included:
|
10
10
|
|
11
11
|
<code>reusable_text.md</code>
|
12
12
|
```
|
13
13
|
This is some useful text that can be included in more than one place (actually, in more than one file).
|
14
14
|
```
|
15
15
|
|
16
|
-
####
|
16
|
+
#### Includer File
|
17
17
|
|
18
18
|
Here's a template file that includes it:
|
19
19
|
|
@@ -29,16 +29,20 @@ This file includes the useful text.
|
|
29
29
|
Here's the command to perform the inclusion (```--pristine``` suppresses inclusion comments):
|
30
30
|
|
31
31
|
```sh
|
32
|
-
|
32
|
+
markdown_helper include includer.md included.md
|
33
33
|
```
|
34
34
|
|
35
|
-
####
|
35
|
+
#### File with Inclusion
|
36
36
|
|
37
37
|
Here's the finished file with the inclusion:
|
38
38
|
|
39
39
|
<code>included.md</code>
|
40
40
|
```
|
41
|
+
<!-- >>>>>> BEGIN GENERATED FILE (include): SOURCE includer.md -->
|
41
42
|
This file includes the useful text.
|
42
43
|
|
44
|
+
<!-- >>>>>> BEGIN INCLUDED FILE (verbatim): SOURCE ./reusable_text.md -->
|
43
45
|
This is some useful text that can be included in more than one place (actually, in more than one file).
|
46
|
+
<!-- <<<<<< END INCLUDED FILE (verbatim): SOURCE ./reusable_text.md -->
|
47
|
+
<!-- <<<<<< END GENERATED FILE (include): SOURCE includer.md -->
|
44
48
|
```
|
@@ -1,26 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
1
3
|
reusable_text_file_name = 'reusable_text.md'
|
2
4
|
includer_file_name = 'includer.md'
|
3
5
|
included_file_name = 'included.md'
|
6
|
+
use_case_file_name = 'reuse_text.md'
|
4
7
|
template_file_name = 'template.md'
|
5
|
-
use_case_file_name = 'use_case.md'
|
6
8
|
|
7
|
-
include_command = "
|
8
|
-
|
9
|
+
include_command = "markdown_helper include #{includer_file_name} #{included_file_name}"
|
10
|
+
|
11
|
+
File.write(
|
12
|
+
reusable_text_file_name,
|
13
|
+
<<EOT
|
14
|
+
This is some useful text that can be included in more than one place (actually, in more than one file).
|
15
|
+
EOT
|
16
|
+
)
|
17
|
+
|
18
|
+
File.write(
|
19
|
+
includer_file_name,
|
20
|
+
<<EOT
|
21
|
+
This file includes the useful text.
|
22
|
+
|
23
|
+
@[:verbatim](#{reusable_text_file_name})
|
24
|
+
EOT
|
25
|
+
)
|
26
|
+
|
27
|
+
# Example inclusion.
|
28
|
+
system(include_command)
|
9
29
|
|
10
|
-
|
11
|
-
|
30
|
+
File.write(
|
31
|
+
template_file_name,
|
32
|
+
<<EOT
|
33
|
+
### Use Case: Reuse Text
|
12
34
|
|
13
35
|
Use file inclusion to stay DRY (Don't Repeat Yourself).
|
14
36
|
|
15
37
|
Maintain reusable text in a separate file, then include it wherever it's needed.
|
16
38
|
|
17
|
-
####
|
39
|
+
#### File to Be Included
|
18
40
|
|
19
|
-
Here's a file containing some text that can be included
|
41
|
+
Here's a file containing some text that can be included:
|
20
42
|
|
21
43
|
@[:code_block](#{reusable_text_file_name})
|
22
44
|
|
23
|
-
####
|
45
|
+
#### Includer File
|
24
46
|
|
25
47
|
Here's a template file that includes it:
|
26
48
|
|
@@ -34,34 +56,14 @@ Here's the command to perform the inclusion (```--pristine``` suppresses inclusi
|
|
34
56
|
#{include_command}
|
35
57
|
```
|
36
58
|
|
37
|
-
####
|
59
|
+
#### File with Inclusion
|
38
60
|
|
39
61
|
Here's the finished file with the inclusion:
|
40
62
|
|
41
63
|
@[:code_block](#{included_file_name})
|
42
64
|
EOT
|
65
|
+
)
|
43
66
|
|
44
|
-
|
45
|
-
|
46
|
-
EOT
|
47
|
-
|
48
|
-
includer = <<EOT
|
49
|
-
This file includes the useful text.
|
50
|
-
|
51
|
-
@[:verbatim](#{reusable_text_file_name})
|
52
|
-
EOT
|
53
|
-
|
54
|
-
# Write markdown files.
|
55
|
-
{
|
56
|
-
template_file_name => template,
|
57
|
-
reusable_text_file_name => reusable_text,
|
58
|
-
includer_file_name => includer,
|
59
|
-
}.each_pair do |file_name, text|
|
60
|
-
File.write(file_name, text)
|
61
|
-
end
|
62
|
-
|
63
|
-
# Perform the inclusion.
|
64
|
-
system(include_command)
|
65
|
-
|
66
|
-
# Build the use case.
|
67
|
+
# Build use case.
|
68
|
+
build_command = "markdown_helper include --pristine #{template_file_name} #{use_case_file_name}"
|
67
69
|
system(build_command)
|
@@ -1,16 +1,16 @@
|
|
1
|
-
###
|
1
|
+
### Use Case: Reuse Text
|
2
2
|
|
3
3
|
Use file inclusion to stay DRY (Don't Repeat Yourself).
|
4
4
|
|
5
5
|
Maintain reusable text in a separate file, then include it wherever it's needed.
|
6
6
|
|
7
|
-
####
|
7
|
+
#### File to Be Included
|
8
8
|
|
9
|
-
Here's a file containing some text that can be included
|
9
|
+
Here's a file containing some text that can be included:
|
10
10
|
|
11
11
|
@[:code_block](reusable_text.md)
|
12
12
|
|
13
|
-
####
|
13
|
+
#### Includer File
|
14
14
|
|
15
15
|
Here's a template file that includes it:
|
16
16
|
|
@@ -21,10 +21,10 @@ Here's a template file that includes it:
|
|
21
21
|
Here's the command to perform the inclusion (```--pristine``` suppresses inclusion comments):
|
22
22
|
|
23
23
|
```sh
|
24
|
-
|
24
|
+
markdown_helper include includer.md included.md
|
25
25
|
```
|
26
26
|
|
27
|
-
####
|
27
|
+
#### File with Inclusion
|
28
28
|
|
29
29
|
Here's the finished file with the inclusion:
|
30
30
|
|
File without changes
|
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: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- burdettelamar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-04-
|
11
|
+
date: 2018-04-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -112,16 +112,15 @@ files:
|
|
112
112
|
- markdown/include_usage.rb
|
113
113
|
- markdown/resolve.md
|
114
114
|
- markdown/resolve_usage.rb
|
115
|
-
- markdown/use_cases/
|
116
|
-
- markdown/use_cases/
|
117
|
-
- markdown/use_cases/
|
118
|
-
- markdown/use_cases/
|
119
|
-
- markdown/use_cases/reusable_text
|
120
|
-
- markdown/use_cases/
|
121
|
-
- markdown/use_cases/
|
122
|
-
- markdown/use_cases/
|
123
|
-
- markdown/use_cases/
|
124
|
-
- markdown/use_cases/rubygem_images.md
|
115
|
+
- markdown/use_cases/gemify_images/template.md
|
116
|
+
- markdown/use_cases/resize_images/template.md
|
117
|
+
- markdown/use_cases/reuse_text/included.md
|
118
|
+
- markdown/use_cases/reuse_text/includer.md
|
119
|
+
- markdown/use_cases/reuse_text/reusable_text.md
|
120
|
+
- markdown/use_cases/reuse_text/reuse_text.md
|
121
|
+
- markdown/use_cases/reuse_text/reuse_text.rb
|
122
|
+
- markdown/use_cases/reuse_text/template.md
|
123
|
+
- markdown/use_cases/verify_examples/template.md
|
125
124
|
- markdown/verbatim_ruby_template.md
|
126
125
|
- markdown_helper.gemspec
|
127
126
|
homepage: https://github.com/BurdetteLamar/markdown_helper
|
@@ -1,5 +0,0 @@
|
|
1
|
-
### Include Generated Text
|
2
|
-
|
3
|
-
Use the markdown helper to include text that is generated at project "build time."
|
4
|
-
|
5
|
-
Example: Project build runs each executable with option <code>--help</code>, capturing the output into a file. That file can then be included into the markdown pages for the project.
|