ZMediumToMarkdown 1.7.7 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/Models/Paragraph.rb +4 -3
- data/lib/Parsers/IMGParser.rb +5 -5
- data/lib/Parsers/MIXTAPEEMBEDParser.rb +2 -2
- data/lib/Parsers/MarkupStyleRender.rb +10 -5
- data/lib/ZMediumFetcher.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd013ec3e5d14a70bde7a740c1bf706aab2b2f9d1cb8d51f6dba4d91de6e1a64
|
4
|
+
data.tar.gz: dcb1fd33caff28304fffd152ee4e5027dfa36a149a54230a37cdb93520c0461d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be39a4ea0bef517393348fe00cb61f9b6360197567a2edb30810909e743b833bd948b16fd42cc9bd05b4320500ab7ac54ec1da8ecdedcdc6f3c377eecc17d36e
|
7
|
+
data.tar.gz: 279eb3fdbe72c3569e13b4da3411376d952ccdb835abb1d219f2b77f97ee4a620c952273c0f3831a7dd1b3954af6fb7155226f10c8b85c26e2cd655bc4d30005
|
data/lib/Models/Paragraph.rb
CHANGED
@@ -5,7 +5,7 @@ require 'Parsers/PParser'
|
|
5
5
|
require 'securerandom'
|
6
6
|
|
7
7
|
class Paragraph
|
8
|
-
attr_accessor :postID, :name, :orgText, :text, :type, :href, :metadata, :mixtapeMetadata, :iframe, :oliIndex, :markups, :markupLinks
|
8
|
+
attr_accessor :postID, :name, :orgText, :orgTextWithEscape, :text, :type, :href, :metadata, :mixtapeMetadata, :iframe, :oliIndex, :markups, :markupLinks
|
9
9
|
|
10
10
|
class Iframe
|
11
11
|
attr_accessor :id, :title, :type, :src
|
@@ -61,12 +61,13 @@ class Paragraph
|
|
61
61
|
def initialize(json, postID)
|
62
62
|
@name = json['name']
|
63
63
|
@text = json['text']
|
64
|
+
@orgText = json['text']
|
64
65
|
@type = json['type']
|
65
66
|
@href = json['href']
|
66
67
|
@postID = postID
|
67
68
|
|
68
|
-
|
69
|
-
@
|
69
|
+
orgTextWithEscape = Helper.escapeMarkdown(json['text'])
|
70
|
+
@orgTextWithEscape = orgTextWithEscape
|
70
71
|
|
71
72
|
if json['metadata'].nil?
|
72
73
|
@metadata = nil
|
data/lib/Parsers/IMGParser.rb
CHANGED
@@ -25,19 +25,19 @@ class IMGParser < Parser
|
|
25
25
|
|
26
26
|
result = ""
|
27
27
|
alt = ""
|
28
|
-
if paragraph.
|
29
|
-
alt = " \"#{paragraph.
|
28
|
+
if paragraph.orgTextWithEscape != ""
|
29
|
+
alt = " \"#{paragraph.orgTextWithEscape}\""
|
30
30
|
end
|
31
31
|
|
32
32
|
if ImageDownloader.download(absolutePath, imageURL)
|
33
33
|
relativePath = "#{pathPolicy.getRelativePath(nil)}/#{imagePathPolicy.getRelativePath(fileName)}"
|
34
34
|
if isForJekyll
|
35
|
-
result = "\r\n![#{paragraph.
|
35
|
+
result = "\r\n![#{paragraph.orgTextWithEscape}](/#{relativePath}#{alt})\r\n"
|
36
36
|
else
|
37
|
-
result = "\r\n![#{paragraph.
|
37
|
+
result = "\r\n![#{paragraph.orgTextWithEscape}](#{relativePath}#{alt})\r\n"
|
38
38
|
end
|
39
39
|
else
|
40
|
-
result = "\r\n![#{paragraph.
|
40
|
+
result = "\r\n![#{paragraph.orgTextWithEscape}](#{imageURL}#{alt})\r\n"
|
41
41
|
end
|
42
42
|
|
43
43
|
if paragraph.text != ""
|
@@ -8,9 +8,9 @@ class MIXTAPEEMBEDParser < Parser
|
|
8
8
|
def parse(paragraph)
|
9
9
|
if paragraph.type == 'MIXTAPE_EMBED'
|
10
10
|
if !paragraph.mixtapeMetadata.nil? && !paragraph.mixtapeMetadata.href.nil?
|
11
|
-
"\n[#{paragraph.
|
11
|
+
"\n[#{paragraph.orgTextWithEscape}](#{paragraph.mixtapeMetadata.href})"
|
12
12
|
else
|
13
|
-
"\n#{paragraph.
|
13
|
+
"\n#{paragraph.text}"
|
14
14
|
end
|
15
15
|
else
|
16
16
|
if !nextParser.nil?
|
@@ -191,12 +191,17 @@ class MarkupStyleRender
|
|
191
191
|
end
|
192
192
|
|
193
193
|
if char.chars.join() != "\n"
|
194
|
-
|
195
|
-
|
196
|
-
|
194
|
+
if !stack.select { |tag| tag.startChars.chars.join() == "`" }.nil?
|
195
|
+
# is in code block
|
196
|
+
response.append(char)
|
197
|
+
else
|
198
|
+
resultChar = Helper.escapeMarkdown(char.chars.join())
|
199
|
+
if isForJekyll
|
200
|
+
resultChar = Helper.escapeHTML(resultChar)
|
201
|
+
end
|
202
|
+
|
203
|
+
response.append(TextChar.new(resultChar.chars, "Text"))
|
197
204
|
end
|
198
|
-
|
199
|
-
response.append(TextChar.new(resultChar.chars, "Text"))
|
200
205
|
end
|
201
206
|
|
202
207
|
endTags = tags.select { |tag| tag.endIndex == index }
|
data/lib/ZMediumFetcher.rb
CHANGED
@@ -210,10 +210,10 @@ class ZMediumFetcher
|
|
210
210
|
end
|
211
211
|
|
212
212
|
if isForJekyll
|
213
|
-
postPathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), "_posts")
|
213
|
+
postPathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), "_posts/zmediumtomarkdown")
|
214
214
|
imagePathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), "assets")
|
215
215
|
else
|
216
|
-
postPathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), "
|
216
|
+
postPathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), "zmediumtomarkdown")
|
217
217
|
imagePathPolicy = PathPolicy.new(postPathPolicy.getAbsolutePath(nil), "assets")
|
218
218
|
end
|
219
219
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ZMediumToMarkdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZhgChgLi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|