Community
    • Login

    Is it possible to add styles and fonts in txt files, like in Ms Word (docx)?

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    5 Posts 5 Posters 1.6k 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.
    • Hellena CrainicuH
      Hellena Crainicu
      last edited by

      hello, happy new year.

      I want to make a code in Python, but before that I want to know if it is possible to add styles and fonts in txt files, like in Ms Word (docx)?

      For example, I want to add BOLD, ITALIC and Color, but without formatting the text in html or another language. I mean, I don’t want to add tags like <strong> </strong> or <i> , etc

      Alan KilbornA supasillyassS CoisesC 3 Replies Last reply Reply Quote 0
      • Alan KilbornA
        Alan Kilborn @Hellena Crainicu
        last edited by

        @Hellena-Crainicu

        See HERE.

        1 Reply Last reply Reply Quote 3
        • supasillyassS
          supasillyass @Hellena Crainicu
          last edited by

          @Hellena-Crainicu DOCX does add tags (XML—the “X” in DOCX is for XML), but it’s hidden from the end user. Maybe a Markdown editor would suit your needs better.

          1 Reply Last reply Reply Quote 2
          • Mark OlsonM
            Mark Olson
            last edited by

            In my experience, Markdown renderers are… inconsistent at handling coloring of text (e.g., GitHub’s Markdown renderer doesn’t seem to support it even though VSCode’s does).

            That said, Markdown is quite easy to work with.

            1 Reply Last reply Reply Quote 0
            • CoisesC
              Coises @Hellena Crainicu
              last edited by

              @Hellena-Crainicu said in Is it possible to add styles and fonts in txt files, like in Ms Word (docx)?:

              I want to know if it is possible to add styles and fonts in txt files, like in Ms Word (docx)?

              For example, I want to add BOLD, ITALIC and Color, but without formatting the text in html or another language. I mean, I don’t want to add tags like <strong> </strong> or <i> , etc

              Short answer: It is not possible.

              Longer answer:

              It is not possible, because what you would have would no longer be a plain text file. Plain text has no notion of formatting aside from a few control characters which have (relatively) agreed-upon meanings: mainly tabs and end-of-line characters. Aside from that, it’s just a stream of character codes, interpreted according to either a code page or a Unicode standard.

              (In principle, I suppose someone could define a “code page” that included control characters for color, bold, italic, font assignment and so on. No existing software would know how to interpret it, though, and most people would agree it was no longer “plain text.”)

              Files like docx have tags (or the equivalent of tags); it’s just that the program which displays and edits them interprets those tags and hides them so you see their effect instead of the tags themselves. It gives a WYSIWYG (what you see is what you get) experience, but that’s due to the editing application, not the file type.

              Contrast this with html, which you usually edit in a text editor but display in a web browser. You’re aware of the tags when you create html, but viewers don’t see them or think about them.

              Consider the form in which we type these posts. We can have italics and bold in our posts, but that’s because the forum software displays the text that way based on a simple form of tags (asterisks for italic, doubled asterisks for bold, square brackets followed by parentheses for links, and so on). We edit in plain text.

              So, no software will display colors, bold, italics and the like without some sort of tags. The tags can be so simple (markdown, like these posts) that you can easily read and write them in a text editor, or so deeply encoded (pdf) that they can neither be displayed nor edited without software specifically designed for them. But they will have to be there.

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