Skip to content
This repository

Remove trailing whitespace in produced markdown #44

Merged
merged 1 commit into from 12 months ago

2 participants

Marcus Stollsteimer Thomas Leitner
Marcus Stollsteimer

Avoids a trailing whitespace in link definitions without a title when converting to markdown (kramdown) format:

require 'kramdown'
htmldoc =<<HTML
<p><a href="http://test1.com/">Test 1</a></p>
<p><a href="http://test2.com/" title="Test 2">Test 2</a></p>
HTML
puts Kramdown::Document.new(htmldoc, :input => :html).to_kramdown

Output:

[Test 1][1]

[Test 2][2]



[1]: http://test1.com/X
[2]: http://test2.com/ "Test 2"

with a whitespace (marked by "X") at the end of link definition 1.

Marcus Stollsteimer Removed trailing whitespace in link definition
Avoids a trailing whitespace in link definitions without a title
when converting to kramdown format.
bbb28e4
Marcus Stollsteimer

Ping? Any feedback?

Thomas Leitner
Owner

Pong! Looks good, will have a detailed look on the weekend when I have more time.

Thomas Leitner gettalong merged commit bbb28e4 into from
Thomas Leitner gettalong closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 27, 2013
Marcus Stollsteimer Removed trailing whitespace in link definition
Avoids a trailing whitespace in link definitions without a title
when converting to kramdown format.
bbb28e4
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  lib/kramdown/converter/kramdown.rb
2  lib/kramdown/converter/kramdown.rb
@@ -366,7 +366,7 @@ def create_link_defs
366 366
         res << "\n\n" if @linkrefs.size > 0
367 367
         @linkrefs.each_with_index do |el, i|
368 368
           title = el.attr['title']
369  
-          res << "[#{i+1}]: #{el.attr['href']} #{title ? '"' + title.gsub(/"/, "&quot;") + '"' : ''}\n"
  369
+          res << "[#{i+1}]: #{el.attr['href']}#{title ? ' "' + title.gsub(/"/, "&quot;") + '"' : ''}\n"
370 370
         end
371 371
         res
372 372
       end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.