Community
    • Login

    How to Markdown code on this forum?

    Scheduled Pinned Locked Moved General Discussion
    12 Posts 8 Posters 29.4k 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.
    • moon6969M
      moon6969
      last edited by

      I’m struggling to format code sections when posting to this forum.

      The help says:

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

      The next 2 lines start with 8 and 12 spaces respectively:
      if not “mnFixedFindFilename” in globals()
      globals()[“mnFixedFindFilename”] = notepad.getCurrentFilename())
      but the preview window steals my spaces and formats as normal…
      Imgur

      How do I get the fancy black code blocks!?

      1 Reply Last reply Reply Quote 1
      • MaDillM
        MaDill
        last edited by

        add an empty line after “…respectively:”

        The next 2 lines start with 8 and 12 spaces respectively:

            if not “mnFixedFindFilename” in globals()
                globals()[“mnFixedFindFilename”] = notepad.getCurrentFilename())
        

        but the preview window steals my spaces and formats as normal…

        1 Reply Last reply Reply Quote 3
        • moon6969M
          moon6969
          last edited by

          Doh! Undone by my obsessive dislike of automatic line/paragraph spacing!!

          Thanks MaDill
          
          Scott SumnerS 1 Reply Last reply Reply Quote 1
          • Scott SumnerS
            Scott Sumner @moon6969
            last edited by PeterJones

            I have a cheatsheet I’ve assembled for markdown specific to this forum; it isn’t all-encompassing but maybe it is of some use:

            -------------------------------------------------------------------------------

            \----------------- –> -----------------
            (I like to use this one as a separator; like drawing a horizontal line; note the leading \ is important; maybe there is a better way…)

            -------------------------------------------------------------------------------

            **bold** --> bold

            -------------------------------------------------------------------------------

            *italics* --> italics

            -------------------------------------------------------------------------------

            ***bold_italics*** --> bold_italics

            -------------------------------------------------------------------------------

            `red_with_grey_background` --> red_with_grey_background
            (best for presenting regular expressions since everything between back-ticks (grave accents) is treated verbatim)

            -------------------------------------------------------------------------------

            ~~strikeout~~ --> strikeout

            -------------------------------------------------------------------------------

            # heading1 big ->

            heading1 big

            (space between # and “h” in this example is important; # must start the line)

            -------------------------------------------------------------------------------

            ## heading2 ->

            heading2

            (space between # and “h” in this example is important; # must start the line)

            -------------------------------------------------------------------------------

            ### heading3 ->

            heading3

            (space between # and “h” in this example is important; # must start the line)

            -------------------------------------------------------------------------------

            #### heading4 ->

            heading4

            (space between # and “h” in this example is important; # must start the line)

            -------------------------------------------------------------------------------

            bullet-point lists:
            * bullet1
            * bullet2
            * bullet3
            –>

            • bullet1
            • bullet2
            • bullet3

            (note: space after * is important!)

            -------------------------------------------------------------------------------

            numbered lists:
            1) one
            2) two
            3) three
            –>

            1. one
            2. two
            3. three

            (note: space after ) is important!)

            -------------------------------------------------------------------------------

            a code block is indented with 4 spaces and must be preceded by a blank line:

            I really have 4 spaces before me
            

            -------------------------------------------------------------------------------

            quote another poster:

            >YOU said this

            And now I’m replying to it
            (note: blank line between > line and the reply is important)
            –>

            YOU said this

            And now I’m replying to it

            -------------------------------------------------------------------------------

            links:

            Very simple direct link to https://www.google.com
            ->
            Very simple direct link to https://www.google.com

            This is a simple [here](https://www.google.com) link
            –>
            This is a simple here link

            This is a simple [here](https://www.google.com “go Google!”) link with custom hover pop-up text
            ->
            This is a simple here link with custom hover pop-up text

            -------------------------------------------------------------------------------

            images (not links to images) embedded in the post:

            ![ ](http://i.imgur.com/QTHZysa.png)
            ->

            2024 moderator update: see our more-recent FAQ: Formatting Forum Posts: embedding images from imgur no longer works reliably; but unlike in 2017, you can just paste your image directly in the Forum post without using an external host, anyway.
            -------------------------------------------------------------------------------

            V S RawatV 1 Reply Last reply Reply Quote 15
            • glennfromiowaG
              glennfromiowa
              last edited by

              @Scott_Sumner Thank you for posting this! This is the best guide to markdown I’ve ever seen - much better than the forum-provided guide. It should be posted somewhere accessible! Too bad we don’t have an active wiki anymore.

              1 Reply Last reply Reply Quote 1
              • guy038G
                guy038
                last edited by

                Hello @scott-sumner,

                I totally agree with @glennfromiowa. Explanations, about links, that I didn’t dare to practice yet, are very clear ! Many thanks, Scott, for this neat summary ;-))

                Cheers,

                guy038

                1 Reply Last reply Reply Quote 2
                • Scott SumnerS
                  Scott Sumner
                  last edited by Scott Sumner

                  Ahem. Well, I’m somewhat embarrassed that the posting of mine that has generated the most interest over the past couple of years is about…markdown syntax. :-D

                  Here’s an addition to the above “cheatsheet”, because I recently messed up trying to embed a “video” in a posting even thought I’ve done it before (so I re-figured out the right way to do it):

                  -------------------

                  VIDEOS (not links-to-videos) EMBEDDED IN THE POST:

                  Note: These are actually animated-GIF files, not true video files
                  • Create screen-capture’d video file (e.g., .MP4 with SnagIt…my preference…YMMV) showing what you want the readers of your post to see
                  • Use online video to animated-GIF converter (e.g., https://ezgif.com/video-to-gif) to convert video (e.g. .MP4) to .GIF
                  • Save resulting .GIF file locally (temporarily)
                  • Upload .GIF file to image-hosting site (e.g., http://imgur.com/)
                  • Get “markdown” link to uploaded .GIF from image-hosting site to clipboard; example: [Imgur](http://i.imgur.com/UPYeN9e.gifv)
                  • Add ! out front, optionally delete Imgur between the [ and the ], and change gifv to gif; example: ![](http://i.imgur.com/UPYeN9e.gif)
                  • Paste that text into a new Notepad++ Community site posting, and you should have a live-action “video” in the preview pane of your posting, and, of course, when it truly gets posted!

                  -------------------

                  The embedded “video” from the above example (courtesy of this thread–where I originally screwed up the embedding and got a link instead):

                  1 Reply Last reply Reply Quote 3
                  • MAPJe71M
                    MAPJe71
                    last edited by MAPJe71

                    Alternative for capturing GIF: ScreenToGif

                    1 Reply Last reply Reply Quote 3
                    • PeterJonesP
                      PeterJones
                      last edited by PeterJones

                      I just saw that another trick that @Scott-Sumner taught us in some other post isn’t in his summary above.

                      For quoting a file, there are two methods. The first, as others (including Scott) showed above, is to indent all the lines of the file by 4 spaces – and having a blank line before and after. This will create the black box, which can actually do syntax highlighting:

                      \-----
                      normal text followed by blank line
                      
                          # this block indented four spaces
                          x = os.getenv('TEMP')
                      
                      \-----
                      

                      will be formatted as
                      -----
                      normal text followed by blank line

                      # this block indented four spaces
                      x = os.getenv('TEMP')
                      

                      -----

                      But you’ll notice that my example code doesn’t have the black box or code formatting. I got that through what I call the “```z trick”: prefix your file by a blank line, followed by ```z by itself on a line, followed by ``` by itself and another blank, like

                      \----- visual separation for my example
                      normal text before blank line
                      
                      ```z
                      text that doesn't have to be indented
                      ```
                      
                      more normal text, after blank line
                      \----- visual separation for my example
                      

                      To nest them (like I did here), you can use balanced groups of more ```` ticks, followed by a different letter, like:

                      \----
                      
                      ````x
                      
                      ```z
                      blah
                      ```
                      
                      ````
                      
                      \----
                      

                      Hope this helps clarify.

                      1 Reply Last reply Reply Quote 1
                      • PeterJonesP
                        PeterJones
                        last edited by

                        Looks like the ```z notation doesn’t need blank lines surrounding:

                        \----
                        ````x
                        ```z
                        blah
                        ```
                        ````
                        \----
                        

                        renders as

                        ----

                        ```z
                        blah
                        ```
                        

                        ----

                        PeterJonesP 1 Reply Last reply Reply Quote 0
                        • V S RawatV
                          V S Rawat @Scott Sumner
                          last edited by

                          @Scott-Sumner

                          Great help.

                          I was always putting something wrong that was destroying the presented version.

                          now I am wiser with your list.

                          Maybe this site should give a link of your post in the message compose window.

                          Thanks a gig.

                          1 Reply Last reply Reply Quote 0
                          • PeterJonesP PeterJones referenced this topic on
                          • PeterJonesP
                            PeterJones @PeterJones
                            last edited by

                            For Future Readers

                            The hints in this discussion are mostly still good (other than suggesting imgur, as the moderator note clarifies); however, a few years after this discussion, we added a FAQ: Formatting Forum Posts which should be used as the canonical/official guide for using Markdown on this Forum; the benefit of the FAQ is that it can and will be kept up-to-date, which is harder to do for these older discussions.

                            1 Reply Last reply Reply Quote 2
                            • PeterJonesP PeterJones locked this topic on
                            • First post
                              Last post
                            The Community of users of the Notepad++ text editor.
                            Powered by NodeBB | Contributors