How to Markdown code on this forum?
-
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…
How do I get the fancy black code blocks!?
-
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…
-
Doh! Undone by my obsessive dislike of automatic line/paragraph spacing!!
Thanks MaDill
-
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
–>- one
- two
- 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.comThis is a simple [here](https://www.google.com) link
–>
This is a simple here linkThis 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)
->
-------------------------------------------------------------------------------
-
@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.
-
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
-
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 deleteImgur
between the[
and the]
, and changegifv
togif
; 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):
-
Alternative for capturing GIF: ScreenToGif
-
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.
-
Looks like the ```z notation doesn’t need blank lines surrounding:
\---- ````x ```z blah ``` ```` \----
renders as
----
```z blah ```
----
-
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.
-