doublebyte_charactify 1.1.0 → 1.1.15
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/README.md +3 -4
- data/lib/doublebyte_charactify/convert.rb +6 -8
- data/lib/doublebyte_charactify/note_serializer.rb +1 -1
- data/lib/doublebyte_charactify/status_serializer.rb +1 -1
- data/lib/doublebyte_charactify/version.rb +1 -1
- data/lib/doublebyte_charactify.rb +1 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fd87748dcc93b496c31b654b5085b3f7c44f927
|
4
|
+
data.tar.gz: cb15586f2399cffa52d08897ce05d9d82f941c07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3cecb5274bcec8faed3139d6f06a300243705b10c78c62e91b2c40a979bde2ad4e2f616b8ce6b7f27cd087637675e0083fa76ac077f68ac2bd0eac8ed9dbda3c
|
7
|
+
data.tar.gz: ac922bae3b3a86d2b62989588b061c708bb8e20c516b1f03bd924b45a9507acdd0d07b4750cf5be20836407183b4f6d7d9ad99be9e4f30e4ae484ff8cdcbdf9d
|
data/README.md
CHANGED
@@ -18,10 +18,9 @@ And then execute:
|
|
18
18
|
config\initializers\doublebyte_charactify.rb
|
19
19
|
|
20
20
|
```ruby
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
21
|
+
require_relative "inflections"
|
22
|
+
require Rails.root.join("app/serializers/activitypub/note_serializer")
|
23
|
+
DoublebyteCharactify.patch()
|
25
24
|
```
|
26
25
|
|
27
26
|
- toot by mastodon
|
@@ -1,12 +1,10 @@
|
|
1
1
|
module DoublebyteCharactify
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
content = doc.to_xhtml(:encoding => 'UTF-8')
|
8
|
-
end
|
9
|
-
content
|
2
|
+
def self.convert(content, tags)
|
3
|
+
if !(tags.select { |tag| tag.name === '全角芸' }).blank?
|
4
|
+
doc = Nokogiri::XML.parse(content)
|
5
|
+
doc.traverse do |e| e.content = e.content.tr('0-9a-zA-Z/\\\.:#\-_"\' ', '0-9a-zA-Z/\.:#ー_”’ ') if e.text? end
|
6
|
+
content = doc.to_xhtml(:encoding => 'UTF-8')
|
10
7
|
end
|
8
|
+
content
|
11
9
|
end
|
12
10
|
end
|
@@ -4,22 +4,8 @@ require "doublebyte_charactify/status_serializer"
|
|
4
4
|
require "doublebyte_charactify/note_serializer"
|
5
5
|
|
6
6
|
module DoublebyteCharactify
|
7
|
-
def self.
|
8
|
-
# create function for Monkey patch
|
9
|
-
extend self
|
10
|
-
(
|
11
|
-
class << self;
|
12
|
-
self
|
13
|
-
end).module_eval do
|
14
|
-
define_method 'convert_content', &proc
|
15
|
-
# define_method 'b' do
|
16
|
-
# p 'b'
|
17
|
-
# end
|
18
|
-
end
|
19
|
-
|
20
|
-
# Monkey patch
|
7
|
+
def self.patch
|
21
8
|
REST::StatusSerializer.prepend(RESTStatusSerializerPatch)
|
22
9
|
ActivityPub::NoteSerializer.prepend(ActivityPubNoteSerializerPatch)
|
23
10
|
end
|
24
11
|
end
|
25
|
-
|