2

I was trying to write some markdown code using markdown in github, but it always leads to some strange format, is there any idea about this issue?

For example: I wanna

# header1 #

but it always display as real header

header1

and it also happens to code block, i wanna

```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
```

but I got

require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html

that is so confusing. Is there a good way to write it in markdown?

1
  • 2
    Your content is hilariously messed up... You know, asking for Markdown help on a site that uses Markdown in completely broken Markdown. Commented Sep 15, 2014 at 6:53

3 Answers 3

3

You can escape characters like # or _ in Markdown with a backslash. For example:

\# header 1

If you look at the source code of this post, you'll actually notice that I had to escape the escape character so that the backslash would display in the answer, but a single backslash is all you need to have a special character rendered literally.

You can also use pre-formatted code blocks by indenting your text 4 spaces. For example:

    # header 1

Again,if you look at the source you'll see I actually indented 8 spaces so that the code block shows 4 space characters. However, indenting by 4 spaces is generally all you need to display your Markdown source, unless you're trying to be very meta with your rendering.

Sign up to request clarification or add additional context in comments.

Comments

2

Another tip is simply to wrap your markdown code in <pre></pre> (that avoids the need to add 4 spaces at the beginning of each line)

# tilte
```` ruby
code
````

Comments

0

You can use backslash to escape Markdown syntax. Just put it in the beginning of the line. Just try Markdown editor online and you will simply see how it works.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.