<a id="launchpad-comment-parsing"></a>

# Launchpad comment parsing

Launchpad automatically parses and formats comment text, creating links
to bugs, branches, and other resources when you use specific syntax
patterns.

## Whitespaces

Launchpad reduces any whitespace between non-whitespace characters to a
single space, keeps whitespace to the left, and removes whitespace to
the right.

#### NOTE
Technically Launchpad passes whitespace through and the browser just
ignores the whitespace.

### Examples

| Input                                                                                                                                                                                                                                          | Output                                                                                                                                                                                               |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `This sentence has varying amounts of whitespace between<br/>its words.`                                                                                                                                                                       | `This sentence has varying amounts of whitespace between<br/>its words.`                                                                                                                             |
| ```default<br/>| Column 1   | Column 2 | Column 3    |<br/>|------------+----------+-------------|<br/>| Lorem      | ipsum    | dolor       |<br/>| sit        | amet     | consectetur |<br/>| adipiscing | elit     | sed         |<br/>``` | ```default<br/>| Column 1 | Column 2 | Column 3 |<br/>|------------+----------+-------------|<br/>| Lorem | ipsum | dolor |<br/>| sit | amet | consectetur |<br/>| adipiscing | elit | sed |<br/>``` |

## Paragraphs

Multiple newline characters will be reduced to one.

### Examples

| Input                                                                                                                                              | Output                                                                                                                              |
|----------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------|
| ```default<br/>Here are two paragraphs with lots of whitespace between them.<br/><br/><br/><br/><br/>But they're still just two paragraphs<br/>``` | ```default<br/>Here are two paragraphs with lots of whitespace between them.<br/><br/>But they're still just two paragraphs<br/>``` |

## Mention a single Launchpad bug

Use any of these patterns to link to a bug. These patterns are
case-insensitive.

Patterns:

```default
bug <LP-Bug-Number>
bug #<LP-Bug-Number>
bug number <LP-Bug-Number>
bug num <LP-Bug-Number>
bug num. <LP-Bug-Number>
bug no <LP-Bug-Number>
bug no. <LP-Bug-Number>
bug report <LP-Bug-Number>
bug-report <LP-Bug-Number>
bug-<LP-Bug-Number>
bug=<LP-Bug-Number>
```

### Examples

