rookie
rookie

Reputation: 1208

preserve .txt formatting when changing to .html

I have a .txt file that has certain formatting. It's not too complicated:

Text heading
----

Point 1

Point 2

Result:
---

This file goes onto the server and gets displayed to a user. But when it goes there, it automatically changes the filetype to html(when originally it was just .txt) and the formatting is all gone. It becomes like

Text Heading ---- Point 1 Point 2 Result: ----- 

It basically gets encapsulated in a <p></p> Is there a way to preserve the basic formatting, or do I have to manually enclose it within tags to get the formatting right

Upvotes: 1

Views: 516

Answers (1)

nem035
nem035

Reputation: 35501

Either wrap your content in a <pre> tag or use some css to preserve whitespace:

p {
  display: block;
  white-space: pre;
}

Upvotes: 2

Related Questions