Github Markdown Syntax

broken image


Markdown is a lightweight and easy-to-use syntax for styling all forms of writing on the GitHub platform.

  1. Github Markdown Syntax Cheat
  2. Github Markdown Syntax Highlighting Languages
  3. Github Readme Markdown Syntax
  4. Github Markdown Syntax Highlighting
  5. Xast— Extensible Abstract Syntax Tree

What you will learn:

  • How the Markdown format makes styled collaborative editing easy
  • How Markdown differs from traditional formatting approaches
  • How to use Markdown to format text
  • How to leverage GitHub's automatic Markdown rendering
  • How to apply GitHub's unique Markdown extensions

Markdown is a lightweight markup language for creating formatted text using a plain-text editor. John Gruber and Aaron Swartz created Markdown in 2004 as a markup language that is appealing to human readers in its source code form. Markdown is widely used in blogging, instant messaging, online forums, collaborative software, documentation pages, and readme files. Dec 25, 2019 GitHub Image Markdown Syntax!Alt text(Image URL) It starts with an exclamation mark, then square brackets where you can specify the alt text for SEO and then the image file URL in parenthesis. Add an existing Image to README.md file. In the following example, we will add an image file that already exists in our repository. Nov 21, 2019 Github's flavor of markdown allows you to create some complex tables, but in many cases, it's best to keep it simple and easy to read. Markdown native syntax, such as bold or inline code blocks, is easy to add to tables, and HTML tags can be used as well.

What is Markdown?

Markdown is a way to style text on the web. You control the display of the document; formatting words as bold or italic, adding images, and creating lists are just a few of the things we can do with Markdown. Mostly, Markdown is just regular text with a few non-alphabetic characters thrown in, like # or *.

You can use Markdown most places around GitHub:

  • Comments in Issues and Pull Requests
  • Files with the .md or .markdown extension

For more information, see 'Writing on GitHub' in the GitHub Help.

Examples

It's very easy to make some words bold and other words italic with Markdown. You can even link to Google!

Syntax guide

Here's an overview of Markdown syntax that you can use anywhere on GitHub.com or in your own text files.

Headers

Github Markdown Syntax

Emphasis

Lists

Unordered

Github Markdown Syntax Cheat

Ordered

Images

Links

Blockquotes

Inline code

GitHub Flavored Markdown

GitHub.com uses its own version of the Markdown syntax that provides an additional set of useful features, many of which make it easier to work with content on GitHub.com.

Note that some features of GitHub Flavored Markdown are only available in the descriptions and comments of Issues and Pull Requests. These include @mentions as well as references to SHA-1 hashes, Issues, and Pull Requests. Task Lists are also available in Gist comments and in Gist Markdown files.

Syntax highlighting

Here's an example of how you can use syntax highlighting with GitHub Flavored Markdown:

You can also simply indent your code by four spaces:

Here's an example of Python code without syntax highlighting:

Task Lists

If you include a task list in the first comment of an Issue, you will get a handy progress indicator in your issue list. It also works in Pull Requests!

Highlighting

Emphasis

Lists

Unordered

Github Markdown Syntax Cheat

Ordered

Images

Links

Blockquotes

Inline code

GitHub Flavored Markdown

GitHub.com uses its own version of the Markdown syntax that provides an additional set of useful features, many of which make it easier to work with content on GitHub.com.

Note that some features of GitHub Flavored Markdown are only available in the descriptions and comments of Issues and Pull Requests. These include @mentions as well as references to SHA-1 hashes, Issues, and Pull Requests. Task Lists are also available in Gist comments and in Gist Markdown files.

Syntax highlighting

Here's an example of how you can use syntax highlighting with GitHub Flavored Markdown:

You can also simply indent your code by four spaces:

Here's an example of Python code without syntax highlighting:

Task Lists

If you include a task list in the first comment of an Issue, you will get a handy progress indicator in your issue list. It also works in Pull Requests!

Tables

