markita 3.3.210918 → 3.4.210922
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -2
- data/lib/markita/markdown.rb +59 -22
- data/lib/markita.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df6d287bdc5a83164680b7218d6a1b097dddc703ba731f5ae3568e51756385c7
|
4
|
+
data.tar.gz: eca3f9de5cd993be7c206c8bdd8cbcf89d99bb0799960aed60a3140d3f3ba9e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 87f88ceb92a5bd24eddcaf3cbefa4dce1a4098befe0534eef5f68a90931441dd7324bfd5d1cb135351c28451d2a3891c259cbf8e7e2433cdbff54e76a4fbcf15
|
7
|
+
data.tar.gz: c691c08fde7db7ff8ee8f3b72a17b7f8cd32df9bf6b4b970699102b6c9dc3aedae4ce19c183ae912527b9c55432a75f47b337c85c8802130116fca708aa27e32
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Markita
|
2
2
|
|
3
|
-
* [VERSION 3.
|
3
|
+
* [VERSION 3.4.210922](https://github.com/carlosjhr64/markita/releases)
|
4
4
|
* [github](https://www.github.com/carlosjhr64/markita)
|
5
5
|
* [rubygems](https://rubygems.org/gems/markita)
|
6
6
|
|
@@ -269,8 +269,9 @@ Markdown:
|
|
269
269
|
|
270
270
|
!> /path-to/ascii_art.txt
|
271
271
|
|
272
|
-
Must be a `*.txt` file.
|
273
272
|
Useful for ASCII art.
|
273
|
+
Unless an `*.html` file, the text is embedded in `pre` tags.
|
274
|
+
Further more unless a `*.txt` file, the text is embedded in `code` tags.
|
274
275
|
|
275
276
|
### Emojis
|
276
277
|
|
@@ -294,6 +295,16 @@ Markdown:
|
|
294
295
|
[^2]: Cash is money in currency.
|
295
296
|
[^3]: Read as "Nan took it."
|
296
297
|
|
298
|
+
### Meta-data
|
299
|
+
|
300
|
+
Markdown:
|
301
|
+
|
302
|
+
---
|
303
|
+
Title: The Title You Want For Your Page
|
304
|
+
1: https://way.to/create/ref/links
|
305
|
+
---
|
306
|
+
You can now [link](1) with a reference number.
|
307
|
+
|
297
308
|
## HOW-TOs
|
298
309
|
|
299
310
|
### Set site password:
|
data/lib/markita/markdown.rb
CHANGED
@@ -6,6 +6,7 @@ class Markdown
|
|
6
6
|
def initialize(title)
|
7
7
|
@title = title
|
8
8
|
@line=@html=@file=@opt=nil
|
9
|
+
@metadata = {}
|
9
10
|
end
|
10
11
|
|
11
12
|
def start
|
@@ -14,6 +15,9 @@ class Markdown
|
|
14
15
|
end
|
15
16
|
|
16
17
|
def finish
|
18
|
+
if title = @metadata['Title']
|
19
|
+
@html << %Q(<script> document.title = "#{title}" </script>\n)
|
20
|
+
end
|
17
21
|
@html << HTML.footer
|
18
22
|
@line = nil
|
19
23
|
end
|
@@ -62,7 +66,10 @@ class Markdown
|
|
62
66
|
CODE = lambda {|m| "<code>#{m[1]}</code>"}
|
63
67
|
|
64
68
|
Ax = /\[([^\[\]]+)\]\(([^()]+)\)/
|
65
|
-
|
69
|
+
def anchor(m)
|
70
|
+
href = ((_=m[2]).match?(/^\d+$/) and @metadata[_] or _)
|
71
|
+
%Q(<a href="#{href}">#{m[1]}</a>)
|
72
|
+
end
|
66
73
|
|
67
74
|
URLx = %r(\[(https?://[\w\.\-\/\&\+\?\%]+)\])
|
68
75
|
URL = lambda {|m| %Q(<a href="#{m[1]}">#{m[1]}</a>)}
|
@@ -95,9 +102,9 @@ class Markdown
|
|
95
102
|
return (block ? block.call(entry) : entry)
|
96
103
|
end
|
97
104
|
|
98
|
-
|
105
|
+
def inline(entry)
|
99
106
|
string = Markdown.tag(entry, CODEx, CODE) do |entry|
|
100
|
-
Markdown.tag(entry, Ax,
|
107
|
+
Markdown.tag(entry, Ax, method(:anchor)) do |entry|
|
101
108
|
Markdown.tag(entry, URLx, URL) do |entry|
|
102
109
|
entry = Markdown.tag(entry, EMOJIx, EMOJI)
|
103
110
|
entry = Markdown.tag(entry, Bx, B)
|
@@ -128,7 +135,7 @@ class Markdown
|
|
128
135
|
@html << "<ol#{@opt[:attributes]}>\n"
|
129
136
|
@opt.delete(:attributes)
|
130
137
|
while md and level==md[1].length
|
131
|
-
@html << " <li>#{
|
138
|
+
@html << " <li>#{inline(md[2])}</li>\n"
|
132
139
|
if md = (@line=@file.gets)&.match(ORDERED)
|
133
140
|
if level < md[1].length
|
134
141
|
ordered(md, md[1].length)
|
@@ -148,7 +155,7 @@ class Markdown
|
|
148
155
|
@html << "<p#{@opt[:attributes]}>\n"
|
149
156
|
@opt.delete(:attributes)
|
150
157
|
while md
|
151
|
-
@html <<
|
158
|
+
@html << inline(@line)
|
152
159
|
md = (@line=@file.gets)&.match PARAGRAPHS
|
153
160
|
end
|
154
161
|
@html << "</p>\n"
|
@@ -163,7 +170,7 @@ class Markdown
|
|
163
170
|
@html << "<ul#{@opt[:attributes]}>\n"
|
164
171
|
@opt.delete(:attributes)
|
165
172
|
while md and level==md[1].length
|
166
|
-
@html << " <li>#{
|
173
|
+
@html << " <li>#{inline(md[2])}</li>\n"
|
167
174
|
if md = (@line=@file.gets)&.match(UNORDERED)
|
168
175
|
if level < md[1].length
|
169
176
|
unordered(md, md[1].length)
|
@@ -187,7 +194,7 @@ class Markdown
|
|
187
194
|
li = (x=='x')?
|
188
195
|
%q{<li style="list-style-type: '☑ '">} :
|
189
196
|
%q{<li style="list-style-type: '☐ '">}
|
190
|
-
@html << " #{li}#{
|
197
|
+
@html << " #{li}#{inline(t)}</li>\n"
|
191
198
|
md = (@line=@file.gets)&.match BALLOTS
|
192
199
|
end
|
193
200
|
@html << "</ul>\n"
|
@@ -203,8 +210,8 @@ class Markdown
|
|
203
210
|
@opt.delete(:attributes)
|
204
211
|
while md
|
205
212
|
item = md[1]
|
206
|
-
@html << ((item[-1]==':')? "<dt>#{
|
207
|
-
"<dd>#{
|
213
|
+
@html << ((item[-1]==':')? "<dt>#{inline(item[0..-2])}</dt>\n" :
|
214
|
+
"<dd>#{inline(item)}</dd>\n")
|
208
215
|
md = (@line=@file.gets)&.match DEFINITIONS
|
209
216
|
end
|
210
217
|
@html << "</dl>\n"
|
@@ -217,9 +224,9 @@ class Markdown
|
|
217
224
|
def headers
|
218
225
|
md = HEADERS.match(@line) or return false
|
219
226
|
i,header = md[1].length,md[2]
|
220
|
-
id = header.
|
227
|
+
id = header.gsub(/\([^\(\)]*\)/,'').scan(/\w+/).join('+')
|
221
228
|
@html << %Q(<a id="#{id}">\n)
|
222
|
-
@html << " <h#{i}#{@opt[:attributes]}>#{
|
229
|
+
@html << " <h#{i}#{@opt[:attributes]}>#{inline(header)}</h#{i}>\n"
|
223
230
|
@html << "</a>\n"
|
224
231
|
@opt.delete(:attributes)
|
225
232
|
@line = @file.gets
|
@@ -234,7 +241,7 @@ class Markdown
|
|
234
241
|
@html << "<blockquote#{@opt[:attributes]}>\n"
|
235
242
|
@opt.delete(:attributes)
|
236
243
|
while md
|
237
|
-
@html <<
|
244
|
+
@html << inline(md[1])
|
238
245
|
@html << "\n"
|
239
246
|
md = (@line=@file.gets)&.match BLOCKQS
|
240
247
|
end
|
@@ -278,14 +285,31 @@ class Markdown
|
|
278
285
|
true
|
279
286
|
end
|
280
287
|
|
281
|
-
#
|
288
|
+
# Meta-data
|
289
|
+
METADATAS = /^(\w+): (.*)$/
|
290
|
+
def metadata
|
291
|
+
md = METADATAS.match(@line) or return false
|
292
|
+
while md
|
293
|
+
@metadata[md[1]] = md[2]
|
294
|
+
md = (@line=@file.gets)&.match METADATAS
|
295
|
+
end
|
296
|
+
true
|
297
|
+
end
|
298
|
+
|
299
|
+
# Horizontal rule or Meta-data
|
282
300
|
HRS = /^---+$/
|
283
301
|
PARSERS << :hrs
|
284
302
|
def hrs
|
285
303
|
HRS.match? @line or return false
|
286
|
-
@html << "<hr#{@opt[:attributes]}>\n"
|
287
|
-
@opt.delete(:attributes)
|
288
304
|
@line = @file.gets
|
305
|
+
if metadata
|
306
|
+
# Optional closing HRS
|
307
|
+
@line = @file.gets if @line&.match? HRS
|
308
|
+
else
|
309
|
+
# Display HR
|
310
|
+
@html << "<hr#{@opt[:attributes]}>\n"
|
311
|
+
@opt.delete(:attributes)
|
312
|
+
end
|
289
313
|
true
|
290
314
|
end
|
291
315
|
|
@@ -297,7 +321,7 @@ class Markdown
|
|
297
321
|
@html << "<table#{@opt[:attributes]}>\n"
|
298
322
|
@opt.delete(:attributes)
|
299
323
|
@html << '<thead><tr><th>'
|
300
|
-
@html << @line[1...-1].split('|').map{
|
324
|
+
@html << @line[1...-1].split('|').map{inline(_1.strip)}.join('</th><th>')
|
301
325
|
@html << "</th></tr></thead>\n"
|
302
326
|
align = []
|
303
327
|
while (@line=@file.gets)&.match TABLES
|
@@ -314,7 +338,7 @@ class Markdown
|
|
314
338
|
align[i] = ' align="left"'
|
315
339
|
@html << '<td><hr></td>'
|
316
340
|
else
|
317
|
-
@html << "<td#{align[i]}>#{
|
341
|
+
@html << "<td#{align[i]}>#{inline(cell.strip)}</td>"
|
318
342
|
end
|
319
343
|
end
|
320
344
|
@html << "</tr>\n"
|
@@ -426,14 +450,27 @@ form << %Q{ #{field}:<input type="#{type}" name="#{name}" value="#{value}">}
|
|
426
450
|
end
|
427
451
|
|
428
452
|
# Embed text
|
429
|
-
EMBED_TEXTS = /^!> (#{PAGE_KEY}
|
453
|
+
EMBED_TEXTS = /^!> (#{PAGE_KEY}\.\w+)$/
|
430
454
|
PARSERS << :embed_texts
|
431
455
|
def embed_texts
|
432
456
|
md = EMBED_TEXTS.match(@line) or return false
|
433
457
|
if File.exist?(filename=File.join(ROOT, md[1]))
|
434
|
-
|
435
|
-
|
436
|
-
|
458
|
+
extension,lang = filename.split('.').last,nil
|
459
|
+
unless extension=='html'
|
460
|
+
lang = Rouge::Lexer.find extension
|
461
|
+
klass = lang ? ' class="highlight"' : nil
|
462
|
+
@html << "<pre#{klass}#{@opt[:attributes]}>"
|
463
|
+
@opt.delete(:attributes)
|
464
|
+
@html << '<code>' unless extension=='txt'
|
465
|
+
@html << "\n"
|
466
|
+
end
|
467
|
+
code = File.read(filename)
|
468
|
+
@html << (lang ? ROUGE.format(lang.new.lex(code)) : code)
|
469
|
+
unless extension=='html'
|
470
|
+
@html << '</code>' unless extension=='txt'
|
471
|
+
@html << '</pre>'
|
472
|
+
@html << "\n"
|
473
|
+
end
|
437
474
|
else
|
438
475
|
@html << @line
|
439
476
|
end
|
@@ -448,7 +485,7 @@ form << %Q{ #{field}:<input type="#{type}" name="#{name}" value="#{value}">}
|
|
448
485
|
md = FOOTNOTES.match(@line) or return false
|
449
486
|
@html << "<small>\n"
|
450
487
|
while md
|
451
|
-
@html <<
|
488
|
+
@html << inline(@line.chomp)+"<br>\n"
|
452
489
|
md = (@line=@file.gets)&.match FOOTNOTES
|
453
490
|
end
|
454
491
|
@html << "</small>\n"
|
data/lib/markita.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.4.210922
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CarlosJHR64
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: help_parser
|