Syntax guidance for Markdown files, widgets, and pull request comments

Last Update: 5/1/2017

Team Services | TFS 2017 | TFS 2015

Having the right guidance at the right time is critical to success. To support your team or contributors to your project, use markdown to add rich formatting, tables, and images to your project pages, readme files, dashboards, and pull request comments.

You can provide guidance to your team in these places using markdown:

In this topic you'll find some basic Markdown syntax guidance. You can use both common Markdown conventions and Github-flavored extensions.

Headers

Structure your comments using headers. Headers segment longer comments, making them easier to read.

Start a line with a hash character # to set a heading. Organize your remarks with subheadings by starting a line with additional hash characters, for example ####. Up to six levels of headings are supported.

Example:

# This is an H1 header
## This is an H2 header
### This is an H3 header
#### This is an H4 header
##### This is an H5 header

Result:

Web portal, Headers 1 through 5

Paragraphs and line breaks

Make your text easier to read by breaking it up with paragraphs or line breaks.

In pull request comments, press Enter to insert a line break and begin text on a new line.

In a Markdown file or widget, enter two spaces prior to the line break to begin a new paragraph, or enter two line breaks consecutively to begin a new paragraph.

Example - pull request comment:

Add lines between your text with the Enter key.
This spaces your text better and makes it easier to read.

Result:
Add lines between your text with the return key
This spaces your text better and makes it easier to read.

Example - markdown file or widget:

Add two spaces prior to the end of the line.(space, space)     
This adds space in between paragraphs.

Result:
Add two spaces prior to the end of the line.

This adds space in between paragraphs.

Quotes

Quote previous comments or other text to set context for your comment.

Quote single lines of text be putting a > before the text. Use multiple > characters to nest quoted text. Quote blocks of lines of text by using the same level of > across multiple lines.

Example:

> Single line quote
>> Nested quote   
> multiple line
> quote

Result:

quoting in markdown

Horizontal rules

Add a horizontal rule by adding a new line that's just a series of dashes ---.

Example:

above
----
below

Result:

above


below

Lists

Organize related items with lists. You can add ordered lists with numbers, or unordered lists with just bullets.

Ordered lists start with a number followed by a period for each list item. Unordered lists start with a -. Begin each list item on a new line.

Example:

1. First item.
2. Second item.
3. Third item.

Result:

  1. First item.
  2. Second item.
  3. Third item.

Example:

  • Item 1
  • Item 2
  • Item 3

Result:

  • Item 1
  • Item 2
  • Item 3

In pull request comments, HTTP and HTTPS URLs are automatically formatted as links. Also, you can link to work items by typing the # key and a work item ID, and then choosing the work item from the list.

In markdown files and widgets, you can set text hyperlinks for your URL using the standard markdown link syntax:

[Link Text](Link URL)

When linking to another Markdown page in the same Git or TFVC repository, the link target can be a relative path or an absolute path in the repository.

