wikitxt 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -19
- data/Guardfile +2 -2
- data/README.md +62 -3
- data/docs/screenshot.png +0 -0
- data/lib/html/layout.html.erb +5 -1
- data/lib/wikitxt/cli.rb +3 -0
- data/lib/wikitxt/node.rb +7 -1
- data/lib/wikitxt/parser.rb +20 -9
- data/lib/wikitxt/version.rb +1 -1
- data/samples/Wikitxt.txt +20 -0
- data/samples/index.txt +1 -3
- data/samples/woman.jpg +0 -0
- data/wikitxt.gemspec +2 -3
- metadata +7 -18
- data/samples/sample.txt +0 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d3b04ad6ac8b66425ee7374b81ca20cdcb39611ff5a57751eae0f3a54a5937fb
|
4
|
+
data.tar.gz: a3f1748ed210269426e8f3a9256fd3b22574427d7f26983c437d773298e9a722
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a56d2d48bf432221678bfe940d784526d5957593c2ce9712777d10872d0fd5ea814a096aba8efd946501757f88d5131dd4e7acd46c871ef02fcae97e69d4bbc0
|
7
|
+
data.tar.gz: '0383569f43fa4ea1e8d80fb079c62b1deb49c287d2df5afcac193aa3b8a5d96fc19319bd47030111949743d89d2e3cecbf4a61ee4d6fd70f888eb5f5c79fe763'
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,15 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wikitxt (0.1.
|
5
|
-
sinatra (~> 4.0)
|
4
|
+
wikitxt (0.1.2)
|
6
5
|
thor (~> 1.3)
|
7
6
|
webrick (~> 1.8)
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: https://rubygems.org/
|
11
10
|
specs:
|
12
|
-
base64 (0.2.0)
|
13
11
|
coderay (1.1.3)
|
14
12
|
diff-lcs (1.5.1)
|
15
13
|
ffi (1.16.3)
|
@@ -32,8 +30,6 @@ GEM
|
|
32
30
|
rb-inotify (~> 0.9, >= 0.9.10)
|
33
31
|
lumberjack (1.2.10)
|
34
32
|
method_source (1.0.0)
|
35
|
-
mustermann (3.0.0)
|
36
|
-
ruby2_keywords (~> 0.0.1)
|
37
33
|
nenv (0.3.0)
|
38
34
|
notiffany (0.1.3)
|
39
35
|
nenv (~> 0.1)
|
@@ -41,12 +37,6 @@ GEM
|
|
41
37
|
pry (0.14.2)
|
42
38
|
coderay (~> 1.1)
|
43
39
|
method_source (~> 1.0)
|
44
|
-
rack (3.0.10)
|
45
|
-
rack-protection (4.0.0)
|
46
|
-
base64 (>= 0.1.0)
|
47
|
-
rack (>= 3.0.0, < 4)
|
48
|
-
rack-session (2.0.0)
|
49
|
-
rack (>= 3.0.0)
|
50
40
|
rake (13.2.1)
|
51
41
|
rb-fsevent (0.11.2)
|
52
42
|
rb-inotify (0.10.1)
|
@@ -64,18 +54,10 @@ GEM
|
|
64
54
|
diff-lcs (>= 1.2.0, < 2.0)
|
65
55
|
rspec-support (~> 3.13.0)
|
66
56
|
rspec-support (3.13.1)
|
67
|
-
ruby2_keywords (0.0.5)
|
68
57
|
shellany (0.0.1)
|
69
|
-
sinatra (4.0.0)
|
70
|
-
mustermann (~> 3.0)
|
71
|
-
rack (>= 3.0.0, < 4)
|
72
|
-
rack-protection (= 4.0.0)
|
73
|
-
rack-session (>= 2.0.0, < 3)
|
74
|
-
tilt (~> 2.0)
|
75
58
|
spoon (0.0.6)
|
76
59
|
ffi
|
77
60
|
thor (1.3.1)
|
78
|
-
tilt (2.3.0)
|
79
61
|
webrick (1.8.1)
|
80
62
|
|
81
63
|
PLATFORMS
|
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
|
-
#
|
1
|
+
# Wiki.txt
|
2
2
|
|
3
|
-
|
3
|
+
![v](https://badgen.net/rubygems/v/wikitxt)
|
4
|
+
![dt](https://badgen.net/rubygems/dt/wikitxt)
|
5
|
+
![license](https://badgen.net/github/license/kawakamimoeki/wikitxt)
|
6
|
+
|
7
|
+
Most lightweight markup language and personal knowledge manager or wiki platform.
|
8
|
+
|
9
|
+
![screenshot](https://github.com/kawakamimoeki/wikitxt/blob/main/docs/screenshot.png)
|
4
10
|
|
5
11
|
## Installation
|
6
12
|
|
@@ -12,8 +18,61 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
12
18
|
|
13
19
|
$ gem install wikitxt
|
14
20
|
|
21
|
+
## Syntax
|
22
|
+
|
23
|
+
Paragraphs:
|
24
|
+
|
25
|
+
```
|
26
|
+
Wikitxt is a lightweight markup language and a tool for composing Wiki . The syntax of Wikitxt can be converted to HTML and viewed in a browser. When converted to HTML, files can be interlinked.
|
27
|
+
```
|
28
|
+
|
29
|
+
Lists:
|
30
|
+
|
31
|
+
```
|
32
|
+
Lists
|
33
|
+
Based on the idea that most information can be expressed in lists
|
34
|
+
Paragraphs
|
35
|
+
Paragraphs always have the potential to be listed. They can easily be converted to lists.
|
36
|
+
Paragraphs can also serve as headings.
|
37
|
+
Mutual Links
|
38
|
+
Text decoration is limited to links.
|
39
|
+
Words you want to emphasize should be expressed as wiki pages.
|
40
|
+
```
|
41
|
+
|
42
|
+
Internal Links:
|
43
|
+
|
44
|
+
```
|
45
|
+
#internallink
|
46
|
+
```
|
47
|
+
|
48
|
+
Internal Images:
|
49
|
+
|
50
|
+
```
|
51
|
+
#internalimage.png
|
52
|
+
```
|
53
|
+
|
54
|
+
External Links:
|
55
|
+
|
56
|
+
```
|
57
|
+
#<https://example.com Example Domain>
|
58
|
+
```
|
59
|
+
|
60
|
+
External Images:
|
61
|
+
|
62
|
+
```
|
63
|
+
#<https://example.com/image.png Example Image>
|
64
|
+
```
|
65
|
+
|
15
66
|
## Usage
|
16
67
|
|
68
|
+
### Render HTML
|
69
|
+
|
70
|
+
```ruby
|
71
|
+
Wikitxt.to_html(text)
|
72
|
+
```
|
73
|
+
|
74
|
+
### Server
|
75
|
+
|
17
76
|
`wiki/index.txt`:
|
18
77
|
|
19
78
|
```
|
@@ -42,7 +101,7 @@ Cras at tortor urna. Maecenas nec iaculis nulla.
|
|
42
101
|
```
|
43
102
|
|
44
103
|
```
|
45
|
-
wikitxt s
|
104
|
+
$ wikitxt s
|
46
105
|
```
|
47
106
|
|
48
107
|
Access to http://localhost:8000 .
|
data/docs/screenshot.png
ADDED
Binary file
|
data/lib/html/layout.html.erb
CHANGED
@@ -35,11 +35,15 @@
|
|
35
35
|
background: #333;
|
36
36
|
border-radius: 100%;
|
37
37
|
}
|
38
|
+
|
39
|
+
img {
|
40
|
+
max-width: 100%;
|
41
|
+
}
|
38
42
|
</style>
|
39
43
|
|
40
44
|
<body>
|
41
45
|
<div class="content">
|
42
|
-
<div class="title"><%= title %></div>
|
46
|
+
<div class="title"><%= title.capitalize %></div>
|
43
47
|
<%= body %>
|
44
48
|
</div>
|
45
49
|
</body>
|
data/lib/wikitxt/cli.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require "thor"
|
2
2
|
require 'webrick'
|
3
3
|
require 'erb'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
module Wikitxt
|
6
7
|
class CLI < Thor
|
@@ -18,6 +19,8 @@ module Wikitxt
|
|
18
19
|
Dir.mkdir("dist") unless Dir.exist?("dist")
|
19
20
|
File.write(File.join("dist", "#{title}.html"), html)
|
20
21
|
end
|
22
|
+
images = Dir.glob(File.join(path, "*.{png,jpg,jpeg}"))
|
23
|
+
FileUtils.cp(images, "dist")
|
21
24
|
server = WEBrick::HTTPServer.new :Port => 8000, :DocumentRoot => "dist"
|
22
25
|
trap 'INT' do server.shutdown end
|
23
26
|
server.start
|
data/lib/wikitxt/node.rb
CHANGED
@@ -45,7 +45,13 @@ module Wikitxt
|
|
45
45
|
|
46
46
|
class LinkNode < BaseNode
|
47
47
|
def to_html
|
48
|
-
" <a href=\"
|
48
|
+
" <a href=\"#{attrs[:url]}\">#{attrs[:title]}</a> "
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
class ImageNode < BaseNode
|
53
|
+
def to_html
|
54
|
+
"<img src=\"#{attrs[:url]}\" title=\"#{attrs[:title]}\" />"
|
49
55
|
end
|
50
56
|
end
|
51
57
|
end
|
data/lib/wikitxt/parser.rb
CHANGED
@@ -37,17 +37,28 @@ module Wikitxt
|
|
37
37
|
|
38
38
|
scanner = StringScanner.new(parent.attrs[:text])
|
39
39
|
|
40
|
-
if match = parent.attrs[:text].match(/^#(?<page>.+)$/)
|
41
|
-
parent.children << LinkNode.new(page: match[:page])
|
42
|
-
return parent.children.map(&:to_html).join
|
43
|
-
end
|
44
|
-
|
45
40
|
until scanner.eos? do
|
46
|
-
if result = scanner.scan(/
|
47
|
-
parent.children << pending
|
41
|
+
if result = scanner.scan(/ ?#<.+>/)
|
42
|
+
parent.children << pending if pending
|
43
|
+
pending = nil
|
44
|
+
match = result.match(/#<(?<title>.*) *(?<url>https?:\/\/.+\.\S+) *(?<title>.*)>/)
|
45
|
+
if match[:url].match(/\.(png|jpg|jpeg|svg)/)
|
46
|
+
parent.children << ImageNode.new(url: match[:url], title: match[:title])
|
47
|
+
next
|
48
|
+
end
|
49
|
+
parent.children << LinkNode.new(url: match[:url], title: match[:title])
|
50
|
+
next
|
51
|
+
end
|
52
|
+
|
53
|
+
if result = scanner.scan(/(^| )#\S+( |$)/)
|
54
|
+
parent.children << pending if pending
|
48
55
|
pending = nil
|
49
|
-
match = result.match(/ #(?<
|
50
|
-
|
56
|
+
match = result.match(/(^| )#(?<url>\S+)( |$)/)
|
57
|
+
if match[:url].match(/\.(png|jpg|jpeg|svg)/)
|
58
|
+
parent.children << ImageNode.new(url: "/#{match[:url]}")
|
59
|
+
next
|
60
|
+
end
|
61
|
+
parent.children << LinkNode.new(url: "/#{match[:url]}.html", title: match[:url])
|
51
62
|
next
|
52
63
|
end
|
53
64
|
|
data/lib/wikitxt/version.rb
CHANGED
data/samples/Wikitxt.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#Wikitxt is a lightweight markup language and a tool for composing #Wiki . The syntax of #Wikitxt can be converted to #HTML and viewed in a browser. When converted to HTML, files can be interlinked.
|
2
|
+
|
3
|
+
#Wikitxt is based on the format of lists and paragraphs. Most information can be expressed in list format, and the choice between lists and paragraphs is always changing as you write.
|
4
|
+
|
5
|
+
Text decoration is limited to mutual links using hashtags. By utilizing the decoration of mutual links, you can intentionally increase the number of pages in the wiki.
|
6
|
+
|
7
|
+
In summary, it's like this:
|
8
|
+
|
9
|
+
Lists
|
10
|
+
Based on the idea that most information can be expressed in lists
|
11
|
+
Paragraphs
|
12
|
+
Paragraphs always have the potential to be listed. They can easily be converted to lists.
|
13
|
+
Paragraphs can also serve as headings.
|
14
|
+
Mutual Links
|
15
|
+
Text decoration is limited to links.
|
16
|
+
Words you want to emphasize should be expressed as wiki pages.
|
17
|
+
|
18
|
+
Absolute url is parsed as external link: #<https://example.com Example Domain>
|
19
|
+
|
20
|
+
#woman.jpg
|
data/samples/index.txt
CHANGED
data/samples/woman.jpg
ADDED
Binary file
|
data/wikitxt.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.authors = ["Moeki Kawakami"]
|
9
9
|
spec.email = ["moeki.kawakami@icloud.com"]
|
10
10
|
|
11
|
-
spec.summary = "Most lightweight
|
12
|
-
spec.description = "Most lightweight
|
11
|
+
spec.summary = "Most lightweight markup language and personal knowledge manager or wiki platform."
|
12
|
+
spec.description = "Most lightweight markup language and personal knowledge manager or wiki platform."
|
13
13
|
spec.homepage = "https://github.com/kawakamimoeki/wikitxt"
|
14
14
|
spec.license = "MIT"
|
15
15
|
spec.required_ruby_version = ">= 2.6.0"
|
@@ -26,7 +26,6 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.add_dependency "sinatra", "~> 4.0"
|
30
29
|
spec.add_dependency "thor", "~> 1.3"
|
31
30
|
spec.add_dependency "webrick", "~> 1.8"
|
32
31
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moeki Kawakami
|
@@ -10,20 +10,6 @@ bindir: exe
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2024-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: sinatra
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '4.0'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '4.0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: thor
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,7 +38,8 @@ dependencies:
|
|
52
38
|
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '1.8'
|
55
|
-
description: Most lightweight
|
41
|
+
description: Most lightweight markup language and personal knowledge manager or wiki
|
42
|
+
platform.
|
56
43
|
email:
|
57
44
|
- moeki.kawakami@icloud.com
|
58
45
|
executables:
|
@@ -69,6 +56,7 @@ files:
|
|
69
56
|
- LICENSE.txt
|
70
57
|
- README.md
|
71
58
|
- Rakefile
|
59
|
+
- docs/screenshot.png
|
72
60
|
- exe/wikitxt
|
73
61
|
- lib/html/layout.html.erb
|
74
62
|
- lib/wikitxt.rb
|
@@ -77,8 +65,9 @@ files:
|
|
77
65
|
- lib/wikitxt/parser.rb
|
78
66
|
- lib/wikitxt/renderer.rb
|
79
67
|
- lib/wikitxt/version.rb
|
68
|
+
- samples/Wikitxt.txt
|
80
69
|
- samples/index.txt
|
81
|
-
- samples/
|
70
|
+
- samples/woman.jpg
|
82
71
|
- wikitxt.gemspec
|
83
72
|
homepage: https://github.com/kawakamimoeki/wikitxt
|
84
73
|
licenses:
|
@@ -104,5 +93,5 @@ requirements: []
|
|
104
93
|
rubygems_version: 3.3.26
|
105
94
|
signing_key:
|
106
95
|
specification_version: 4
|
107
|
-
summary: Most lightweight
|
96
|
+
summary: Most lightweight markup language and personal knowledge manager or wiki platform.
|
108
97
|
test_files: []
|
data/samples/sample.txt
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec mauris orci, euismod in tortor eu, condimentum pharetra libero.
|
2
|
-
|
3
|
-
Cras at tortor urna. Maecenas nec iaculis nulla.
|
4
|
-
|
5
|
-
Animals:
|
6
|
-
Elephant
|
7
|
-
Giraffe
|
8
|
-
Tiger
|
9
|
-
Penguin
|
10
|
-
Dolphin
|
11
|
-
Foods:
|
12
|
-
Pizza
|
13
|
-
Apple
|
14
|
-
Chocolate
|
15
|
-
Sushi
|
16
|
-
Broccoli
|
17
|
-
|