• Home »
  • Insights »
  • Include Underscores While Using Markdown Without Them Being Bold Or Italic Indicators For Text

Include Underscores While Using Markdown Without Them Being Bold Or Italic Indicators For Text

I am fairly new to Markdown and have really just been becoming more familiar with Markdown while posting here on Question Defense’s [Engage][1] site. So far I really like Markdown and have been impressed with how user friendly it becomes as you learn the Markdown tricks as I call them including asterisks or underscores for bolding or italicizing, brackets for links/URLs, and numbered lists simply using 1., 2., 3., etc. While the Markdown learning curve has been fairly steep for me
An issue I ran into on my last post was the fact that I was posting some PayPal variables that included underscores within the variable.

I am fairly new to Markdown which is a lightweight markup language. I have really just started becoming more familiar with Markdown while posting or replying to articles in the Question Defense Engage section. Markdown is the markup language used on Engage to format the posted questions, posted responses, comments, and pretty much anywhere that content data is entered. So far I really like Markdown and have been impressed with how user friendly it becomes as you learn the Markdown tricks as I call them including asterisks or underscores for bolding or italicizing, brackets for links/URLs, and numbered lists simply using 1., 2., 3., etc. While the Markdown learning curve has been fairly steep for me the more I use it the more Markdown is sticking with me.

Underscore Display Issue Using The Markup Language Called Markdown:

The issue I ran into on one of my Engage posts was the fact that I was posting content that included underscores. The content posted included PayPal variables that have underscores within them. So while this would normally not be an issue when posting this sort of content in say an HTML page it was an issue using Markdown because Markdown assumed I wanted the text following the underscore to be bold or italic. After a little research I located an easy resolution using backslashes. Below are numerous examples displaying the content formatting error when posting PayPal variables on a page that uses the markup language Markdown for formatting. The PayPal variables posted were parent_txn_id and txn_id so look below to see the original attempt and what was done to work around the Markdown underscore problem.

Original Content Using Multiple Underscores Before Markdown Processing:

txn_id
parent_txn_id

Display Of Content Including Underscores After Markdown Processing:

txn_id
parenttxnid

There are two things to note from the output. Notice how the output of the first item (txn_id) looks fine because it only includes one underscore however the output of the second item (parent_txn_id) doesn’t display any underscores. The second item displays the text in between the underscores as italic which is a feature of Markdown the lightweight markup language. The purpose is to be able to easily format text as it is being entered into a web interface and since you would rarely have text with an underscore on each end without spaces this makes sense. To get around this issue when posting items such as PayPal variables or possibly other types of variables that may include multiple underscores you can simply use backslashes as displayed in the below examples.

Content Display With Backslashes Added Before Markdown Processing:

txn\_id
parent\_txn\_id

Content Display With Backslashes Added After Markdown Processing:

txn_id
parent_txn_id

As you can see above when using the backslashes before the underscores the PayPal variables now display as intended. There are numerous characters listed below that can use a backslash before them to skip Markdown formatting. Markdown calls this process backslash escapes which will again skip the Markdown formatting to display a specific character.

Characters That Can Use Backslashes To Skip Markdown Formatting:

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

Using Backslashes For Character Escaping In Markdown:

Sometimes using the backslashes can get tricky but there is a definite process to the madness. It can be odd is when you need to actually display a backslash (\) in front of say an underscore (_). In the case of the PayPal variable being parent\_txn\_id where you actually wanted the backslashes to display you would have to post parent\\\_txn\\\_id into Markdown. If you only posted two backslashes then the “txn” portion of the PayPal variable would be italic again.

Python Web Development with Django (Paperback)

By (author): Jeff Forcier, Paul Bissex, Wesley Chun


List Price: $49.99 USD
New From: $21.59 USD In Stock
Used from: $8.16 USD In Stock


List Price: $179.00 USD
New From: $104.93 USD In Stock
Used from: $104.98 USD In Stock

Share