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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f34b1b96683e25673872ff046d9baaeda079d595d5163fbcf894e0fc3bf340c
4
- data.tar.gz: e852a11256fe0789472182bb43d0cb9a15f75439676043703dc368e0a153e06a
3
+ metadata.gz: dd013ec3e5d14a70bde7a740c1bf706aab2b2f9d1cb8d51f6dba4d91de6e1a64
4
+ data.tar.gz: dcb1fd33caff28304fffd152ee4e5027dfa36a149a54230a37cdb93520c0461d
5
5
  SHA512:
6
- metadata.gz: 7ba230c20dfd3f9638ed837f7a989de1c0fa0309db3865390d6b7616c6f2dcc0321c70acc49875128fb83225d8a892e51ffe7726d06c7311aae30830841d843d
7
- data.tar.gz: f8936158de2a595047cf989f7fabaed2602aec4502f2e2480bef81659980f08ead77e0647a024d1eb4efb72cf4614448abada9d7cecec5741960a8aeb98f5048
6
+ metadata.gz: be39a4ea0bef517393348fe00cb61f9b6360197567a2edb30810909e743b833bd948b16fd42cc9bd05b4320500ab7ac54ec1da8ecdedcdc6f3c377eecc17d36e
7
+ data.tar.gz: 279eb3fdbe72c3569e13b4da3411376d952ccdb835abb1d219f2b77f97ee4a620c952273c0f3831a7dd1b3954af6fb7155226f10c8b85c26e2cd655bc4d30005
@@ -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
- orgText = Helper.escapeMarkdown(json['text'])
69
- @orgText = orgText
69
+ orgTextWithEscape = Helper.escapeMarkdown(json['text'])
70
+ @orgTextWithEscape = orgTextWithEscape
70
71
 
71
72
  if json['metadata'].nil?
72
73
  @metadata = nil
@@ -25,19 +25,19 @@ class IMGParser < Parser
25
25
 
26
26
  result = ""
27
27
  alt = ""
28
- if paragraph.orgText != ""
29
- alt = " \"#{paragraph.orgText}\""
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.orgText}](/#{relativePath}#{alt})\r\n"
35
+ result = "\r\n![#{paragraph.orgTextWithEscape}](/#{relativePath}#{alt})\r\n"
36
36
  else
37
- result = "\r\n![#{paragraph.orgText}](#{relativePath}#{alt})\r\n"
37
+ result = "\r\n![#{paragraph.orgTextWithEscape}](#{relativePath}#{alt})\r\n"
38
38
  end
39
39
  else
40
- result = "\r\n![#{paragraph.orgText}](#{imageURL}#{alt})\r\n"
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.orgText}](#{paragraph.mixtapeMetadata.href})"
11
+ "\n[#{paragraph.orgTextWithEscape}](#{paragraph.mixtapeMetadata.href})"
12
12
  else
13
- "\n#{paragraph.orgText}"
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
- resultChar = Helper.escapeMarkdown(char.chars.join())
195
- if isForJekyll
196
- resultChar = Helper.escapeHTML(resultChar)
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 }
@@ -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), "posts")
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.7.7
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-13 00:00:00.000000000 Z
11
+ date: 2022-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri