dtext_rb 1.4.1 → 1.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/dtext/extconf.rb +1 -0
- data/lib/dtext.rb +19 -0
- metadata +25 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a0ae5ddbd77f003f5f02622d970d4b59be2918a
|
4
|
+
data.tar.gz: 17fd9b6d2cae65ecbe7b4f679ee129a6de5e00b2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c9041f204a9b30f492e4232bd4894a3ec2bb08c0b6f292b367aab26a35307d15813d71c9f0ba0c065a11955a132c45be0aa1d495107c0ac792e657cb5b30e15
|
7
|
+
data.tar.gz: 6f8462c6babfbc29ba38d5b09e025ba869aa3603539f3696a2001d9b58ca9319d9a5060d092dfe55e1e8908f5017beb844d89aa66bb7d1f040767a8b0709a6ee
|
data/ext/dtext/extconf.rb
CHANGED
data/lib/dtext.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "dtext/dtext"
|
2
|
+
require "nokogiri"
|
2
3
|
|
3
4
|
module DTextRagel
|
4
5
|
class Error < StandardError; end
|
@@ -10,4 +11,22 @@ module DTextRagel
|
|
10
11
|
def self.parse_strip(str)
|
11
12
|
parse(str, :strip => true)
|
12
13
|
end
|
14
|
+
|
15
|
+
def self.parse(str, strip: false, inline: false, disable_mentions: false, base_url: nil)
|
16
|
+
html = c_parse(str, strip, inline, disable_mentions)
|
17
|
+
html = resolve_relative_urls(html, base_url) if base_url
|
18
|
+
html
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def self.resolve_relative_urls(html, base_url)
|
24
|
+
nodes = Nokogiri::HTML.fragment(html)
|
25
|
+
nodes.traverse do |node|
|
26
|
+
if node[:href]&.start_with?("/")
|
27
|
+
node[:href] = base_url.chomp("/") + node[:href]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
nodes.to_s
|
31
|
+
end
|
13
32
|
end
|
metadata
CHANGED
@@ -1,57 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dtext_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- r888888888
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: nokogiri
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.6'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.10'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake-compiler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
45
|
- - "~>"
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0
|
34
|
-
type: :
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
52
|
- - "~>"
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0
|
54
|
+
version: '1.0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: jeweler
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '2.
|
48
|
-
type: :
|
61
|
+
version: '2.3'
|
62
|
+
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '2.
|
68
|
+
version: '2.3'
|
55
69
|
description: Compiled DText parser
|
56
70
|
email: r888888888@gmail.com
|
57
71
|
executables:
|