markdown_titles_to_svg 0.1.6 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +298 -15
- data/lib/markdown_titles_to_svg.rb +81 -9
- data/lib/markdown_titles_to_svg/version.rb +1 -1
- data/markdown_titles_to_svg-0.1.6.gem +0 -0
- metadata +3 -3
- data/markdown_titles_to_svg-0.1.5.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c77f3af5e524ce88627f23c2d5853b236cd069320b785e4b14050c9b9e06378
|
4
|
+
data.tar.gz: c662e79b267cf3ec1e132ee10d9f732f03c16fbdfe5673e766b326e0201055c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b13d54f1f65209676deec9cca6b40484e826e940fc7c0be82aada3dabc5cc6e24feebbaa5b0e521f13028ed45cc5d9e8b64b2ff2af410b6e7e31177e1d852ce4
|
7
|
+
data.tar.gz: 26d3fe2ed3f6bb9dc3c90895d2f5d51c45a0701cb374f795b0f65572399d97fef02391b9c870a74ea88694a9e460372a338d75cc0785e3aa99282793e43132b7
|
data/README.md
CHANGED
@@ -1,10 +1,104 @@
|
|
1
|
-
#
|
1
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/titles.svg" height="55px" alt="# Markdown Titles to .svg for Ruby">
|
2
2
|
|
3
|
-
|
3
|
+
Headline Generator for ```Github Markdown``` File to generate beautiful ```Google Fonts``` Headlines.
|
4
|
+
<br>
|
5
|
+
<br>
|
6
|
+
<br>
|
7
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/examples.svg" height="55px" alt="Examples">
|
4
8
|
|
5
|
-
|
9
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/examples/20.svg" height="45px">
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
{ font__google_fonts__h1__name: "Permanent Marker" }
|
13
|
+
```
|
14
|
+
|
15
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/examples/21.svg" height="45px">
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
{ font__google_fonts__h1__name: "Playfair Display" }
|
19
|
+
```
|
20
|
+
|
21
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/examples/22.svg" height="45px">
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
{ font__google_fonts__h1__name: "Roboto Condensed" }
|
25
|
+
```
|
26
|
+
|
27
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/examples/23.svg" height="45px">
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
{ font__google_fonts__h1__name: "Sarina" }
|
31
|
+
```
|
32
|
+
|
33
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/examples/24.svg" height="45px">
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
{ font__google_fonts__h1__name: "Sonsie One" }
|
37
|
+
```
|
38
|
+
|
39
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/examples/25.svg" height="45px">
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
{ font__google_fonts__h1__name: "Trocchi" }
|
43
|
+
```
|
44
|
+
|
45
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/examples/26.svg" height="45px">
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
{ font__google_fonts__h1__name: "UnifrakturMaguntia" }
|
49
|
+
```
|
50
|
+
|
51
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/examples/27.svg" height="45px">
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
{ font__google_fonts__h1__name: "Zilla Slab Highlight" }
|
55
|
+
```
|
56
|
+
<br>
|
57
|
+
<br>
|
58
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/quickstart.svg" height="55px" alt="Quickstart">
|
59
|
+
|
60
|
+
### Single Title
|
61
|
+
```ruby
|
62
|
+
require 'markdown_titles_to_svg'
|
63
|
+
|
64
|
+
svg = MarkdownTitlesToSvg.single(
|
65
|
+
'headline',
|
66
|
+
:h1,
|
67
|
+
{}
|
68
|
+
)
|
69
|
+
```
|
70
|
+
|
71
|
+
|
72
|
+
### Generate from Github Markdown
|
73
|
+
```ruby
|
74
|
+
require 'markdown_titles_to_svg'
|
75
|
+
|
76
|
+
markdowns = [
|
77
|
+
'https://raw.githubusercontent.com/a6b8/a6b8/main/templates/readme.md'
|
78
|
+
]
|
79
|
+
|
80
|
+
MarkdownTitlesToSvg.generate(
|
81
|
+
markdowns,
|
82
|
+
'a6b8',
|
83
|
+
{}
|
84
|
+
)
|
85
|
+
```
|
86
|
+
<br>
|
87
|
+
<br>
|
88
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/demo.svg" height="55px" alt="Demo">
|
89
|
+
|
90
|
+
**A. Implementation**
|
91
|
+
> https://raw.githubusercontent.com/a6b8/a6b8/main/README.md
|
6
92
|
|
7
|
-
|
93
|
+
|
94
|
+
**B. Execution**
|
95
|
+
> https://github.com/a6b8/a6b8/blob/main/titles.sh
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
<br>
|
100
|
+
<br>
|
101
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/setup.svg" height="55px" alt="Setup">
|
8
102
|
|
9
103
|
Add this line to your application's Gemfile:
|
10
104
|
|
@@ -19,25 +113,214 @@ And then execute:
|
|
19
113
|
Or install it yourself as:
|
20
114
|
|
21
115
|
$ gem install markdown_headlines_to_svg
|
116
|
+
<br>
|
117
|
+
<br>
|
118
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/process.svg" height="55px" alt="Process">
|
22
119
|
|
23
|
-
|
120
|
+
1. Run Command
|
121
|
+
```txt
|
122
|
+
mds = [ PATH_FILE1, PATH_FILE2 ]
|
123
|
+
markdown_headlines_to_svg.generate(
|
124
|
+
mds,
|
125
|
+
"github_profile_name",
|
126
|
+
options = {}
|
127
|
+
)
|
24
128
|
|
25
|
-
|
129
|
+
```
|
26
130
|
|
27
|
-
|
131
|
+
2. Prepare (Import) Font
|
132
|
+
``` txt
|
133
|
+
:h1 :default
|
134
|
+
| |
|
135
|
+
| mode | mode
|
136
|
+
---------- ----------
|
137
|
+
| | | |
|
138
|
+
v v v v
|
139
|
+
Local Google Fonts Local
|
140
|
+
```
|
28
141
|
|
29
|
-
|
142
|
+
3. Scrape Titles
|
143
|
+
``` txt
|
30
144
|
|
31
|
-
|
145
|
+
MD_FILE_ 1 QUEUE
|
146
|
+
------------------------------------------------------
|
147
|
+
| img src="../a/c/d/1.svg" alt="# Headline 1" ------|------> [ 0 ]
|
148
|
+
| |
|
149
|
+
| MD_FILE_2 |
|
150
|
+
| -----------------------------------------------------
|
151
|
+
| | img src="../b/c/d/1.svg" alt="# Headline 2" -----|-> [ 1 ]
|
152
|
+
|----| ... |
|
153
|
+
| img src="../c/d/e/2.svg" alt="Title 1" ----------|-> [ 2 ]
|
154
|
+
| ... |
|
32
155
|
|
33
|
-
|
156
|
+
[ 0 ] { text: 'Headline 1', type: :h1, output: '../a/c/d/1.svg' }
|
157
|
+
[ 1 ] { text: 'Headline 2', type: :h1, output: '../b/c/d/1.svg' }
|
158
|
+
[ 2 ] { text: 'Title 1', type: :default, output: '../c/d/e/2.svg' }
|
159
|
+
```
|
34
160
|
|
35
|
-
|
161
|
+
4. Add Style and Font Options
|
36
162
|
|
37
|
-
|
163
|
+
``` txt
|
164
|
+
default
|
165
|
+
+ user options
|
166
|
+
{ |
|
167
|
+
type: :h1, ---------------------|------------------
|
168
|
+
text: 'Headline 1', | |
|
169
|
+
output: '../a/c/d/1.svg', V V
|
170
|
+
style: <-------------------- options[ :style ][ :h1 ]
|
171
|
+
font: <---------------------- options[ :font ][ :h1 ]
|
172
|
+
},
|
173
|
+
{ ...
|
38
174
|
|
39
|
-
|
175
|
+
```
|
176
|
+
<br>
|
177
|
+
<br>
|
178
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/functions.svg" height="55px" alt="Functions">
|
179
|
+
|
180
|
+
### .get_options()
|
181
|
+
Output all Parameter
|
182
|
+
```ruby
|
183
|
+
MarkdownTitlesToSvg.get_options()
|
184
|
+
|
185
|
+
# => { github: { profile: nil, ...
|
186
|
+
```
|
187
|
+
|
188
|
+
### .generate( [], '', {} )
|
189
|
+
Generate and store of Titles in all Files
|
190
|
+
```ruby
|
191
|
+
MarkdownTitlesToSvg.generate(
|
192
|
+
markdowns,
|
193
|
+
'a6b8',
|
194
|
+
{}
|
195
|
+
)
|
196
|
+
```
|
197
|
+
|
198
|
+
| **Type** | **Required** | **Description** | **Example** | **Description** |
|
199
|
+
|------:|:------|:------|:------|:------|
|
200
|
+
| **markdowns** | ```Array (of String)``` | Yes | ```[ '/markdown-titles-to-svg/main/README.md' ]``` | Define List of Markup |
|
201
|
+
| **github user name** | ```String``` | Yes | ```'a6b8'``` | Set Github User Name |
|
202
|
+
| **options** | ```Hash``` | No | ```'a6b8'``` | Change default options, see "options" for more Information. |
|
203
|
+
|
204
|
+
### .single( [], '', {} )
|
205
|
+
Generate a single Title and outputs a svg string.
|
206
|
+
```ruby
|
207
|
+
svg = MarkdownTitlesToSvg.single(
|
208
|
+
'headline',
|
209
|
+
:h1,
|
210
|
+
{}
|
211
|
+
)
|
212
|
+
|
213
|
+
# => <svg ...
|
214
|
+
```
|
40
215
|
|
41
|
-
|
216
|
+
| **Type** | **Required** | **Description** | **Example** | **Description** |
|
217
|
+
|------:|:------|:------|:------|:------|
|
218
|
+
| **headline** | ```String``` | Yes | ```'headline'``` | Define List of Markup |
|
219
|
+
| **style** | ```Symbol``` | Yes | ```:h1``` | |
|
220
|
+
| **options** | ```Hash``` | No | ```{}``` | Change default options, see "options" for more Information. |
|
42
221
|
|
43
|
-
|
222
|
+
<br>
|
223
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/options.svg" height="55px" alt="Options">
|
224
|
+
|
225
|
+
### Github
|
226
|
+
| Nr | Name | Key | Default | Type | Description |
|
227
|
+
| :-- | :-- | :-- | :-- | :-- | :-- |
|
228
|
+
| A.1. | Source |:github__source | `"https://raw.githubusercontent.com/"` | String | |
|
229
|
+
|
230
|
+
|
231
|
+
### Font
|
232
|
+
| Nr | Name | Key | Default | Type | Description |
|
233
|
+
| :-- | :-- | :-- | :-- | :-- | :-- |
|
234
|
+
| B.1. | Text_align |:font__text_align | `left` | Symbol | Set aligment of text |
|
235
|
+
| B.2. | Bold |:font__bold | `false` | Boolean | Set format of font. If you use Google Fonts try "variant first" |
|
236
|
+
| B.3. | Mode H1 |:font__mode__h1 | `:google_fonts` | Symbol | Set mode for Headlines. Choose between :h1 and :google_fonts |
|
237
|
+
| B.4. | Mode Default |:font__mode__default | `:google_fonts` | Symbol | Set mode for Titles. Choose between :h1 and :google_font |
|
238
|
+
|
239
|
+
|
240
|
+
#### Import from Local
|
241
|
+
| Nr | Name | Key | Default | Type | Description |
|
242
|
+
| :-- | :-- | :-- | :-- | :-- | :-- |
|
243
|
+
| B.5. | H1 |:font__local__h1 | `"/Library/Fonts/Microsoft/Corbel Bold.ttf"` | String | Set local font for Headline if necessary |
|
244
|
+
| B.6. | Default |:font__local__default | `"/Library/Fonts/Microsoft/Consolas.ttf"` | String | String | Set local font for Titles if necessary |
|
245
|
+
|
246
|
+
|
247
|
+
#### Import from "Google Fonts"
|
248
|
+
| Nr | Name | Key | Default | Type | Description |
|
249
|
+
| :-- | :-- | :-- | :-- | :-- | :-- |
|
250
|
+
| B.7. | H1 Name |:font__google_fonts__h1__name | `"Oswald"` | String | Set Google Fonts font name for Headline |
|
251
|
+
| B.8. | H1 Variant |:font__google_fonts__h1__variant | `"regular"` | String | Set Google Fonts variant type for headlines |
|
252
|
+
| B.9. | H1 Subset |:font__google_fonts__h1__subset | `"latin"` | String | Set Google Fonts subset type for headlines |
|
253
|
+
| B.10. | Default Name |:font__google_fonts__default__name | `"Amatic SC"` | String | Set Google Fonts font name for Titles |
|
254
|
+
| B.11. | Default Variant |:font__google_fonts__default__variant | `"regular"` | String | Set Google Fonts variant type for titles |
|
255
|
+
| B.12. | Default Subset |:font__google_fonts__default__subset | `"latin"` | String | Set Google Fonts subset type for titles |
|
256
|
+
|
257
|
+
Please use https://google-webfonts-helper.herokuapp.com/fonts to find your favorite Font.
|
258
|
+
|
259
|
+
### View
|
260
|
+
| Nr | Name | Key | Default | Type | Description |
|
261
|
+
| :-- | :-- | :-- | :-- | :-- | :-- |
|
262
|
+
| C.1. | Offset Height |:view__offset__height | `0` | Integer | Experimental: Set change View Box height |
|
263
|
+
| C.2. | Offset Widht |:view__offset__widht | `0` | Integer | Experimental: Set change View Box width |
|
264
|
+
|
265
|
+
### Style
|
266
|
+
|
267
|
+
#### Headlines
|
268
|
+
| Nr | Name | Key | Default | Type | Description |
|
269
|
+
| :-- | :-- | :-- | :-- | :-- | :-- |
|
270
|
+
| D.1. | Color Opacity |:style__h1__color__opacity | `1.0` | Float | Change Headline color opacity |
|
271
|
+
| D.2. | Color Default |:style__h1__color__default | `"#A5834B"` | String | Change Headline fill color |
|
272
|
+
| D.3. | Color Palette |:style__h1__color__palette | `[]` | Array | Experimental: Set for each character in headline an other color |
|
273
|
+
| D.4. | Stroke Color |:style__h1__stroke__color | `"none"` | String | Change headline fill color of stroke |
|
274
|
+
| D.5. | Stroke Width |:style__h1__stroke__width | `"0"` | String | Change headline stroke width |
|
275
|
+
| D.6. | Stroke Opacity |:style__h1__stroke__opacity | `1.0` | Float | Change headline stroke opacity |
|
276
|
+
| D.7. | Stroke Linecap |:style__h1__stroke__linecap | `"butt"` | String | Change headline stroke width |
|
277
|
+
|
278
|
+
#### Default
|
279
|
+
| Nr | Name | Key | Default | Type | Description |
|
280
|
+
| :-- | :-- | :-- | :-- | :-- | :-- |
|
281
|
+
| D.8. | Color Opacity |:style__default__color__opacity | `1.0` | Float | Change Title color opacity |
|
282
|
+
| D.9. | Color Default |:style__default__color__default | `"#A5834B"` | String | Change Title fill color |
|
283
|
+
| D.10. | Color Palette |:style__default__color__palette | `[]` | Array | Experimental: Set for each character in titles an other color |
|
284
|
+
| D.11. | Stroke Color |:style__default__stroke__color | `"none"` | String | Change title fill color of stroke |
|
285
|
+
| D.12. | Stroke Width |:style__default__stroke__width | `"0"` | String | Change title stroke width |
|
286
|
+
| D.13. | Stroke Opacity |:style__default__stroke__opacity | `1.0` | Float | Change title stroke opacity |
|
287
|
+
| D.14. | Stroke Linecap |:style__default__stroke__linecap | `"butt"` | String | Change title stroke width |
|
288
|
+
|
289
|
+
You can find more Information about ```svg``` format here: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/path
|
290
|
+
|
291
|
+
|
292
|
+
### Other
|
293
|
+
| Nr | Name | Key | Default | Type | Description |
|
294
|
+
| :-- | :-- | :-- | :-- | :-- | :-- |
|
295
|
+
| E.1. | Silent | :silent | `false` | Boolean | Controll console output. |
|
296
|
+
|
297
|
+
<br>
|
298
|
+
<br>
|
299
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/limitations.svg" height="55px" alt="Limitations">
|
300
|
+
|
301
|
+
- Font Types are limited to '.ttf' and '.otf'.
|
302
|
+
- Read only Markdown Files from Github.
|
303
|
+
<br>
|
304
|
+
<br>
|
305
|
+
|
306
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/contributing.svg" height="55px" alt="Contributing">
|
307
|
+
|
308
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/a6b8/statosio-for-wordpress. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/a6b8/statosio/blob/master/CODE_OF_CONDUCT.md).
|
309
|
+
<br>
|
310
|
+
<br>
|
311
|
+
<br>
|
312
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/license.svg" height="55px" alt="License">
|
313
|
+
|
314
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
315
|
+
<br>
|
316
|
+
<br>
|
317
|
+
<br>
|
318
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/code-of-conduct.svg" height="55px" alt="Code of Conduct">
|
319
|
+
|
320
|
+
Everyone interacting in the Statosio project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/a6b8/markdown-titles-to-svg-for-ruby/blob/master/CODE_OF_CONDUCT.md).
|
321
|
+
<br>
|
322
|
+
<br>
|
323
|
+
<br>
|
324
|
+
<img src="https://raw.githubusercontent.com/a6b8/a6b8/main/docs/markdown-titles-to-svg-for-ruby/readme/headlines/support-my-work.svg" height="55px" alt="Support my Work">
|
325
|
+
|
326
|
+
Donate by [https://www.paypal.com](https://www.paypal.com/donate?hosted_button_id=XKYLQ9FBGC4RG)
|
@@ -56,7 +56,7 @@ module MarkdownTitlesToSvg
|
|
56
56
|
h1: {
|
57
57
|
color: {
|
58
58
|
opacity: 1.0,
|
59
|
-
default: '#
|
59
|
+
default: '#CAD1D8',
|
60
60
|
palette: []
|
61
61
|
},
|
62
62
|
stroke: {
|
@@ -69,7 +69,7 @@ module MarkdownTitlesToSvg
|
|
69
69
|
default: {
|
70
70
|
color: {
|
71
71
|
opacity: 1.0,
|
72
|
-
default: '#
|
72
|
+
default: '#CAD1D8',
|
73
73
|
palette: []
|
74
74
|
},
|
75
75
|
stroke: {
|
@@ -89,8 +89,33 @@ module MarkdownTitlesToSvg
|
|
89
89
|
end
|
90
90
|
|
91
91
|
|
92
|
+
def self.single( headline, type, options = {})
|
93
|
+
svg = nil
|
94
|
+
if self.validate_single( headline, type, options, @TEMPLATE )
|
95
|
+
obj = self.options_update( options, @TEMPLATE, 'set_options' )
|
96
|
+
obj = self.set_fonts( obj )
|
97
|
+
|
98
|
+
cmd = {}
|
99
|
+
cmd[:headline] = headline
|
100
|
+
cmd[:type] = type
|
101
|
+
svg = self.svg_generate( cmd, obj )
|
102
|
+
end
|
103
|
+
|
104
|
+
obj[:font][:mode].keys.each do | key |
|
105
|
+
if obj[:font][:mode][ key ] == :google_fonts
|
106
|
+
if ( Time.now.getutc.to_i - obj[:font][:current][ key ].split( '-' )[ 1 ].to_i ) < 30
|
107
|
+
if File.basename( obj[:font][:current][ key ] ) .start_with?( key.to_s )
|
108
|
+
File.delete( obj[:font][:current][ key ] )
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
return svg
|
114
|
+
end
|
115
|
+
|
116
|
+
|
92
117
|
def self.generate( markdowns, gh_name, options = {} )
|
93
|
-
if self.
|
118
|
+
if self.validate_generate( markdowns, gh_name, options, @TEMPLATE )
|
94
119
|
obj = self.options_update( options, @TEMPLATE, 'set_options' )
|
95
120
|
obj[:github][:profile] = gh_name
|
96
121
|
obj = self.set_fonts( obj )
|
@@ -99,9 +124,10 @@ module MarkdownTitlesToSvg
|
|
99
124
|
|
100
125
|
root = './'
|
101
126
|
cmds.each do | cmd |
|
127
|
+
puts cmd
|
102
128
|
svg = self.svg_generate( cmd, obj )
|
103
129
|
FileUtils.mkdir_p ( File.dirname( cmd[:path] ) )
|
104
|
-
File.open( cmd[:path],
|
130
|
+
File.open( cmd[:path], 'w' ) { | f | f.write( svg ) }
|
105
131
|
end
|
106
132
|
|
107
133
|
obj[:font][:mode].keys.each do | key |
|
@@ -191,7 +217,7 @@ module MarkdownTitlesToSvg
|
|
191
217
|
.min_by { | h | h[:score] }
|
192
218
|
|
193
219
|
font = fonts_subset
|
194
|
-
.find { | a | a["id"].eql? id[:name] }
|
220
|
+
.find { | a | a["id"].eql?( id[:name] ) }
|
195
221
|
|
196
222
|
variant = font['variants']
|
197
223
|
.map { | a | { name: a, score: self.str_difference( style.to_s, a.to_s ) } }
|
@@ -215,7 +241,53 @@ module MarkdownTitlesToSvg
|
|
215
241
|
end
|
216
242
|
|
217
243
|
|
218
|
-
def self.
|
244
|
+
def self.validate_single( headline, type, vars, template )
|
245
|
+
messages = {
|
246
|
+
headline:[],
|
247
|
+
type:[],
|
248
|
+
options:[]
|
249
|
+
}
|
250
|
+
if headline.class.to_s.eql?( 'String' )
|
251
|
+
else
|
252
|
+
messages[:headline].push( 'Is not Type "String"')
|
253
|
+
end
|
254
|
+
|
255
|
+
if type.class.to_s.eql?( 'Symbol' )
|
256
|
+
if [ :h1, :default ].include? type
|
257
|
+
else
|
258
|
+
messages[:type].push( 'Input is not :h1 or :default' )
|
259
|
+
end
|
260
|
+
else
|
261
|
+
messages[:type].push( 'Is not Type "Symbol"' )
|
262
|
+
end
|
263
|
+
|
264
|
+
if vars.class.to_s == 'Hash'
|
265
|
+
messages[:options] = self.options_update( vars, template, 'check_options' )
|
266
|
+
else
|
267
|
+
messages[:options].push( 'Is not Type "Hash".')
|
268
|
+
end
|
269
|
+
|
270
|
+
|
271
|
+
valid = messages.keys.map { | key | messages[ key ].length }.sum == 0
|
272
|
+
|
273
|
+
if !valid
|
274
|
+
puts 'Following errors occured:'
|
275
|
+
messages.keys.each do | key |
|
276
|
+
if messages[ key ].length != 0
|
277
|
+
|
278
|
+
puts " #{key[ 0, 1 ].upcase}#{key[ 1, key.length ]}"
|
279
|
+
messages[ key ].each do | m |
|
280
|
+
puts " - #{m}"
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
return valid
|
287
|
+
end
|
288
|
+
|
289
|
+
|
290
|
+
def self.validate_generate( markdowns, gh_name, vars, template )
|
219
291
|
messages = {
|
220
292
|
markdowns: [],
|
221
293
|
github: [],
|
@@ -224,7 +296,7 @@ module MarkdownTitlesToSvg
|
|
224
296
|
}
|
225
297
|
|
226
298
|
#begin
|
227
|
-
if markdowns.class.to_s.eql? 'Array'
|
299
|
+
if markdowns.class.to_s.eql?( 'Array' )
|
228
300
|
if markdowns.map { | a | a.start_with?( template[:github][:source] ) }.all?
|
229
301
|
if markdowns.map { | a | a.end_with?( '.md' ) }.all?
|
230
302
|
|
@@ -238,8 +310,8 @@ module MarkdownTitlesToSvg
|
|
238
310
|
messages[:markdowns].push( 'Is not Type "Array" or "String".' )
|
239
311
|
end
|
240
312
|
|
241
|
-
if gh_name.class.to_s.eql? 'String'
|
242
|
-
if !gh_name.eql? ''
|
313
|
+
if gh_name.class.to_s.eql?( 'String' )
|
314
|
+
if !gh_name.eql?( '' )
|
243
315
|
|
244
316
|
else
|
245
317
|
messages[:github].push( "Github Name is required." )
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_titles_to_svg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- a6b8
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: text2svg
|
@@ -101,7 +101,7 @@ files:
|
|
101
101
|
- bin/setup
|
102
102
|
- lib/markdown_titles_to_svg.rb
|
103
103
|
- lib/markdown_titles_to_svg/version.rb
|
104
|
-
- markdown_titles_to_svg-0.1.
|
104
|
+
- markdown_titles_to_svg-0.1.6.gem
|
105
105
|
- markdown_titles_to_svg.gemspec
|
106
106
|
homepage: https://github.com/a6b8/markdown-titles-to-svg-for-ruby
|
107
107
|
licenses:
|
Binary file
|