You can create tables by assembling a list of words and dividing them with hyphens - (for the first row), and then separating each column with a pipe |:

Would become:

First HeaderSecond Header
Content from cell 1Content from cell 2
Content in the first columnContent in the second column

SHA references

Any reference to a commit's SHA-1 hash will be automatically converted into a link to that commit on GitHub.

Issue references within a repository

Any number that refers to an Issue or Pull Request will be automatically converted into a link.

Username @mentions

Typing an @ symbol, followed by a username, will notify that person to come and view the comment. This is called an '@mention', because you're mentioning the individual. You can also @mention teams within an organization.

Automatic linking for URLs

Any URL (like http://www.github.com/) will be automatically converted into a clickable link.

Strikethrough

Any word wrapped with two tildes (like ~~this~~) will appear crossed out.

Emoji

GitHub supports emoji!

To see a list of every image we support, check out the Emoji Cheat Sheet.

Last updated Jan 15, 2014

If you frequently use GitHub, then you know any directory with a Readme markdown file in it automagically displays it, making it a convenient place to let visitors know helpful information about a project... about setting it up, how to contact the author, where to turn for help, etc.

But there are some little tricks you can take advantage of too, which most people wouldn't know about. Here's my top 5 (see them in action on GitHub too). One more thing before we dig in... these tricks work in any markdown file, including new Issues, Pull Requests, and in the Wiki.

Create Reusable Links

The normal way to create a link using markdown is this:

But what if you have a long Readme file or wiki page, and the same link is used in multiple places?

To make updates easier (not to mention, keeping things DRY), you can create a list of links at the bottom of the file, and reference them in multiple places by name. The list won't render on the page, so visitors won't even know it's there, and it makes one convenient place to do updates.

You can use the same technique with images too!

Add Hidden Comments

If you want to add a comment to your markdown file on GitHub - something to note but that shouldn't render when the page is viewed - here's a little hack that takes advantage of the same 'link' syntax used in the previous example. (The double-slash is the link id, the hash is the URL, and the comment in parenthesis is the link title.)

You can add these to anything that accepts a link label, wherever you find them useful - maybe in a Pull Request template to give contributors instructions that won't render when the PR is submitted, or near a confusing part of a wiki page so the next person who tries to edit it sees a brief explanation before submitting their change.

Quickly Insert Images

Although the Wiki has a button that lets you upload images to it, and the Issues page lets you drag and drop images, the interface in the main repo has no such button. You can (ab)use the Issues page though, to avoid the pain of having to upload images into your repo... which keeps the size of your repo down too.

Github Markdown Syntax Highlighting Languages

Just create a new issue and drag your image into the editor pane. It'll upload it and generate a unique URL for you. Don't even bother saving the issue... just copy the markdown it generates and drop it into your Readme.

The only caveat is that it's not under source control, but I can't really see that being an issue. I've never had a need to keep revisions of images, but if you do then this may not be the tip for you.

Resize Images

But what if you get your image inserted and it's obnoxiously huge? You can't resize an image using markdown.

Github Readme Markdown Syntax

Well, GitHub doesn't support all HTML tags - for example the style tag - but it does support a subset. You can check out their filter for yourself, but here's the list of tags they support:

The img tag is in the list, so just switch to standard HTML to resize it. It even supports other attributes, allowing things like word wrapping.

Add Some Color to Your Life

You can't color your text using markdown, but you can use an image placeholder service like placeholder.com to create some useful effects that make sections of your Readme file, etc stand out.

The above markdown is rendered like this:

What else?

Github Markdown Syntax Highlighting

I was hoping to find some trick for generating a table of contents, but alas after years of ongoing discussion... nada. There are other solutions like github-markdown-toc and the Github Markdown Outline chrome extension, but nothing native. Who knows though... maybe since Microsoft bought GitHub and is actively adding features, we'll see more features built-in.

Xast— Extensible Abstract Syntax Tree

If you find any cool tricks of your own, I'd love to know about them! Share below...





broken image