| Input             | Output                                                |
|-------------------|-------------------------------------------------------|
| `bug 123`         | [bug 123](https://bugs.launchpad.net/bugs/123)        |
| `bug    123`      | [bug 123](https://bugs.launchpad.net/bugs/123)        |
| `bug #123`        | [bug #123](https://bugs.launchpad.net/bugs/123)       |
| `bug number 123`  | [bug number 123](https://bugs.launchpad.net/bugs/123) |
| `bug number. 123` | bug number. 123                                       |
| `bug num 123`     | [bug num 123](https://bugs.launchpad.net/bugs/123)    |
| `bug num. 123`    | [bug num. 123](https://bugs.launchpad.net/bugs/123)   |
| `bug no 123`      | [bug no 123](https://bugs.launchpad.net/bugs/123)     |
| `bug report 123`  | [bug report 123](https://bugs.launchpad.net/bugs/123) |
| `bug no. 123`     | [bug no. 123](https://bugs.launchpad.net/bugs/123)    |
| `bug#123`         | bug#123                                               |
| `bug-123`         | [bug-123](https://bugs.launchpad.net/bugs/123)        |
| `bug-report-123`  | [bug-report-123](https://bugs.launchpad.net/bugs/123) |
| `bug=123`         | [bug=123](https://bugs.launchpad.net/bugs/123)        |
| `debug #52`       | debug #52                                             |

## Mention multiple Launchpad bugs

Use this pattern to link to multiple bugs. These patterns are
case-insensitive. The amount of whitespace can be variable, but
whitespace in other positions may prevent parsing.

Pattern:

```default
LP: #<LP-Bug-Number>[, #<LP-Bug-Number>]...
```

### Examples

| Input                                                     | Output                                                                                                                                                                    |
|-----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `LP: #1`                                                  | LP: [#1](http://example.net)                                                                                                                                              |
| `(LP: #1)`                                                | (LP: [#1](http://example.net)                                                                                                                                             |
| `LP: #1, #2.`                                             | LP: [#1](http://example.net), [#2](http://example.net).                                                                                                                   |
| ```default<br/>LP:<br/>#1,<br/>#2,<br/>#3,<br/>#4<br/>``` | LP:<br/><br/><br/>[#1](http://example.net)<br/><br/><br/>[#2](http://example.net)<br/><br/><br/>[#3](http://example.net)<br/><br/><br/>[#4](http://example.net)<br/><br/> |
| `lp: #1`                                                  | lp: [#1](http://example.net)                                                                                                                                              |
| `(lp: #1)`                                                | (lp: [#1](http://example.net)                                                                                                                                             |
| `lp: #1, #2.`                                             | lp: [#1](http://example.net), [#2](http://example.net).                                                                                                                   |
| `LP #1`                                                   | LP #1                                                                                                                                                                     |
| `LP: #1 , #2`                                             | LP: [#1](http://example.net) , #2                                                                                                                                         |
| ```default<br/>LP: #1, #2,<br/><br/>#3<br/>```            | LP: [#1](http://example.net), [#2](http://example.net),<br/><br/><br/><br/><br/>1. 3<br/><br/>                                                                            |

## Mention a branch

Link to a Launchpad branch using the `lp` URI syntax. The `lp:`
prefix will expand to `https://bugs.launchpad.net/+code/`. These
patterns are case-insensitive.

Patterns:

```default
lp:<Relative-URL>
lp:/<Relative-URL>
lp:///<Relative-URL>
```

### Examples

| Input                                 | Output                                                                                                             |
|---------------------------------------|--------------------------------------------------------------------------------------------------------------------|
| `lp:~foo/bar/baz`                     | [lp:~foo/bar/baz](https://bugs.launchpad.net/+code/~foo/bar/baz)                                                   |
| `lp:~foo/bar/bug-123`                 | [lp:~foo/bar/bug-123](https://bugs.launchpad.net/+code/~foo/bar/bug-123)                                           |
| `lp:~foo/+junk/baz`                   | [lp:~foo/+junk/baz](https://bugs.qastaging.launchpad.net/+code/~foo/+junk/baz)                                     |
| `lp:~foo/ubuntu/jaunty/evolution/baz` | [lp:~foo/ubuntu/jaunty/evolution/baz](https://bugs.qastaging.launchpad.net/+code/~foo/ubuntu/jaunty/evolution/baz) |
| `lp:foo/bar`                          | [lp:foo/bar](https://bugs.qastaging.launchpad.net/+code/foo/bar)                                                   |
| `lp:foo`                              | [lp:foo](https://bugs.launchpad.net/+code/foo)                                                                     |
| `lp:foo,`                             | [lp:foo](https://bugs.launchpad.net/+code/foo),                                                                    |
| `lp:foo/bar.`                         | [lp:foo/bar](https://bugs.launchpad.net/+code/foo/bar).                                                            |
| `lp:foo/bar/baz`                      | [lp:foo/bar/baz](https://bugs.launchpad.net/+code/bar/baz)                                                         |
| `lp:///foo`                           | [lp:///foo](https://bugs.launchpad.net/+code/foo)                                                                  |
| `lp:/foo`                             | [lp:///foo](https://bugs.launchpad.net/+code/foo)                                                                  |

## Mention an FAQ thread

Link to a Launchpad FAQ thread by mentioning its number. These patterns
are case-insensitive.

Patterns:

```default
faq <faq-number>
faq #<faq-number>
faq-<faq-number>
faq=<faq-number>
faq item <faq-number>
faq number <faq-number>
```

### Examples

| Input               | Output                                                            |
|---------------------|-------------------------------------------------------------------|
| `faq 3041`          | [faq 3041](https://answers.launchpad.net/ubuntu/+faq/3041)        |
| `faq #3041`         | [faq #3041](https://answers.launchpad.net/ubuntu/+faq/3041)       |
| `faq-3041`          | [faq-3041](https://answers.launchpad.net/ubuntu/+faq/3041)        |
| `faq=3041`          | [faq=3041](https://answers.launchpad.net/ubuntu/+faq/3041)        |
| `faq item 3041`     | [faq item 3041](https://answers.launchpad.net/ubuntu/+faq/3041)   |
| `faq  number  3041` | [faq number 3041](https://answers.launchpad.net/ubuntu/+faq/3041) |

## URIs

Launchpad automatically recognizes and links `http`, `https`,
`ftp`, `sftp`, `mailto`, `news`, `irc`, and `jabber` URIs.

Not recognized: `tel`, `urn`, `telnet`, `ldap` URIs, relative
URLs (e.g., `example.com`), and plain email addresses (e.g.,
`test@example.com`).

### Examples

| Input                                                                       | Output                                                                                                                                                    |
|-----------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------|
| `http://localhost:8086/bar/baz/foo.html`                                    | [http://localhost:8086/bar/baz/foo.html](http://localhost:8086/bar/baz/foo.html)                                                                          |
| `ftp://localhost:8086/bar/baz/foo.bar.html`                                 | [ftp://localhost:8086/bar/baz/foo.bar.html](ftp://localhost:8086/bar/baz/foo.bar.html)                                                                    |
| `sftp://localhost:8086/bar/baz/foo.bar.html.`                               | sftp://localhost:8086/bar/baz/foo.bar.html.                                                                                                               |
| `http://localhost:8086/bar/baz/foo.bar.html;`                               | [http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html);                                                                 |
| `news://localhost:8086/bar/baz/foo.bar.html:`                               | [news://localhost:8086/bar/baz/foo.bar.html](news://localhost:8086/bar/baz/foo.bar.html):                                                                 |
| `http://localhost:8086/bar/baz/foo.bar.html?`                               | [http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)?                                                                 |
| `http://localhost:8086/bar/baz/foo.bar.html,`                               | [http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html),                                                                 |
| `<http://localhost:8086/bar/baz/foo.bar.html>`                              | <[http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)>                                                                |
| `<http://localhost:8086/bar/baz/foo.bar.html>,`                             | <[http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)>,                                                               |
| `<http://localhost:8086/bar/baz/foo.bar.html>.`                             | <[http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)>.                                                               |
| `<http://localhost:8086/bar/baz/foo.bar.html>;`                             | <[http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)>;                                                               |
| `<http://localhost:8086/bar/baz/foo.bar.html>:`                             | <[http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)>:                                                               |
| `<http://localhost:8086/bar/baz/foo.bar.html>?`                             | <[http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)>?                                                               |
| `(http://localhost:8086/bar/baz/foo.bar.html)`                              | ([http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html))                                                                |
| `(http://localhost:8086/bar/baz/foo.bar.html),`                             | ([http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)),                                                               |
| `(http://localhost:8086/bar/baz/foo.bar.html).`                             | ([http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)).                                                               |
| `(http://localhost:8086/bar/baz/foo.bar.html);`                             | ([http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html));                                                               |
| `(http://localhost:8086/bar/baz/foo.bar.html):`                             | ([http://localhost:8086/bar/baz/foo.bar.html](http://localhost:8086/bar/baz/foo.bar.html)):                                                               |
| `http://localhost/bar/baz/foo.bar.html?a=b&b=a`                             | [http://localhost/bar/baz/foo.bar.html?a=b&b=a](http://localhost/bar/baz/foo.bar.html?a=b&b=a)                                                            |
| `http://localhost/bar/baz/foo.bar.html?a=b&b=a.`                            | [http://localhost/bar/baz/foo.bar.html?a=b&b=a](http://localhost/bar/baz/foo.bar.html?a=b&b=a).                                                           |
| `http://localhost/bar/baz/foo.bar.html?a=b&b=a,`                            | [http://localhost/bar/baz/foo.bar.html?a=b&b=a](http://localhost/bar/baz/foo.bar.html?a=b&b=a),                                                           |
| `http://localhost/bar/baz/foo.bar.html?a=b&b=a;`                            | [http://localhost/bar/baz/foo.bar.html?a=b&b=a](http://localhost/bar/baz/foo.bar.html?a=b&b=a);                                                           |
| `http://localhost/bar/baz/foo.bar.html?a=b&b=a:`                            | [http://localhost/bar/baz/foo.bar.html?a=b&b=a](http://localhost/bar/baz/foo.bar.html?a=b&b=a):                                                           |
| `http://localhost/bar/baz/foo.bar.html?a=b&b=a:b;c@d_e%f~g#h,j!k-l+m$n*o'p` | [http://localhost/bar/baz/foo.bar.html?a=b&b=a:b;c@d_e%f~g#h,j!k-l+m$n\*o’p](http://localhost/bar/baz/foo.bar.html?a=b&b=a:b;c@d_e%25f~g#h,j!k-l+m$n*o'p) |
| `http://www.searchtools.com/test/urls/(parens).html`                        | [http://www.searchtools.com/test/urls/(parens).html](http://www.searchtools.com/test/urls/(parens).html)                                                  |
| `http://www.searchtools.com/test/urls/-dash.html`                           | [http://www.searchtools.com/test/urls/-dash.html](http://www.searchtools.com/test/urls/-dash.html)                                                        |
| `http://www.searchtools.com/test/urls/_underscore.html`                     | [http://www.searchtools.com/test/urls/_underscore.html](http://www.searchtools.com/test/urls/_underscore.html)                                            |
| `http://www.searchtools.com/test/urls/period.x.html`                        | [http://www.searchtools.com/test/urls/period.x.html](http://www.searchtools.com/test/urls/period.x.html)                                                  |
| `http://www.searchtools.com/test/urls/!exclamation.html`                    | [http://www.searchtools.com/test/urls/!exclamation.html](http://www.searchtools.com/test/urls/!exclamation.html)                                          |
| `http://www.searchtools.com/test/urls/~tilde.html`                          | [http://www.searchtools.com/test/urls/~tilde.html](http://www.searchtools.com/test/urls/~tilde.html)                                                      |
| `http://www.searchtools.com/test/urls/*asterisk.html`                       | [http://www.searchtools.com/test/urls/\*asterisk.html](http://www.searchtools.com/test/urls/*asterisk.html)                                               |
| `irc://chat.freenode.net/launchpad`                                         | [irc://chat.freenode.net/launchpad](irc://chat.freenode.net/launchpad)                                                                                    |
| `irc://chat.freenode.net/%23launchpad,isserver`                             | [irc://chat.freenode.net/%23launchpad,isserver](irc://chat.freenode.net/%23launchpad,isserver)                                                            |
| `mailto:noreply@launchpad.net`                                              | [mailto:noreply@launchpad.net](mailto:noreply@launchpad.net)                                                                                              |
| `jabber:noreply@launchpad.net`                                              | jabber:noreply@launchpad.net                                                                                                                              |
| `http://localhost/foo?xxx&`                                                 | [http://localhost/foo?xxx&](http://localhost/foo?xxx&)                                                                                                    |
| `http://localhost?testing=[square-brackets-in-query]`                       | [http://localhost?testing=%5Bsquare-brackets-in-query]](http://localhost?testing=%5Bsquare-brackets-in-query])                                            |

## Quote removal

If a comment is entirely enclosed in double quotes (`"Content"`),
Launchpad will drop the quotes.

### Examples

| Input       | Output   |
|-------------|----------|
| `"Content"` | Content  |
