markdown

Why does markdown need an escape for \. to show a slash dot


Why does markdown need an escape \ before the \.path to render this name\of\.path correctly. Without the escape it renders name\of.path

i.e. it must be coded as name\of\\.path to get name\of\.path


Solution

  • Markdown uses backslash as an escape character:

    Markdown allows you to use backslash escapes to generate literal characters which would otherwise have special meaning in Markdown’s formatting syntax. For example, if you wanted to surround a word with literal asterisks (instead of an HTML <em> tag), you can use backslashes before the asterisks, like this:

    \*literal asterisks\*
    

    Markdown provides backslash escapes for the following characters:

    \   backslash
    `   backtick
    *  asterisk
    _   underscore
    {}  curly braces
    []  square brackets
    ()  parentheses
    #   hash mark
    +   plus sign
    -   minus sign (hyphen)
    .   dot
    !   exclamation mark
    

    Note that the period ("dot") is included in this list. Therefore, a single backslash preceding a period simply escapes the period. To escape the backslash itself (and therefore display it literally) it must be escaped with a second backslash.