Tim Reilly
Tim Reilly

Reputation: 143

How to paste Raw HTML into a README.md using markdown on GitHub?

Editing a README.md for a git repository. But I want to embed raw HTML into the the readme. I'm using Markdown, which is an excellent tool. Yet, the code just keeps showing up as rendered HTML.

How do I keep it Raw? And formatted like code?

Here it is if you're curious:

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Welcome</title>
</head>
<body>
    <h1>Django Site</h1>
    <hr />
    <p>Thanks for visiting.</p>
</body>
</html>

The heck? It works here.

Upvotes: 0

Views: 5525

Answers (3)

J A.
J A.

Reputation: 1346

You can use this to add html code to the readme file.

```html
<!-- sample html code  -->
<section id="produts"></section>```

Upvotes: 1

OCEAN OF ANYTHING
OCEAN OF ANYTHING

Reputation: 1

Use "`" This Sign To Use Raw Code Snippets

    <!DOCTYPE html>

    <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>Welcome</title>
    </head>
    <body>
        <h1>Django Site</h1>
        <hr />
        <p>Thanks for visiting.</p>
    </body>
    </html>

It Will Allow A User To Copy Your Code Directly From Your README.md File In Github By Just Pressing A Button !!!

Upvotes: 0

I suppose you are on GitHub.

GitHub only allows certain HTML elements and attributes inside their markdown: all others are stripped to prevent XSS and defacing.

And of course, <body> is one of the forbidden tags as it would make the HTML invalid if present (a body inside a body)

This is documented at: https://help.github.com/articles/github-flavored-markdown/#html

Upvotes: 3

Related Questions