View Single Post
Old 08-17-2017, 12:46 PM   #1
AlanHK
Guru
AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.AlanHK ought to be getting tired of karma fortunes by now.
 
AlanHK's Avatar
 
Posts: 681
Karma: 929286
Join Date: Apr 2014
Device: PW-3, iPad, Android phone
whitespace eaten by pretty print

I have some text mimicking a report; needed to have text line up on several lines, since HTML doesnt have tabstops, only way I could think was to use a monospaced font.

so did this CSS:

Code:
.memo {
margin-top:2em;
margin-left: 2em;
text-indent:0em;
font-family: monospace;
font-size: .9em;
white-space: pre-wrap;
}
and text like:
Code:
<p class="memo">
AGENTS:
 Section Leader: Com Varlt, MW 69321
 Crew:           Horman Tilis MW 69345
                 Fal Korf AW 70958
                 Pague Lo Sig AW 70889 

PROGRESS TO DATE:
  Traced subject—Kmoat Vo Pranj—to Levels 415-426 inclusive.
</p>
And that worked perfectly. Looks as it does above with "CODE" tags.
But when I saved it, clean source collapses it to:

Code:
<p class="memo">AGENTS: Section Leader: Com Varlt, MW 69321 Crew: Horman Tilis MW 69345 Fal Korf AW 70958 Pague Lo Sig AW 70889 PROGRESS TO DATE: Traced subject—Kmoat Vo Pranj—to Levels 415-426 inclusive.</p>
Destroying the layout.

Eventually I tried using pre instead of p : <pre class="memo">
And that was safe from being reformatted.

I don't know if the pretty print can be made to check if whitespace should be preserved, but at least there is a work-around.

One reason I used p tags first was I was going to make AZW, and according to Amazon:
https://kdp.amazon.com/en_US/help/topic/A1JPUWCSD6F59O
Kindle does not support either <pre> or <tt>

But when I tried it, actually it does.
If I use Kindlegen on the <pre> coded text, Looking at the result in Calibre's Inspect, the AZW is identical: <pre class="memo">, while the KF7 has become <tt>.

Last edited by AlanHK; 08-17-2017 at 01:59 PM.
AlanHK is offline   Reply With Quote