Supported links for Welcome pages:

  • Relative path: [text to display](./target.md)
  • Absolute path in Git: [text to display](/folder/target.md)
  • Absolute path in TFVC: [text to display]($/project/folder/target.md)
  • URL: [text to display](http://address.com)

Supported links for Markdown widget:

  • URL: [text to display](http://address.com)

NOTE

Links to documents on file shares using file:// are not supported on Team Services or TFS 2017.1 and later versions. This restriction has been implemented for security purposes.

For information on how to specify relative links from a Welcome page or Markdown widget, see Source control relative links.

Example:

[C# language reference](https://msdn.microsoft.com/en-us/library/618ayhy6.aspx)

Result:

C# language reference

Links to source control files are interpreted differently depending on whether you specify them in a Welcome page or a Markdown widget. The system interprets relative links as follows:

  • Welcome page: relative to the root of the source control repository in which the welcome page exists
  • Markdown widget: relative to the team project collection URL base.

For example:

Welcome page Markdown widget equivalent
/BuildTemplates/AzureContinuousDeploy.11.xaml /DefaultCollection/Fabrikam Fiber/_versionControl#path=$/Tfvc Welcome/BuildTemplates/AzureContinuousDeploy.11.xaml
./page-2.md /DefaultCollection/Fabrikam Fiber/_versionControl#path=$/Tfvc Welcome/page-2.md

Within Markdown files, anchor IDs are assigned to all headings when rendered as HTML. The ID is the heading text, with the spaces replaced by dashes (-) and all lower case.

Example:

###Link to a heading in the page


Result:

The syntax for an anchor link to a section...

[Link to a heading in the page](#link-to-a-heading-in-the-page)

The ID is all lower case, and the link is case sensitive, so be sure to use lower case, even though the heading itself uses upper case. You can also reference headings within another Markdown file:
[text to display](./target.md#heading id)  

Images

Add images and animated GIFs to your pull request comments or markdown files to highlight issues or just to liven the discussion.

Use the following syntax to add an image:

![Text](URL)
The text in the brackets describes the image being linked and the URL points to the image location.

Example:

![Let's use this flow for the login experience](http://dev.fabrikam.net/images/uxflow.png)


Result:

Sample flowchart with three items

The path to the image file can be a relative path or the absolute path in Git or TVFC, just like the path to another Markdown file in a link.

  • Relative path:
    ![Image alt text](./image.png)
  • Absolute path in Git:
    ![Image alt text](/_img/image.png)
  • Absolute path in TFVC:
    ![Image alt text]($/project/folder/_img/image.png)

Tables

Organize structured data with tables. Tables are especially useful for describing function parameters, object methods, and other data that has a clear name to description mapping.

  • Place each table row on its own line
  • Separate table cells using the pipe character |
  • The first two lines of a table set the column headers and the alignment of elements in the table
  • Use colons (:) when dividing the header and body of tables to specify column alignment (left, center, right)
  • Make sure to end each row with a CR or LF.

Example:

| Heading 1 | Heading 2 | Heading 3 |  
|-----------|:-----------:|-----------:|  
| Cell A1 | Cell A2 | Cell A3 |  
| Cell B1 | Cell B2 | Cell B3 |  


Result:

Heading 1 Heading 2 Heading 3
Cell A1 Cell A2 Cell A3
Cell B1 Cell B2 Cell B3

Emphasis (bold, italics, underscore)

You can emphasize text by applying bold, italics, or strikethrough to characters:

  • To apply italics: surround the text with an asterisk * or underscore _
  • To apply bold: surround the text with double asterisks **.
  • To apply strick-through: surround the text with double tilde characters ~~.

Combine these elements to apply multiple emphasis to text.

Example:

Use _emphasis_ in comments to express **strong** opinions and point out ~~corrections~~ 
**_Bold, italizied text_**  
**~~Bold, strike-through text~~**


Result:
Use emphasis in comments to express strong opinions and point out corrections
Bold, italizied text
Bold, strike-through text

Code highlighting

Highlight suggested code segments using code highlight blocks. To indicate a span of code, wrap it with three backtick quotes ( ```) on a new line at both the start and end of the block.

Example:

```
$ sudo npm install vsoagent-installer -g  
```


Result:

$ sudo npm install vsoagent-installer -g


Within a markdown file, text with four spaces at the beginning of the line automatically converts to a code block.

Set a language identifier for the code block to enable syntax highlighting for any of the supported languages.

```language
code
```


Additional examples:

```js
const count = records.length;
```
js
const count = records.length;


Console.WriteLine("Hello, World!");

csharp
Console.WriteLine("Hello, World!");

Emoji

In pull request comments, you can use emojis to add character and quickly react to other comments in the request. Type in what you're feeling surrounded by : characters to get a matching emoji in your text. The full set of emojis are supported.

Example:

:smile:
:angry:

Result:

Emojis in markdown

Special characters

Syntax Example/notes

To insert one of the following characters, prefix with a backslash:

\ backslash

` backtick

_ underscore

{} curly braces

[] square brackets

() parentheses

# hash mark

+ plus sign

- minus sign (hyphen)

. dot

! exclamation mark

Some examples on inserting special characters

Enter \\ to get \

Enter \_ to get _

Enter \# to get #

Enter \( to get (

Enter \. to get .

Enter \! to get !

Attachments

In pull request comments, you can attach files to illustrate your point or to give more detailed reasoning behind your suggestions. To attach a file, drag and drop it into the comment field or select the paper-clip icon in the upper-right of the comment box.

Web portal, Pull Request, Attach files via drag and drop i

If you have an image in your clipboard, you can paste it from the clipboard into the comment box and it will render directly into your comment.

Attachments support the following file formats:

  • Images: PNG (.png), GIF (.gif), JPEG (both .jpeg and .jpg)
  • Documents: Word (.docx), Excel (.xlsx), and Powerpoint (.pptx), text files (.txt), and PDFs (.pdf)
  • Compressed files: ZIP (.zip) and GZIP (.gz)
  • Video files: MOV (.mov), MP4 (.mp4)

Attaching non-image files creates a link to the file in your comment. Update the description text between the brackets to change the text displayed in the link. Attached image files render directly into your comment.

Once you save a new comment or update a comment with an attachment, reviewers see the attached image(s) in the comment and can select links to download attached files.