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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/ext/dtext/extconf.rb +1 -0
  3. data/lib/dtext.rb +19 -0
  4. metadata +25 -11
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0c7acf79da08d2c0204dcf8f5eac6e5c11933816
4
- data.tar.gz: 7bf742f9c60729293909230154a289068970fe04
3
+ metadata.gz: 4a0ae5ddbd77f003f5f02622d970d4b59be2918a
4
+ data.tar.gz: 17fd9b6d2cae65ecbe7b4f679ee129a6de5e00b2
5
5
  SHA512:
6
- metadata.gz: a7e89f7bc9dc8fe5f794a5910e66a985a63d2c77c1144204430a990a8ed12678d829f6a3913e5ce63df5f9ebd1aae40accc95c6bc70cc67e95656ddc7f69f78b
7
- data.tar.gz: 4b34cc88af9ec598a4c43ab6792289d59aa330b1efd73fc02d8a2cc2f09239abc482ff9dd88c2853939dafb93adf5b956dc78c65e3c278b07a5f62319696de03
6
+ metadata.gz: 0c9041f204a9b30f492e4232bd4894a3ec2bb08c0b6f292b367aab26a35307d15813d71c9f0ba0c065a11955a132c45be0aa1d495107c0ac792e657cb5b30e15
7
+ data.tar.gz: 6f8462c6babfbc29ba38d5b09e025ba869aa3603539f3696a2001d9b58ca9319d9a5060d092dfe55e1e8908f5017beb844d89aa66bb7d1f040767a8b0709a6ee
data/ext/dtext/extconf.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "mkmf"
2
2
 
3
+ $warnflags = "-Wall -Wextra -Wno-unused-parameter"
3
4
  $CFLAGS << " -std=c99 -D_GNU_SOURCE #{ENV["CFLAGS"]}"
4
5
 
5
6
  pkg_config "glib-2.0"
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.1
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-14 00:00:00.000000000 Z
11
+ date: 2017-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: minitest
14
+ name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '5.8'
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: '5.8'
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.9'
34
- type: :runtime
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.9'
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.0'
48
- type: :runtime
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.0'
68
+ version: '2.3'
55
69
  description: Compiled DText parser
56
70
  email: r888888888@gmail.com
57
71
  executables: