Earlz
Earlz

Reputation: 63835

How to get <pre> like behaviour, but ignore <br>

I have made my own custom little blog and well, I realized it was ignoring whitespace within code tags. Well, the generated code is like

<div class="codebody">
Mycode<br/>
  other indented code<br/>
othercode<br/>
</div>

my codebody class looks like

.codebody {
   background-color: #FFFFFF;
    font-family: Courier new, courier, mono;
    font-size: 12px;
    color: #006600;
    border: 1px solid #BFBFBF;
}

Well, how can I make it so that indentation will show up in code tags, but it won't add double-line breaks because of the <br/>\n?

Upvotes: 1

Views: 525

Answers (1)

Earlz
Earlz

Reputation: 63835

Well just figured out something.. I'm not sure that it works in all browsers, as it is a pretty nasty hack, but this is what I did

.codebody {
    white-space: pre;
    background-color: #FFFFFF;
    font-family: Courier new, courier, mono;
    font-size: 12px;
    color: #006600;
    border: 1px solid #BFBFBF;
}

.codebody br{
    display: none;
}

Upvotes: 1

Related Questions