Multiple lines merging when saving as HTML - Want to stop that
-
Hi,
So, I’m using Notepad++ to combine separate old notepad (.txt) and HTML chat logs into one large file. I’ve done this before, I know how to use the combine feature.
What issue I’m running into is, for some reason, when I save the resulting merged file as an HTML document, all of the old notepad files are mashed into a single line despite showing as single lines in the program. If I export to HTML, it doesnt do that but its hard on my eyes. The weird thing is I have an old, OLD file that has both .txt files and HTML files merged, and didnt have the issue of it mashing all the .txt file into one line.
I have tried CTRL+I, it didnt do anything on save. I have tried saving just the .txt files on their own as HTML, still mashes them up.
Is there a setting somewhere, a script… something… anything I can do to stop it from mashing up the .txt files? Please, and thank you for any help!
-
My initial thought is that you have different types of line endings. For a windows file it is “carriage return” AND “line feed” together. If you have Notepad++ display (View, Show Symbol, End of lines) them you will see CR and LF in inverted colour. These are “control codes”.
If you look at Edit, EOL conversion you will see that you can convert from Windows to Unix and Mac style end of lines.
HTML may have different EOL type to the TXT content hence the merge causes the issue.
Terry
-
@Terry-R Everything says CR LF, both the .txt file and the HTML.
I found a sortve work around, I exported to HTML and then just tweaked the code that was spat out until it looked how I wanted it to, copied and pasted into the merged file. The merging stopped and everything is broken into proper lines. It works, but still confused on why it merged in the first place.
-
still confused on why it merged in the first place.
That’s the way HTML works: if you put in text in paragraphs (or leave it “unwrapped”, just inside the
<html>
tags with no wrapping paragraphs or divs or anything), then the browser collapses all the whitespace (including spaces, tabs, and newlines) into single space characters. If you want text in an HTML document to honor the formatting of a block of text, then you need to wrap it in<pre>...</pre>
, or you need to set a CSSwhite-space
style on your specific block or class that, where a value ofpre
would preserve all the spaces and newlines, orpre-line
would collapse multiple horizontal whitespace (spaces and tabs) down to one space, but still preserve newlines.This is a fundamental concept of HTML, and has nothing to do with Notepad++ itself. (You can tell this because you would have gotten the same results if you were using Windows
notepad.exe
or any other text editor to edit the text into the HTML file.) If you need further help with HTML-specific questions, you will need to find a forum dedicated to HTML, or a stack overflowing with all sorts of experts – the focus of this forum is on Notepad++ itself, not on the particulars HTML (or whatever else you might be typing). -
@PeterJones it wasn’t wrapped with html code. I never said it was. And in my original post I said it didn’t do this to a similar combo of files previously, which is why I was confused.
I’m saving it as an HTML file so it opens in a browser for easier reading. I am aware that doing so produces html coding, but as I said… it hadn’t done that before when combining the files and I was originally asking if there was something I could do in Notepad++ that would prevent the txt file line merging, such as a setting or script.