wikitxt 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/Gemfile.lock +1 -1
- data/README.md +20 -0
- data/lib/wikitxt/node.rb +28 -0
- data/lib/wikitxt/parser.rb +13 -0
- data/lib/wikitxt/version.rb +1 -1
- data/lib/wikitxt/views/layout.erb +4 -4
- data/samples/Wikitxt.txt +6 -31
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7d36aaac23a1d7ba85f0c1b966722702fb988545fa7f4f1550eb0bfad2423e
|
4
|
+
data.tar.gz: 141d7bdcfe59efb10c1f3be0295c370fc9aaefbb94dd973cadb7968d76c13971
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ad58a00cd43a4ded7bb066000774095e39eb52eba0a5fdd5ee1827868868a7e830efc836d7afaaedc04c0db59b22615e4c604b13a8de71b77a5b25dbdb29319
|
7
|
+
data.tar.gz: 9b014e93d894663b6ac222361cd01b0906c84666f207917185a190a5cb10477c0a40e292af7f9b8daef6b11cba102309df414639c43c188f8fcd4194ef2db9b5
|
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
@@ -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
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
|
+
---
|