Skip to content

Commit

Permalink
optimzie
Browse files Browse the repository at this point in the history
  • Loading branch information
zhgchgli0718 committed Jun 12, 2022
1 parent c075d70 commit a0759d9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ZMediumToMarkdown.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
gem.files = Dir['lib/**/*.*']
gem.executables = ['ZMediumToMarkdown']
gem.name = 'ZMediumToMarkdown'
gem.version = '1.7.3'
gem.version = '1.7.4'

gem.license = "MIT"

Expand Down
2 changes: 1 addition & 1 deletion ZMediumToMarkdown_Github.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
gem.files = Dir['lib/**/*.*']
gem.executables = ['ZMediumToMarkdown']
gem.name = 'zmediumtomarkdown'
gem.version = '1.7.3'
gem.version = '1.7.4'

gem.license = "MIT"

Expand Down
2 changes: 1 addition & 1 deletion bin/ZMediumToMarkdown
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Main
Helper.printNewVersionMessageIfExists()
end

opts.on('-kpPOST_URL', '--jekyllPostURL=POST_URL', 'Downloading single post with Jekyll friendly') do |postURL|
opts.on('-kPOST_URL', '--jekyllPostURL=POST_URL', 'Downloading single post with Jekyll friendly') do |postURL|
outputFilePath = PathPolicy.new(filePath, "/")
fetcher.isForJekyll = true
fetcher.downloadPost(postURL, outputFilePath)
Expand Down
17 changes: 12 additions & 5 deletions lib/Parsers/IMGParser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,28 @@ def parse(paragraph)
imagePathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), paragraph.postID)
absolutePath = imagePathPolicy.getAbsolutePath(fileName)

result = ""
comment = ""
if paragraph.text != ""
comment = " \"#{paragraph.text}\""
if paragraph.orgText != ""
comment = " \"#{paragraph.orgText}\""
end

if ImageDownloader.download(absolutePath, imageURL)
relativePath = "#{pathPolicy.getRelativePath(nil)}/#{imagePathPolicy.getRelativePath(fileName)}"
if isForJekyll
"\r\n![#{paragraph.text}](/#{relativePath}#{comment})\r\n"
result = "\r\n![#{paragraph.text}](/#{relativePath}#{comment})\r\n"
else
"\r\n![#{paragraph.text}](#{relativePath}#{comment})\r\n"
result = "\r\n![#{paragraph.text}](#{relativePath}#{comment})\r\n"
end
else
"\r\n![#{paragraph.text}](#{imageURL}#{comment})\r\n"
result = "\r\n![#{paragraph.text}](#{imageURL}#{comment})\r\n"
end

if paragraph.text != ""
result += "#{paragraph.text}\r\n"
end

result
else
if !nextParser.nil?
nextParser.parse(paragraph)
Expand Down
4 changes: 3 additions & 1 deletion lib/Parsers/PQParser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ class PQParser < Parser
attr_accessor :nextParser
def parse(paragraph)
if paragraph.type == 'PQ'
result = ""
result = "\r\n\r\n"
paragraph.text.each_line do |p|
result += "> #{p}"
end
result += "\r\n\r\n"

result
else
if !nextParser.nil?
Expand Down

0 comments on commit a0759d9

Please sign in to comment.