Community
    • Login

    Multiple lines merging when saving as HTML - Want to stop that

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    7 Posts 4 Posters 152 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Neko_KaiohN
      Neko_Kaioh
      last edited by

      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!

      Terry RT pbarneyP 2 Replies Last reply Reply Quote 0
      • Terry RT
        Terry R @Neko_Kaioh
        last edited by

        @Neko_Kaioh

        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

        Neko_KaiohN 1 Reply Last reply Reply Quote 0
        • Neko_KaiohN
          Neko_Kaioh @Terry R
          last edited by

          @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.

          PeterJonesP 1 Reply Last reply Reply Quote 0
          • PeterJonesP
            PeterJones @Neko_Kaioh
            last edited by

            @Neko_Kaioh ,

            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 CSS white-space style on your specific block or class that, where a value of pre would preserve all the spaces and newlines, or pre-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).

            Neko_KaiohN 1 Reply Last reply Reply Quote 1
            • Neko_KaiohN
              Neko_Kaioh @PeterJones
              last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • pbarneyP
                pbarney @Neko_Kaioh
                last edited by

                @Neko_Kaioh Not sure if this is what you mean, but if you have a .txt file put into an .html file, the browser will just display it all as one line, because HTML needs to know when a line ends (technically called “block content”) and it doesn’t care about linebreaks.

                There are two ways you could approach this:

                1. Add a <br> element after every line in your .txt file (either before or after combining it).
                2. EASIER: wrap your .txt. file content in a preformatted text block with the <pre> element, like so:
                <pre>
                Line 1
                Line 2
                Line 3
                </pre>
                

                The HTML <pre> element informs the browser that the content inside of it is already pre-formatted, so just show it as it is.

                Neko_KaiohN 1 Reply Last reply Reply Quote 0
                • Neko_KaiohN
                  Neko_Kaioh @pbarney
                  last edited by

                  @pbarney Finally, some actual assistance on this forum. Thank you!

                  The code I mentioned that was spat out included the <pre>, just in a different format. So I guess my fiddling was on the right path. I appreciate you taking the time to reply though, it gives me more info on what that code is/does.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post
                  The Community of users of the Notepad++ text editor.
                  Powered by NodeBB | Contributors