ZMediumToMarkdown 1.9.4 → 1.9.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/ZMediumToMarkdown +0 -1
- data/lib/Helper.rb +2 -0
- data/lib/Parsers/CodeBlockParser.rb +10 -2
- data/lib/Parsers/IframeParser.rb +6 -1
- data/lib/Parsers/LinkParser.rb +0 -1
- data/lib/Parsers/PREParser.rb +9 -1
- data/lib/Post.rb +2 -1
- data/lib/ZMediumFetcher.rb +5 -5
- 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: 521c7a377c1e9b93996dc31355a8e7d6afb90708d154f69e31f4f20675bed060
|
4
|
+
data.tar.gz: 396d663eaf2f302168dde595842f092bd0051094baf2cbf4974018c0b2aaf270
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57d8f51c5fe1fa5d193e0cdd1e7d11152a5010520867e54966681d064d0f30a7d81b57fb389c765ed8c522f896b4fad4e5ddb3bff9d58f6ae4687172cc381cfd
|
7
|
+
data.tar.gz: 9c5dfe1ff916f9f9d6c288c3537fd9b542a664959f34101f573f66dd0ce2655611b930fb78396a7392c1998b8ae2c52bee9276e1250c40861ad7a97f2dce0809
|
data/bin/ZMediumToMarkdown
CHANGED
@@ -65,7 +65,6 @@ class Main
|
|
65
65
|
|
66
66
|
opts.on('-v', '--version', 'Print current ZMediumToMarkdown Version & Output Path') do
|
67
67
|
puts "Version:#{Helper.getLocalVersion().to_s}"
|
68
|
-
puts "Output Path:#{outputFilePath.getAbsolutePath(nil)}"
|
69
68
|
|
70
69
|
Helper.printNewVersionMessageIfExists()
|
71
70
|
end
|
data/lib/Helper.rb
CHANGED
@@ -109,6 +109,8 @@ class Helper
|
|
109
109
|
result += "date: #{postInfo.firstPublishedAt.strftime('%Y-%m-%dT%H:%M:%S.%LZ')}\n"
|
110
110
|
result += "categories: #{postInfo.collectionName}\n"
|
111
111
|
result += "tags: [#{postInfo.tags.join(",")}]\n"
|
112
|
+
result += "description: #{postInfo.description}\n"
|
113
|
+
result += "render_with_liquid: false\n"
|
112
114
|
result += "---\n"
|
113
115
|
result += "\r\n"
|
114
116
|
|
@@ -4,7 +4,11 @@ require "Parsers/Parser"
|
|
4
4
|
require 'Models/Paragraph'
|
5
5
|
|
6
6
|
class CodeBlockParser < Parser
|
7
|
-
attr_accessor :nextParser
|
7
|
+
attr_accessor :nextParser, :isForJekyll
|
8
|
+
|
9
|
+
def initialize(isForJekyll)
|
10
|
+
@isForJekyll = isForJekyll
|
11
|
+
end
|
8
12
|
|
9
13
|
def self.getTypeString()
|
10
14
|
'CODE_BLOCK'
|
@@ -20,7 +24,11 @@ class CodeBlockParser < Parser
|
|
20
24
|
|
21
25
|
def parse(paragraph)
|
22
26
|
if CodeBlockParser.isCodeBlock(paragraph)
|
23
|
-
"```\n
|
27
|
+
result = "```\n"
|
28
|
+
|
29
|
+
result += paragraph.text.chomp
|
30
|
+
|
31
|
+
result += "\n```"
|
24
32
|
else
|
25
33
|
if !nextParser.nil?
|
26
34
|
nextParser.parse(paragraph)
|
data/lib/Parsers/IframeParser.rb
CHANGED
@@ -74,7 +74,12 @@ class IframeParser < Parser
|
|
74
74
|
gistHTML.search('a').each do |a|
|
75
75
|
if a.text == 'view raw'
|
76
76
|
gistRAW = Request.body(Request.URL(a['href']))
|
77
|
-
|
77
|
+
|
78
|
+
result = "```#{lang}\n"
|
79
|
+
|
80
|
+
result += gistRAW.chomp
|
81
|
+
|
82
|
+
result += "\n```"
|
78
83
|
end
|
79
84
|
end
|
80
85
|
else
|
data/lib/Parsers/LinkParser.rb
CHANGED
data/lib/Parsers/PREParser.rb
CHANGED
@@ -4,7 +4,11 @@ require "Parsers/Parser"
|
|
4
4
|
require 'Models/Paragraph'
|
5
5
|
|
6
6
|
class PREParser < Parser
|
7
|
-
attr_accessor :nextParser
|
7
|
+
attr_accessor :nextParser, :isForJekyll
|
8
|
+
|
9
|
+
def initialize(isForJekyll)
|
10
|
+
@isForJekyll = isForJekyll
|
11
|
+
end
|
8
12
|
|
9
13
|
def self.isPRE(paragraph)
|
10
14
|
if paragraph.nil?
|
@@ -17,10 +21,14 @@ class PREParser < Parser
|
|
17
21
|
def parse(paragraph)
|
18
22
|
if PREParser.isPRE(paragraph)
|
19
23
|
result = "```\n"
|
24
|
+
|
20
25
|
paragraph.text.each_line do |p|
|
21
26
|
result += p
|
22
27
|
end
|
28
|
+
|
29
|
+
result = result.chomp
|
23
30
|
result += "\n```"
|
31
|
+
|
24
32
|
result
|
25
33
|
else
|
26
34
|
if !nextParser.nil?
|
data/lib/Post.rb
CHANGED
@@ -9,7 +9,7 @@ require 'date'
|
|
9
9
|
class Post
|
10
10
|
|
11
11
|
class PostInfo
|
12
|
-
attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :collectionName
|
12
|
+
attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :collectionName, :description
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.getPostIDFromPostURLString(postURLString)
|
@@ -60,6 +60,7 @@ class Post
|
|
60
60
|
|
61
61
|
def self.parsePostInfoFromPostContent(content, postID)
|
62
62
|
postInfo = PostInfo.new()
|
63
|
+
postInfo.description = content&.dig("Post:#{postID}", "previewContent", "subtitle")
|
63
64
|
postInfo.title = content&.dig("Post:#{postID}", "title")
|
64
65
|
postInfo.tags = content&.dig("Post:#{postID}", "tags").map{ |tag| tag["__ref"].gsub! 'Tag:', '' }
|
65
66
|
|
data/lib/ZMediumFetcher.rb
CHANGED
@@ -50,9 +50,9 @@ class ZMediumFetcher
|
|
50
50
|
info += "-"
|
51
51
|
end
|
52
52
|
if !currentPostParagraphIndex.nil? && !totalPostParagraphsLength.nil?
|
53
|
-
info += "[#{postPath[0..
|
53
|
+
info += "[#{postPath[0..15]}...(#{currentPostParagraphIndex}/#{totalPostParagraphsLength})]"
|
54
54
|
else
|
55
|
-
info += "[#{postPath[0..
|
55
|
+
info += "[#{postPath[0..15]}...]"
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -101,9 +101,9 @@ class ZMediumFetcher
|
|
101
101
|
iframeParser.setNext(imgParser)
|
102
102
|
bqParser = BQParser.new()
|
103
103
|
imgParser.setNext(bqParser)
|
104
|
-
preParser = PREParser.new()
|
104
|
+
preParser = PREParser.new(isForJekyll)
|
105
105
|
bqParser.setNext(preParser)
|
106
|
-
codeBlockParser = CodeBlockParser.new()
|
106
|
+
codeBlockParser = CodeBlockParser.new(isForJekyll)
|
107
107
|
preParser.setNext(codeBlockParser)
|
108
108
|
fallbackParser = FallbackParser.new()
|
109
109
|
codeBlockParser.setNext(fallbackParser)
|
@@ -230,7 +230,7 @@ class ZMediumFetcher
|
|
230
230
|
absolutePath = postPathPolicy.getAbsolutePath("#{postWithDatePath}.md")
|
231
231
|
|
232
232
|
# if markdown file is exists and last modification time is >= latestPublishedAt(last update post time on medium)
|
233
|
-
if File.file?(absolutePath) && File.mtime(absolutePath) >= postInfo.latestPublishedAt
|
233
|
+
if File.file?(absolutePath) && File.mtime(absolutePath).to_time.to_i >= postInfo.latestPublishedAt.to_i
|
234
234
|
# Already downloaded and nothing has changed!, Skip!
|
235
235
|
progress.currentPostParagraphIndex = paragraphs.length
|
236
236
|
progress.message = "Skip, Post already downloaded and nothing has changed!"
|
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.9.
|
4
|
+
version: 1.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZhgChgLi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|