markita 1.0.210828 → 1.1.210831
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -4
- data/lib/markita/base.rb +10 -47
- data/lib/markita/config.rb +53 -0
- data/lib/markita/plug/about.rb +3 -1
- 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: 7e32fdc718fa8203e27f73d16b930ce44389416a641274a5968797c0f3d0633c
|
4
|
+
data.tar.gz: 442c0aaefb4f63225dbf9ede33b1b7a253549186b78a8ed194626c60c1ee6dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e242670a5d48bed91d12856dd80bcfe87dae2e3334fb61ed80719200bd6050acea75a8b70e594aea49a66f34f60740b1f1bc2759959c9ddc8dfd2bd60b808ac
|
7
|
+
data.tar.gz: c6f717c76229814fefa75a47d064284ffe9af7ba79f6714746b54cba75d8048275fd870f497ab79d89ca375204ac0bb8c5c3f8b0918c1b6317ac96ad5d0688f3
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Markita
|
2
2
|
|
3
|
-
* [VERSION 1.
|
3
|
+
* [VERSION 1.1.210831](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
|
|
@@ -51,7 +51,7 @@ Types:
|
|
51
51
|
* Template substitutions
|
52
52
|
* ONLY SERVES MARKDOWN PAGES:`/**/*.md`(omit extension `.md` in the url)
|
53
53
|
* ONLY SERVES PNG and GIF IMAGES: `/**/*.png`, and `/**/*.gif`
|
54
|
-
* See [`lib/markita/plug`](lib/markita/plug) for examples of plugins
|
54
|
+
* See [`lib/markita/plug`](lib/markita/plug) and [`/plug`](https://github.com/carlosjhr64/markita/tree/main/plug) for examples of plugins
|
55
55
|
|
56
56
|
Optionally:
|
57
57
|
|
@@ -112,13 +112,15 @@ The above specified image will float right.
|
|
112
112
|
```
|
113
113
|
### One line forms
|
114
114
|
```txt
|
115
|
+
Note the strict use of space!
|
115
116
|
This will do a get method form:
|
116
117
|
|
117
|
-
Google:[q](https://www.google.com/search)
|
118
|
+
Google:[q] (https://www.google.com/search)
|
118
119
|
|
119
120
|
Due to the password field, this will do a post method form:
|
120
121
|
|
121
|
-
Username:[user] Password:[*pwd](/login.html)
|
122
|
+
Username:[user] Password:[*pwd] (/login.html)
|
123
|
+
|
122
124
|
```
|
123
125
|
### Template substitutions
|
124
126
|
```txt
|
@@ -132,6 +134,34 @@ In the template string, uppercase keys are CGI escaped:
|
|
132
134
|
The substitutions are active until the end of the block.
|
133
135
|
If template is not provided, the line itself will be the template.
|
134
136
|
```
|
137
|
+
### Escaping HTML until after markdown's conversion
|
138
|
+
```
|
139
|
+
|
140
|
+
!-- <table><tr><td> --
|
141
|
+
|
142
|
+
# Left
|
143
|
+
1. One
|
144
|
+
2. Two
|
145
|
+
3. Three
|
146
|
+
|
147
|
+
!-- </td><td> --
|
148
|
+
|
149
|
+
# Right
|
150
|
+
* A
|
151
|
+
* B
|
152
|
+
* C
|
153
|
+
|
154
|
+
!-- </td></tr></table> --
|
155
|
+
|
156
|
+
```
|
157
|
+
### Adding plugs
|
158
|
+
```
|
159
|
+
$ # Assuming ~/vimwiki
|
160
|
+
$ mkdir ~/viwiki/plug
|
161
|
+
$ # Then copy (or create) your plug there.
|
162
|
+
$ # For example:
|
163
|
+
$ GET https://raw.githubusercontent.com/carlosjhr64/markita/main/plug/todotxt.rb > ~/vimwiki/plug/todotxt.rb
|
164
|
+
```
|
135
165
|
## LICENSE
|
136
166
|
|
137
167
|
Copyright 2021 CarlosJHR64
|
data/lib/markita/base.rb
CHANGED
@@ -38,65 +38,28 @@ class Base < Sinatra::Base
|
|
38
38
|
FOOTER
|
39
39
|
end
|
40
40
|
|
41
|
-
def Base.
|
41
|
+
def Base.process(text, procs=POSTPROCESS)
|
42
42
|
val,string,_ = {},'',nil
|
43
43
|
text.each_line do |line|
|
44
44
|
line.chomp!
|
45
45
|
case line
|
46
46
|
when ''
|
47
47
|
val.clear
|
48
|
-
when
|
49
|
-
|
50
|
-
line=_ if _=val[:template]
|
51
|
-
$~.named_captures.each do |name, value|
|
52
|
-
line = line.gsub("&#{name};", value)
|
53
|
-
line = line.gsub("&#{name.upcase};", CGI.escape(value))
|
54
|
-
end
|
55
|
-
when %r(^<!-- (.*) -->$)
|
56
|
-
directive = $1
|
48
|
+
when %r(^<(p>)?!\p{Pd}+ (.*) \p{Pd}+(</p)?>$)
|
49
|
+
directive = $2
|
57
50
|
case directive
|
58
51
|
when %r(^(\w+): "(.*)"$)
|
59
52
|
val[$1.to_sym] = $2
|
53
|
+
next
|
60
54
|
when %r(^(\w+): /(.*)/)
|
61
55
|
val[$1.to_sym] = Regexp.new $2
|
56
|
+
next
|
62
57
|
else
|
63
|
-
|
64
|
-
end
|
65
|
-
next
|
66
|
-
end
|
67
|
-
string << line << "\n"
|
68
|
-
end
|
69
|
-
return string
|
70
|
-
end
|
71
|
-
|
72
|
-
def Base.post_process(text)
|
73
|
-
string,_ = '',nil
|
74
|
-
text.each_line do |line|
|
75
|
-
line.chomp!
|
76
|
-
case line
|
77
|
-
when %r(^(\s*)<li>\[(x| )\] (.*)</li>$)
|
78
|
-
# Task Lists
|
79
|
-
s,x,item = $1,$2,$3
|
80
|
-
li = (x=='x')?
|
81
|
-
%q{<li style="list-style-type: '☑ '">} :
|
82
|
-
%q{<li style="list-style-type: '☐ '">}
|
83
|
-
line = s+li+item+"</li>"
|
84
|
-
when %r(^<p>(\w+:\[\*?\w+\] )+\((\S+)\)</p>$)
|
85
|
-
# One Line Forms
|
86
|
-
action,method,form = $2,'get',''
|
87
|
-
line.scan(/(\w+):\[(\*)?(\w+)\] /).each do |field, pwd, name|
|
88
|
-
type = (pwd)? 'password' : 'text'
|
89
|
-
method = 'post' if pwd
|
90
|
-
form << %Q{ #{field}:<input type="#{type}" name="#{name}">\n}
|
58
|
+
line = directive.gsub('<', '<').gsub('>', '>')
|
91
59
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
line = %Q(<img style="display: block; margin-left: auto; margin-right: auto;" #{$1} />)
|
96
|
-
when %r(^<p><img (src="[^"]*" alt=" [^"]*") />$)
|
97
|
-
line = %Q(<p><img style="float: left;" #{$1} />)
|
98
|
-
when %r(^<p><img (src="[^"]*" alt="[^"]* ") />$)
|
99
|
-
line = %Q(<p><img style="float: right;" #{$1} />)
|
60
|
+
else
|
61
|
+
# set line to IDontCare if IDontCare gets set
|
62
|
+
line=_ if procs.detect{_=_1[line, val]}
|
100
63
|
end
|
101
64
|
string << line << "\n"
|
102
65
|
end
|
@@ -111,7 +74,7 @@ class Base < Sinatra::Base
|
|
111
74
|
filepath = File.join ROOT, key+'.md'
|
112
75
|
raise Sinatra::NotFound unless File.exist? filepath
|
113
76
|
text = File.read(filepath).force_encoding('utf-8')
|
114
|
-
Base.page(key){ Base.
|
77
|
+
Base.page(key){ Base.process markdown Base.process(text, PREPROCESS)}
|
115
78
|
end
|
116
79
|
|
117
80
|
get IMAGE_PATH do |path, *_|
|
data/lib/markita/config.rb
CHANGED
@@ -14,5 +14,58 @@ module Markita
|
|
14
14
|
PAGE_KEY = %r{/(\w[\w\/\-]*\w)}
|
15
15
|
IMAGE_PATH = %r{/(\w[\w\/\-]*\w\.((png)|(gif)))}
|
16
16
|
|
17
|
+
PREPROCESS = [
|
18
|
+
lambda do |line, val|
|
19
|
+
case line
|
20
|
+
when val[:regx]
|
21
|
+
# Template/Substitutions
|
22
|
+
template = val[:template] || line
|
23
|
+
$~.named_captures.each do |name, value|
|
24
|
+
template = template.gsub("&#{name};", value)
|
25
|
+
template = template.gsub("&#{name.upcase};", CGI.escape(value))
|
26
|
+
end
|
27
|
+
template
|
28
|
+
when /^```\s*(\w+)?$/
|
29
|
+
$1 ? "~~~ #{$1}" : '~~~'
|
30
|
+
else
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
]
|
35
|
+
|
36
|
+
POSTPROCESS = [
|
37
|
+
lambda do |line,_|
|
38
|
+
case line
|
39
|
+
when %r(^(\s*)<li>\[(x| )\] (.*)</li>$)
|
40
|
+
# Task Lists
|
41
|
+
spaces,x,item = $1,$2,$3
|
42
|
+
li = (x=='x')?
|
43
|
+
%q{<li style="list-style-type: '☑ '">} :
|
44
|
+
%q{<li style="list-style-type: '☐ '">}
|
45
|
+
spaces+li+item+"</li>"
|
46
|
+
when %r(^<p>(\w+:\[\*?\w+\] )+\((\S+)\)</p>$)
|
47
|
+
# One Line Forms
|
48
|
+
action,method,form = $2,'get',[]
|
49
|
+
line.scan(/(\w+):\[(\*)?(\w+)\] /).each do |field, pwd, name|
|
50
|
+
type = (pwd)? 'password' : 'text'
|
51
|
+
method = 'post' if pwd
|
52
|
+
form << %Q{ #{field}:<input type="#{type}" name="#{name}">}
|
53
|
+
end
|
54
|
+
form.unshift %Q(<form action="#{action}" method="#{method}">)
|
55
|
+
form.push %Q( <input type="submit">) if form.length==1
|
56
|
+
form.push %Q(</form>)
|
57
|
+
form.join("\n")
|
58
|
+
when %r(^<p><img (src="[^"]*" alt=" [^"]* ") /></p>$)
|
59
|
+
%Q(<img style="display: block; margin-left: auto; margin-right: auto;" #{$1} />)
|
60
|
+
when %r(^<p><img (src="[^"]*" alt=" [^"]*") />$)
|
61
|
+
%Q(<p><img style="float: left;" #{$1} />)
|
62
|
+
when %r(^<p><img (src="[^"]*" alt="[^"]* ") />$)
|
63
|
+
%Q(<p><img style="float: right;" #{$1} />)
|
64
|
+
else
|
65
|
+
nil
|
66
|
+
end
|
67
|
+
end
|
68
|
+
]
|
69
|
+
|
17
70
|
START_TIME = Time.now
|
18
71
|
end
|
data/lib/markita/plug/about.rb
CHANGED
@@ -19,7 +19,9 @@ class Base
|
|
19
19
|
basename = File.basename(path, '.*')
|
20
20
|
text << "* [#{basename}](#{path})\n"
|
21
21
|
end
|
22
|
-
|
22
|
+
if defined? Favicon and Favicon::ICO
|
23
|
+
text << "\n![Favicon](/favicon.ico)\n"
|
24
|
+
end
|
23
25
|
text
|
24
26
|
end
|
25
27
|
end
|
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: 1.
|
4
|
+
version: 1.1.210831
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CarlosJHR64
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08-
|
11
|
+
date: 2021-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: help_parser
|