Search code examples
htmlgithubmarkdown

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.


Solution

  • 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