#57 ✓invalid
Chad Woolley

Break after list item containing a code block

Reported by Chad Woolley | September 21st, 2008 @ 03:22 AM

How can I avoid the line break in the following example? It puts an unwanted space before the code block...

>> RedCloth.new("* xxx\n<pre><code>\naaaa\n</code></pre>\n").to_html
=> "<ul>\n\t<li>xxx<br />\n<pre><code>\naaaa\n</code></pre></li>\n</ul>"

Comments and changes to this ticket

  • Chad Woolley

    Chad Woolley September 21st, 2008 @ 03:22 AM

    OK, try that again:

    >> RedCloth.new("* xxx\n<pre><code>\naaaa\n</code></pre>\n").to_html
    => "<ul>\n\t<li>xxx<br />\n<pre><code>\naaaa\n</code></pre></li>\n</ul>"
    
    
  • Jason Garber

    Jason Garber September 23rd, 2008 @ 09:26 AM

    • State changed from “new” to “invalid”

    Since lists and pre blocks are both block-level elements, you need two newlines (i.e. a blank line) between them. Otherwise, it thinks you want the PRE to be part of the LI, starting on a new line.

    
    $ ./bin/redcloth
    * one
    * two with some code
    <pre><code>
    This is my code
    </code></pre>
    * three
    ^D
    
    <ul>
    	<li>one</li>
    	<li>two with some code<br />
    <pre><code>
    This is my code
    </code></pre></li>
    	<li>three</li>
    </ul>
    
  • Chad Woolley

    Chad Woolley September 23rd, 2008 @ 12:16 PM

    I don't understand why you marked this invalid. Your example is not the way 4.0.3 works for me:

    >> RedCloth.new("* one\n* two with some code\n<pre><code>\nThis is my code\n</code></pre>\n* three\n").to_html
    => "<ul>\n\t<li>one</li>\n\t<li>two with some code<br />\n<pre><code>\nThis is my code\n</code></pre></li>\n\t<li>three</li>\n</ul>"
    
    

    I DO want the code to part of the line item, but I do not want the br tag. See the br tag? That's what I don't want. How can I avoid it and make the code block part of the li without a br?

  • Jason Garber

    Jason Garber September 25th, 2008 @ 09:07 AM

    • State changed from “invalid” to “open”
    • Tag set to newlines

    Okay, gotcha. I didn't understand that you wanted the pre block within the LI.

    Anything wrong with this?

    
    >> RedCloth.new("* one\n* two with some code<pre><code>\nThis is my code\n</code></pre>\n* three\n").to_html
    => "<ul>\n\t<li>one</li>\n\t<li>two with some code<pre><code>\nThis is my code\n</code></pre></li>\n\t<li>three</li>\n</ul>"
    

    I'll wait to close the ticket until I've heard that it works for you.

  • Jason Garber

    Jason Garber October 1st, 2008 @ 04:41 PM

    • State changed from “open” to “hold”
    • Milestone cleared.

    Waiting to hear back from Chad.

  • Chad Woolley

    Chad Woolley October 3rd, 2008 @ 04:22 AM

    Thanks for the response.

    Well, that works, but results in ugly source. You are saying that I have to put the pre tag on the same line as the prior li tag to avoid the break tag.

    Ths used to work in previous versions of redcloth - they did not introduce the extra break tag. I would consider this a bug, and the approach of putting the pre tag on the previous line without a newline is just a workaround, not an elegant solution.

  • Jason Garber

    Jason Garber October 3rd, 2008 @ 03:07 PM

    • State changed from “hold” to “open”

    What version of RedCloth did it used to work in? Using your example, it was clearly broken in 3.0.4:

    
    ~ $ irb
    >> require 'rubygems'
    => false
    >> gem "RedCloth", "3.0.4"
    => true
    >> require 'redcloth'
    => true
    >> RedCloth::VERSION
    => "3.0.4"
    >> RedCloth.new("* xxx\n<pre><code>\naaaa\n</code></pre>\n").to_html
    => "* xxx\n<pre><code>\naaaa\n</code></pre>"
    
  • Jason Garber

    Jason Garber February 18th, 2009 @ 04:33 PM

    • State changed from “open” to “invalid”

    Chad hasn't responded in four months, so closing ticket. He said it "used to work in previous versions of redcloth" but I showed it didn't work in 3.0.4.

  • Chad Woolley

    Chad Woolley February 18th, 2009 @ 06:15 PM

    Sorry for not replying. I ended up just reformatting all my source to work with the latest version.

    -- Chad

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

RedCloth is a Ruby library for converting Textile into HTML

Shared Ticket Bins

People watching this ticket

Tags

Pages