wikitxt 0.1.6 → 0.1.8
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/Gemfile.lock +1 -1
- data/README.md +20 -0
- data/lib/wikitxt/node.rb +30 -2
- data/lib/wikitxt/parser.rb +13 -0
- data/lib/wikitxt/version.rb +1 -1
- data/lib/wikitxt/views/layout.erb +4 -11
- data/samples/Wikitxt.txt +6 -31
- 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: 73eb1677244102056a2c0ce55f4b155dd93458e7cb323e838cf7a9c4f4d2b340
|
4
|
+
data.tar.gz: 77a2f7d698c476d522839228054216d9a223dc486cd6bc7f9b84683a6ddd574a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46496b95ccd05a44058ec74c1ee7190743921af27a4a9503ae664095b32741f3c9b1a1d0716873f4a88dee0c7bf92106c5b511f3cffa515cad98f830306be353
|
7
|
+
data.tar.gz: 85fb0547e9f9a990a0ec5f257bcaa2d4964fd18bc70c274c9c12f545ed5ba4b447219f19aa77ef53b025301c68d968df8341577cb8eaec74cc2b2fd42f90a90a
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -80,6 +80,18 @@ External Images:
|
|
80
80
|
#<https://example.com/image.png Example Image>
|
81
81
|
```
|
82
82
|
|
83
|
+
Pre Blocks:
|
84
|
+
|
85
|
+
```
|
86
|
+
---
|
87
|
+
class Foo
|
88
|
+
def bar
|
89
|
+
p "bar"
|
90
|
+
end
|
91
|
+
end
|
92
|
+
---
|
93
|
+
```
|
94
|
+
|
83
95
|
## Usage
|
84
96
|
|
85
97
|
### Render HTML
|
@@ -123,6 +135,14 @@ Access to http://localhost:4567 .
|
|
123
135
|
$ wikitxt build wiki
|
124
136
|
```
|
125
137
|
|
138
|
+
### Search references
|
139
|
+
|
140
|
+
Install [ripgrep (rg)](https://github.com/BurntSushi/ripgrep)
|
141
|
+
|
142
|
+
```
|
143
|
+
$ rg "#RDB" .
|
144
|
+
```
|
145
|
+
|
126
146
|
## Development
|
127
147
|
|
128
148
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/wikitxt/node.rb
CHANGED
@@ -30,7 +30,7 @@ module Wikitxt
|
|
30
30
|
def to_html
|
31
31
|
<<~HTML
|
32
32
|
<div class="line">
|
33
|
-
<div
|
33
|
+
<div style="margin-left: #{attrs[:indent] * 10}px;"></div>
|
34
34
|
<div class="list">#{Parser::Inline.new(self).to_html}</div>
|
35
35
|
</div>
|
36
36
|
HTML
|
@@ -45,7 +45,7 @@ module Wikitxt
|
|
45
45
|
|
46
46
|
class LinkNode < BaseNode
|
47
47
|
def to_html
|
48
|
-
" <a href=\"#{attrs[:url]}\">#{CGI.escapeHTML(attrs[:title])}</a> "
|
48
|
+
" <a href=\"#{attrs[:url]}\">#{!attrs[:title].empty? ? CGI.escapeHTML(attrs[:title]) : attrs[:url]}</a> "
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -54,4 +54,32 @@ module Wikitxt
|
|
54
54
|
"<img src=\"#{attrs[:url]}\" title=\"#{attrs[:title]}\" />"
|
55
55
|
end
|
56
56
|
end
|
57
|
+
|
58
|
+
class CodeNode < BaseNode
|
59
|
+
def to_html
|
60
|
+
<<~HTML
|
61
|
+
<div class="line">
|
62
|
+
<code><pre>#{CGI.escapeHTML(attrs[:text])}</pre></code>
|
63
|
+
</div>
|
64
|
+
HTML
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class PreStartNode < BaseNode
|
69
|
+
def to_html
|
70
|
+
"<pre>"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class PreEndNode < BaseNode
|
75
|
+
def to_html
|
76
|
+
"</pre>\n"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class PreNode < BaseNode
|
81
|
+
def to_html
|
82
|
+
CGI.escapeHTML(attrs[:text])
|
83
|
+
end
|
84
|
+
end
|
57
85
|
end
|
data/lib/wikitxt/parser.rb
CHANGED
@@ -11,8 +11,21 @@ module Wikitxt
|
|
11
11
|
|
12
12
|
def body
|
13
13
|
b = BodyNode.new
|
14
|
+
in_pre = false
|
14
15
|
|
15
16
|
text.lines.each do |line|
|
17
|
+
if line == "---\n"
|
18
|
+
node = !in_pre ? PreStartNode.new : PreEndNode.new
|
19
|
+
b.children << node
|
20
|
+
in_pre = !in_pre
|
21
|
+
next
|
22
|
+
end
|
23
|
+
|
24
|
+
if in_pre
|
25
|
+
b.children << PreNode.new(text: line)
|
26
|
+
next
|
27
|
+
end
|
28
|
+
|
16
29
|
if match = line.match(/^(?<indent> {2,})(?<text>.*)$/)
|
17
30
|
b.children << ListNode.new(text: match[:text], indent: match[:indent].length - 2)
|
18
31
|
next
|
data/lib/wikitxt/version.rb
CHANGED
@@ -31,19 +31,12 @@
|
|
31
31
|
min-height: 1rem;
|
32
32
|
}
|
33
33
|
|
34
|
-
.dot {
|
35
|
-
width: 5px;
|
36
|
-
height: 5px;
|
37
|
-
background: #333;
|
38
|
-
border-radius: 100%;
|
39
|
-
}
|
40
|
-
|
41
34
|
pre, code {
|
42
35
|
background: #eee;
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
36
|
+
margin: 0;
|
37
|
+
width: 100%;
|
38
|
+
padding: 0.5rem;
|
39
|
+
box-sizing: border-box;
|
47
40
|
}
|
48
41
|
|
49
42
|
blockquote {
|
data/samples/Wikitxt.txt
CHANGED
@@ -19,35 +19,10 @@ Absolute url is parsed as external link: #<https://example.com Example Domain>
|
|
19
19
|
|
20
20
|
#woman.jpg
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
画像
|
27
|
-
やってないこと
|
28
|
-
#装飾文字
|
29
|
-
これはいらない気もする
|
30
|
-
#コードブロック
|
31
|
-
#引用
|
32
|
-
#自動リンク
|
33
|
-
コードスパンがないのでURLを生で書きたい時に困る
|
34
|
-
コードブロックというかpreはは必要なのか
|
35
|
-
というか #コードブロック の記法を作るくらいならpreタグを使うのとさほど変わらないのでは
|
36
|
-
|
37
|
-
<code>
|
38
|
-
class Hoge
|
39
|
-
def initialize(fuga)
|
40
|
-
@fuga = fuga
|
41
|
-
end
|
22
|
+
---
|
23
|
+
class Foo
|
24
|
+
def bar
|
25
|
+
p "bar"
|
42
26
|
end
|
43
|
-
|
44
|
-
|
45
|
-
↑preタグの中にもリストができてしまったので修正必要そう。
|
46
|
-
|
47
|
-
インラインは良さそう: <pre>これはpreタグの中身です</pre>
|
48
|
-
|
49
|
-
と思ったがpreタグは改行されるのか
|
50
|
-
|
51
|
-
<blockquote>
|
52
|
-
ホゲホゲ
|
53
|
-
</blockquote>
|
27
|
+
end
|
28
|
+
---
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wikitxt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moeki Kawakami
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|