Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Behind the Scenes
  3. Qt.io webservices
  4. How to write multi-line code blocks?

How to write multi-line code blocks?

Scheduled Pinned Locked Moved Solved Qt.io webservices
9 Posts 2 Posters 3.4k Views
  • 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.
  • A Offline
    A Offline
    Asperamanca
    wrote on last edited by SGaist
    #1

    I would like to write a multi-line code block. However, my line breaks are replaced by blanks. I use the backticks (inverted apostrophe) to start and end code blocks. How the description in the markdown documentation is related to this forum is a mystery to me:

    To produce a code block in Markdown, simply indent every line of the block by at least 4 spaces or 1 tab.

    The following text always starts with 4 spaces:

    This is a text of markdown
    Line starts with 4 spaces and should be displayed as a code block

    When starting and ending a block with a single backtick, I get:
    First line of code block second line of test code block

    Test using two backticks each at the start and end of the code block:
    First line of code block second line of test code block

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      For "complex code block" it's three back-ticks e.g.

      First line
      Second line
      etc.
      

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Asperamanca
        wrote on last edited by
        #3
        second line of code```
        
        Hmmm...doesn't work.
        A 1 Reply Last reply
        0
        • A Asperamanca
          second line of code```
          
          Hmmm...doesn't work.
          A Offline
          A Offline
          Asperamanca
          wrote on last edited by
          #4

          Another test:

          Code block line 1
          Code block line 2
          #include something
          

          Ah, so I need to have three backticks and a line break. Thanks for the pointer.

          1 Reply Last reply
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by SGaist
            #5

            Because you're missing line breaks.
            It's:

            three back-ticks, new-line,
            your multi-line code, new-line,
            three back-ticks, new-line

            Your text etc.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            A 1 Reply Last reply
            1
            • SGaistS SGaist

              Because you're missing line breaks.
              It's:

              three back-ticks, new-line,
              your multi-line code, new-line,
              three back-ticks, new-line

              Your text etc.

              A Offline
              A Offline
              Asperamanca
              wrote on last edited by
              #6

              @SGaist
              I just wonder why they didn't write that in the markdown documentation...

              Thanks!

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You're welcome !

                By the way, there's also the new "mark as solved" technique since the latest update of the forum. You don't need to update the thread title anymore, now you can use the "Topic Tool" button thus keeping the thread slug clean :)

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                A 1 Reply Last reply
                0
                • SGaistS SGaist

                  You're welcome !

                  By the way, there's also the new "mark as solved" technique since the latest update of the forum. You don't need to update the thread title anymore, now you can use the "Topic Tool" button thus keeping the thread slug clean :)

                  A Offline
                  A Offline
                  Asperamanca
                  wrote on last edited by
                  #8

                  @SGaist
                  My topic tools show "Delete" and "Edit", nothing more.

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Strange…

                    I've updated it for you

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved