Skip to content

Commit

Permalink
fix markdown format
Browse files Browse the repository at this point in the history
  • Loading branch information
app-harry committed Aug 23, 2024
1 parent 1044ce0 commit 4a4237f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 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.4.2'
gem.version = '2.4.3'

gem.license = "MIT"

Expand Down
41 changes: 28 additions & 13 deletions lib/Parsers/IframeParser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,43 @@ def parse(paragraph)
gist.gsub! '\"', '"'
gist.gsub! '<\/', '</'
gistHTML = Nokogiri::HTML(gist)

lang = gistHTML.search('table').first['data-tagsearch-lang']

if !lang.nil?
lang = lang.downcase
if isForJekyll and lang == "objective-c"
lang = "objectivec"
end
gistHTML.search('a').each do |a|
if a.text == 'view raw'
gistRAW = Request.body(Request.URL(a['href']))
gistHTML.search('a').each do |a|
if a.text == 'view raw'
isMarkdown = false
lang = gistHTML.search('table').first['data-tagsearch-lang']
if !lang.nil?
lang = lang.downcase
if isForJekyll and lang == "objective-c"
lang = "objectivec"
end
else
viewRawURL = a['href']
extName = File.extname(viewRawURL).delete_prefix(".")
if extName == "md"
isMarkdown = true
else
lang = extName
end
end


gistRAW = Request.body(Request.URL(a['href']))

if isMarkdown
result = "\n"

result += gistRAW.chomp

result += "\n"
else
result = "```#{lang}\n"

result += gistRAW.chomp

result += "\n```"
end
end
else
clean_url = srce.to_s.gsub(/\.js$/, '')
result = "[#{clean_url}](#{clean_url})#{jekyllOpen}"
end
else
ogURL = url
Expand Down

0 comments on commit 4a4237f

Please sign in to comment.