jekyll-chatgpt-translate 0.0.15 → 0.0.16
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3a1fa14a50caf08c780825e889b16c100e4afcd4042db089e49b33d01eece4a
|
4
|
+
data.tar.gz: 87cf1124880695e6efad136115b7dfd9e33a629e03f154adc5f7325f7f6e43e9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb6b987ce7934d9294ba69f73d4d23bb3c74d6394cc5537ed956ee0b54b280f0ae79e5d12c9974ef75402f0586422700727d02304e44c4d7f5c74090c7b7c03c
|
7
|
+
data.tar.gz: 597a0397823b9d91a65ce1b8269f3117f37152b2ab9c8eafd501a9c4c0aaeec9ecd70022460616c2ae8c212605fb2fd1df347ab07b9accc5323e5931d7cfd037
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
29
29
|
s.required_ruby_version = '>= 2.6'
|
30
30
|
s.name = 'jekyll-chatgpt-translate'
|
31
|
-
s.version = '0.0.
|
31
|
+
s.version = '0.0.16'
|
32
32
|
s.license = 'MIT'
|
33
33
|
s.summary = 'Translate Jekyll Pages Through ChatGPT'
|
34
34
|
s.description = [
|
@@ -52,7 +52,7 @@ class GptTranslate::ChatGPT
|
|
52
52
|
if par.length <= 32
|
53
53
|
Jekyll.logger.debug("Not translating this, b/c too short: \"#{par}\"")
|
54
54
|
par
|
55
|
-
elsif par !~ /^[
|
55
|
+
elsif par !~ /^[[:alpha:]]/
|
56
56
|
Jekyll.logger.debug("Not translating this, b/c it's not a plain text: \"#{par}\"")
|
57
57
|
par
|
58
58
|
elsif @key.empty?
|
@@ -40,36 +40,26 @@ class GptTranslate::Plain
|
|
40
40
|
def to_s
|
41
41
|
# To turn compact lists into proper lists
|
42
42
|
@markdown.gsub(/([^\n])\n(\s*\*)/, "\\1\n\n\\2").split(/\n{2,}/).compact.map do |par|
|
43
|
-
par.
|
44
|
-
par.gsub!(/\n+/, ' ')
|
45
|
-
par.gsub!(/ {2,}/, ' ')
|
43
|
+
par.strip!
|
46
44
|
# Liquid tags are removed, but this implementation is primitive
|
47
45
|
# Seehttps://stackoverflow.com/questions/
|
48
46
|
par.gsub!(/{{[^}]+}}/, '')
|
49
47
|
par.gsub!(/{%.+?%}/, '')
|
50
48
|
par.gsub!(/<!--.+?-->/m, '')
|
51
|
-
par.
|
52
|
-
|
49
|
+
par = Redcarpet::Markdown.new(Strip).render(par)
|
50
|
+
par.gsub!("\t", ' ')
|
51
|
+
par.gsub!(/\n+/, ' ') unless par.start_with?('```')
|
52
|
+
par.gsub!(/ {2,}/, ' ') unless par.start_with?('```')
|
53
|
+
par.strip
|
53
54
|
end.join("\n\n").gsub(/\n{2,}/, "\n\n").strip
|
54
55
|
end
|
55
56
|
|
56
|
-
# # To ignore/remove Liquid tags.
|
57
|
-
# class NullDrop < Liquid::Drop
|
58
|
-
# def method_missing(*)
|
59
|
-
# nil
|
60
|
-
# end
|
61
|
-
|
62
|
-
# def respond_to_missing?(*)
|
63
|
-
# true
|
64
|
-
# end
|
65
|
-
# end
|
66
|
-
|
67
57
|
# Markdown to pain text.
|
68
58
|
class Strip < Redcarpet::Render::Base
|
69
59
|
%i[
|
70
60
|
block_code block_quote
|
71
61
|
block_html
|
72
|
-
autolink
|
62
|
+
autolink double_emphasis
|
73
63
|
emphasis underline
|
74
64
|
triple_emphasis strikethrough
|
75
65
|
superscript highlight quote
|
@@ -81,8 +71,16 @@ class GptTranslate::Plain
|
|
81
71
|
end
|
82
72
|
end
|
83
73
|
|
84
|
-
def
|
85
|
-
|
74
|
+
def codespan(content)
|
75
|
+
if content.start_with?("\n")
|
76
|
+
"```#{content}```"
|
77
|
+
else
|
78
|
+
content
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def raw_html(content)
|
83
|
+
content
|
86
84
|
end
|
87
85
|
|
88
86
|
def list(content, _type)
|
data/test/test_plain.rb
CHANGED
@@ -78,17 +78,24 @@ class GptTranslate::PlainTest < Minitest::Test
|
|
78
78
|
|
79
79
|
def test_code_block
|
80
80
|
assert_equal(
|
81
|
-
"Hello:\n\nJava",
|
81
|
+
"Hello:\n\n```\nJava\n```",
|
82
82
|
GptTranslate::Plain.new("Hello:\n\n```\nJava\n```\n").to_s
|
83
83
|
)
|
84
84
|
end
|
85
85
|
|
86
86
|
def test_html
|
87
87
|
assert_equal(
|
88
|
-
'This is picture:
|
88
|
+
'This is picture: <img src="a"/>!',
|
89
89
|
GptTranslate::Plain.new('This is picture: <img src="a"/>!').to_s
|
90
90
|
)
|
91
|
-
assert_equal('
|
91
|
+
assert_equal('<img src="a"/>', GptTranslate::Plain.new('<img src="a"/>').to_s)
|
92
|
+
end
|
93
|
+
|
94
|
+
def test_big_code
|
95
|
+
assert_equal(
|
96
|
+
"```\nHello\n```",
|
97
|
+
GptTranslate::Plain.new("```\nHello\n```").to_s
|
98
|
+
)
|
92
99
|
end
|
93
100
|
|
94
101
|
def test_liquid_tags
|
@@ -97,7 +104,7 @@ class GptTranslate::PlainTest < Minitest::Test
|
|
97
104
|
GptTranslate::Plain.new('Hello, {{ Java }}!').to_s
|
98
105
|
)
|
99
106
|
assert_equal(
|
100
|
-
'Hello,
|
107
|
+
'Hello, dude !',
|
101
108
|
GptTranslate::Plain.new('Hello, {% if a %} dude {% endif %}!').to_s
|
102
109
|
)
|
103
110
|
assert_equal(
|