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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73eb1677244102056a2c0ce55f4b155dd93458e7cb323e838cf7a9c4f4d2b340
4
- data.tar.gz: 77a2f7d698c476d522839228054216d9a223dc486cd6bc7f9b84683a6ddd574a
3
+ metadata.gz: d4681e7a7528c3ae501f20cb3b6ba334686e403bd54fbda8c07a62dc2826ec39
4
+ data.tar.gz: de019304d4c52ffcbe8b2cf8462023134842c7b6cd5cb346ee15e96ddd6dff63
5
5
  SHA512:
6
- metadata.gz: 46496b95ccd05a44058ec74c1ee7190743921af27a4a9503ae664095b32741f3c9b1a1d0716873f4a88dee0c7bf92106c5b511f3cffa515cad98f830306be353
7
- data.tar.gz: 85fb0547e9f9a990a0ec5f257bcaa2d4964fd18bc70c274c9c12f545ed5ba4b447219f19aa77ef53b025301c68d968df8341577cb8eaec74cc2b2fd42f90a90a
6
+ metadata.gz: 2bb59f7935afca149a4ea47bb0210eb26051acf04fc1e54037baf196c55fe8892378c3e35022063e5c92d609c1a86eb1ce5814c41900206eddbcdeb0eca87334
7
+ data.tar.gz: a0c849923b6381bad63c91fb7b8070f96075a7c1cab3cca15ce2d4020e201c68e05006e282e7882e1230fc633c8988064aa29fac704e6c1e772108b4c0a987d2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wikitxt (0.1.8)
4
+ wikitxt (0.1.9)
5
5
  rackup (~> 2.1)
6
6
  sinatra (~> 4.0)
7
7
  thor (~> 1.3)
data/README.md CHANGED
@@ -71,13 +71,13 @@ Internal Images:
71
71
  External Links:
72
72
 
73
73
  ```
74
- #<https://example.com Example Domain>
74
+ https://example.com
75
75
  ```
76
76
 
77
77
  External Images:
78
78
 
79
79
  ```
80
- #<https://example.com/image.png Example Image>
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]}\">#{!attrs[:title].empty? ? CGI.escapeHTML(attrs[:title]) : attrs[:url]}</a> "
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]}\" title=\"#{attrs[:title]}\" />"
54
+ "<img src=\"#{attrs[:url]}\" />"
55
55
  end
56
56
  end
57
57
 
@@ -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
- match = result.match(/#<(?<title>.*) *(?<url>https?:\/\/.+\.\S+) *(?<title>.*)>/)
58
- if match[:url].match(/\.(png|jpg|jpeg|svg)/)
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: match[:url], title: match[:title])
63
+ parent.children << LinkNode.new(url: result)
63
64
  next
64
65
  end
65
66
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Wikitxt
4
- VERSION = "0.1.8"
4
+ VERSION = "0.1.9"
5
5
  end
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: #<https://example.com Example Domain>
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.8
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-14 00:00:00.000000000 Z
11
+ date: 2024-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor