Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zhgchgli0718 committed Mar 18, 2023
1 parent 5db05eb commit cb5fe20
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 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 = '2.1.5'
gem.version = '2.1.7'

gem.license = "MIT"

Expand Down
38 changes: 20 additions & 18 deletions lib/Parsers/MarkupStyleRender.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,28 +197,30 @@ def parse()
elsif markup.anchorType == "USER"
url = "https://medium.com/u/#{markup.userId}"
end

lastPath = url.split("/").last
lastQuery = nil
if !lastPath.nil?
lastQuery = lastPath.split("-").last
end

if !usersPostURLs.nil? && !usersPostURLs.find { |usersPostURL| usersPostURL.split("/").last.split("-").last == lastQuery }.nil?
if isForJekyll
url = "(../#{lastQuery}/)"
else
url = "(#{lastPath})"

if url =~ /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}(:[0-9]{1,5})?(\/.*)?$/ix
lastPath = url.split("/").last
lastQuery = nil
if !lastPath.nil?
lastQuery = lastPath.split("-").last
end
else
if isForJekyll
url = "(#{url}){:target=\"_blank\"}"

if !usersPostURLs.nil? && !usersPostURLs.find { |usersPostURL| usersPostURL.split("/").last.split("-").last == lastQuery }.nil?
if isForJekyll
url = "(../#{lastQuery}/)"
else
url = "(#{lastPath})"
end
else
url = "(#{url})"
if isForJekyll
url = "(#{url}){:target=\"_blank\"}"
else
url = "(#{url})"
end
end

tag = TagChar.new(1, markup.start, markup.end, "[", "]#{url}")
end

tag = TagChar.new(1, markup.start, markup.end, "[", "]#{url}")
else
Helper.makeWarningText("Undefined Markup Type: #{markup.type}.")
end
Expand Down

0 comments on commit cb5fe20

Please sign in to comment.