# Whitespace in SuperRedCloth

**URL:** <https://www.ruby-forum.com/t/whitespace-in-superredcloth/131890>\
**Category:** Redcloth\
**Created:** [March 14, 2008, 5:13am UTC](https://www.ruby-forum.com/t/whitespace-in-superredcloth/131890 "2008-03-14T05:13:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasongarber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jasongarber](https://www.ruby-forum.com/u/jasongarber)\
**Post date:** [March 14, 2008, 5:13am UTC](https://www.ruby-forum.com/t/whitespace-in-superredcloth/131890/1 "2008-03-14T05:13:33Z")

</div>

Up to now, the tests have been running with whitespace stripped out.  
Newlines and tabs are insignificant in HTML, so I figured why bother  
with them?

Now I realize why: they’re significant in pre tags and they also make  
your code look pretty!

I’ve been working to get SRC output to roughly match Tetxile2’s as  
far as tabs and newlines go. It’s tough and is adding a lot of  
messiness to the code! I’m close to done, but I’m not satisfied with  
the result.

How about if we just ran the output through Tidy? Could we bundle  
the tidylib c files in so the user doesn’t have to have tidylib  
installed separately? Will the license allow it?

What do you all think?

Jason

---

<div class="post-metadata">

**Author:** ![jasongarber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jasongarber](https://www.ruby-forum.com/u/jasongarber)\
**Post date:** [March 14, 2008, 5:34am UTC](https://www.ruby-forum.com/t/whitespace-in-superredcloth/131890/2 "2008-03-14T05:34:38Z")

</div>

Running everything through tidy seems superfluous to me – if i had to  
vote, i’d say formatting the html all prettylike isn’t that important,  
and isn’t worth the added parsing time (and trying to get the right libs  
for the platform in the gem, etc). developers can call tidy in their  
own projects if they really want tidy html, right?

is there a way you could:

# retain whitespace between pre/code tags – you’d want to do that even

## with tidy, since it won’t always know how you want to format your code

# and then do something simple with the HTML, like adding newlines after

the end of closed block elments (

\n or \n\n)? maybe tabs  
before - I’m not sure they spent too much time in Textile2 trying to get the tabs  
the way they are – trying to replicate them sounds like a headache you  
don’t need to bring on yourself (& future SRC maintainers).

---

<div class="post-metadata">

**Author:** ![jasongarber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jasongarber](https://www.ruby-forum.com/u/jasongarber)\
**Post date:** [March 14, 2008, 6:27pm UTC](https://www.ruby-forum.com/t/whitespace-in-superredcloth/131890/3 "2008-03-14T18:27:46Z")

</div>

I agree. Whitespace is not crucial. As a rule of thumb I would say  
“never add or remove anything”. This means that if the user inserted a  
return, leave it in the source (either before the

 or after for  
example). If there is a tab, leave it. If there is no tab, no return,  
then do not add anything. Let a whitespace be like any other  
character. This rule means:

1. the parsing does not need fancy coding techniques.
2. the code will be sufficiently readable.
3. there is no messing up in “pre” tags.

This would imply removing the added whitespaces in the ruby HTML rules  
and keep ‘\n’ and ’ ’ in the ragel regex. (space =\> cat, ensure CRLF  
is captured in blocks).

Gaspard  
2008/3/14, David R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![jasongarber](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/977dab/32.png) [@jasongarber](https://www.ruby-forum.com/u/jasongarber)\
**Post date:** [March 14, 2008, 8:23pm UTC](https://www.ruby-forum.com/t/whitespace-in-superredcloth/131890/4 "2008-03-14T20:23:41Z")

</div>

Yes, you’re very right. I’ve been just making it decent but not  
overly precise and it’s going very well. I’ll be able to commit my  
changes soon. Thanks for the feedback, David and Gaspard!
