wikitxt 0.1.8 → 0.1.9
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 +2 -2
- data/lib/wikitxt/node.rb +2 -2
- data/lib/wikitxt/parser.rb +6 -5
- data/lib/wikitxt/version.rb +1 -1
- data/samples/Wikitxt.txt +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: d4681e7a7528c3ae501f20cb3b6ba334686e403bd54fbda8c07a62dc2826ec39
|
|
4
|
+
data.tar.gz: de019304d4c52ffcbe8b2cf8462023134842c7b6cd5cb346ee15e96ddd6dff63
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2bb59f7935afca149a4ea47bb0210eb26051acf04fc1e54037baf196c55fe8892378c3e35022063e5c92d609c1a86eb1ce5814c41900206eddbcdeb0eca87334
|
|
7
|
+
data.tar.gz: a0c849923b6381bad63c91fb7b8070f96075a7c1cab3cca15ce2d4020e201c68e05006e282e7882e1230fc633c8988064aa29fac704e6c1e772108b4c0a987d2
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -71,13 +71,13 @@ Internal Images:
|
|
|
71
71
|
External Links:
|
|
72
72
|
|
|
73
73
|
```
|
|
74
|
-
|
|
74
|
+
https://example.com
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
External Images:
|
|
78
78
|
|
|
79
79
|
```
|
|
80
|
-
|
|
80
|
+
https://example.com/image.png
|
|
81
81
|
```
|
|
82
82
|
|
|
83
83
|
Pre Blocks:
|
data/lib/wikitxt/node.rb
CHANGED
|
@@ -45,13 +45,13 @@ module Wikitxt
|
|
|
45
45
|
|
|
46
46
|
class LinkNode < BaseNode
|
|
47
47
|
def to_html
|
|
48
|
-
" <a href=\"#{attrs[:url]}\">#{
|
|
48
|
+
" <a href=\"#{attrs[:url]}\">#{attrs[:title] ? CGI.escapeHTML(attrs[:title]) : attrs[:url]}</a> "
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
class ImageNode < BaseNode
|
|
53
53
|
def to_html
|
|
54
|
-
"<img src=\"#{attrs[:url]}\"
|
|
54
|
+
"<img src=\"#{attrs[:url]}\" />"
|
|
55
55
|
end
|
|
56
56
|
end
|
|
57
57
|
|
data/lib/wikitxt/parser.rb
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'uri'
|
|
4
|
+
|
|
3
5
|
module Wikitxt
|
|
4
6
|
class Parser
|
|
5
7
|
class Block
|
|
@@ -51,15 +53,14 @@ module Wikitxt
|
|
|
51
53
|
scanner = StringScanner.new(parent.attrs[:text])
|
|
52
54
|
|
|
53
55
|
until scanner.eos? do
|
|
54
|
-
if result = scanner.scan(
|
|
56
|
+
if result = scanner.scan(URI.regexp(["http", "https"]))
|
|
55
57
|
parent.children << pending if pending
|
|
56
58
|
pending = nil
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
parent.children << ImageNode.new(url: match[:url], title: match[:title])
|
|
59
|
+
if result.match(/\.(png|jpg|jpeg|svg)/)
|
|
60
|
+
parent.children << ImageNode.new(url: result)
|
|
60
61
|
next
|
|
61
62
|
end
|
|
62
|
-
parent.children << LinkNode.new(url:
|
|
63
|
+
parent.children << LinkNode.new(url: result)
|
|
63
64
|
next
|
|
64
65
|
end
|
|
65
66
|
|
data/lib/wikitxt/version.rb
CHANGED
data/samples/Wikitxt.txt
CHANGED
|
@@ -15,7 +15,7 @@ In summary, it's like this:
|
|
|
15
15
|
Text decoration is limited to links.
|
|
16
16
|
Words you want to emphasize should be expressed as wiki pages.
|
|
17
17
|
|
|
18
|
-
Absolute url is parsed as external link:
|
|
18
|
+
Absolute url is parsed as external link: https://example.com
|
|
19
19
|
|
|
20
20
|
#woman.jpg
|
|
21
21
|
|
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.9
|
|
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-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: thor
|