| 145 | | use the `wiki:/` prefix. |
| 146 | | Be careful **not** to use the `/` prefix alone, as this corresponds to the |
| 147 | | [#Server-relativelinks] syntax and with such a link you will lack the `/wiki/` |
| 148 | | part in the resulting URL. |
| 149 | | |
| 150 | | ''(Changed in 0.11)'' Note that in Trac 0.10, using e.g. `[../newticket]` may have worked for linking to the `/newticket` top-level URL, but since 0.11, such a link will stay in the wiki namespace and therefore link to a sibling page. |
| 151 | | See [#Server-relativelinks] for the new syntax. |
| | 136 | use the `wiki:/` prefix. Be careful **not** to use the `/` prefix alone, as this corresponds to the [#Server-relativelinks] syntax and with such a link you will lack the `/wiki/` part in the resulting URL. A link such as `[../newticket]` will stay in the wiki namespace and therefore link to a sibling page. |
| | 137 | |
| | 138 | === Link anchors === |
| | 139 | |
| | 140 | To create a link to a specific anchor in a page, use '#': |
| | 141 | {{{ |
| | 142 | [#Linkanchors Link anchors] or [[#Linkanchors|Link anchors]] |
| | 143 | }}} |
| | 144 | [#Linkanchors Link anchors] or [[#Linkanchors|Link anchors]] |
| | 145 | |
| | 146 | Hint: when you move your mouse over the title of a section, a '¶' character will be displayed. This is a link to that specific section and you can use this to copy the `#...` part inside a relative link to an anchor. |
| | 147 | |
| | 148 | To create a link to the first or last occurrence of a term on a page, use a ''pseudo anchor'' starting with '#/' or '#?': |
| | 149 | {{{ |
| | 150 | [#/Milestone first occurrence of Milestone] or |
| | 151 | [#?Milestone last occurrence of Milestone] |
| | 152 | }}} |
| | 153 | [#/Milestone first occurrence of Milestone] or |
| | 154 | [#?Milestone last occurrence of Milestone] |
| | 155 | This will also highlight all other matches on the linked page. By default only case sensitive matches are considered. To include case insensitive matches append '/i': |
| | 156 | {{{ |
| | 157 | [#/Milestone/i first occurrence of Milestone or milestone] or |
| | 158 | [#?Milestone/i last occurrence of Milestone or milestone] |
| | 159 | }}} |
| | 160 | [#/Milestone/i first occurrence of Milestone or milestone] or |
| | 161 | [#?Milestone/i last occurrence of Milestone or milestone] |
| | 162 | |
| | 163 | ''(since Trac 1.0)'' |
| | 164 | |
| | 165 | Such anchors can be very useful for linking to specific lines in a file in the source browser: |
| | 166 | {{{ |
| | 167 | [trac:source:tags/trac-0.12/trac/wiki/api.py#L127 Line 127] or |
| | 168 | [trac:source:tags/trac-0.12/trac/ticket/roadmap.py#L47 Line 47] |
| | 169 | }}} |
| | 170 | [trac:source:tags/trac-0.12/trac/wiki/api.py#L127 Line 127] or |
| | 171 | [trac:source:tags/trac-0.12/trac/ticket/roadmap.py#L47 Line 47] |
| | 172 | (Hint: The line numbers displayed in the source browser are links to anchors on the respective lines.) |
| | 173 | |
| | 174 | Since such links become outdated when the file changes, it can be useful to link using a '#/' pseudo anchor instead: |
| | 175 | {{{ |
| | 176 | [trac:source:trunk/trac/wiki/api.py#/IWikiSyntaxProvider IWikiSyntaxProvider] or |
| | 177 | [trac:source:trunk/trac/env.py#/ISystemInfoProvider ISystemInfoProvider] |
| | 178 | }}} |
| | 179 | [trac:source:trunk/trac/wiki/api.py#/IWikiSyntaxProvider IWikiSyntaxProvider] or |
| | 180 | [trac:source:trunk/trac/env.py#/ISystemInfoProvider ISystemInfoProvider] |
| 318 | | - `source:/some/file@123:10-20,100,103#L99` - highlight lines 10 to 20, and lines 100 and 103. |
| 319 | | ''(since 0.11)'' |
| | 345 | - `source:/some/file@123:10-20,100,103#L99` - highlight lines 10 to 20, and lines 100 and 103, and target line 99 |
| | 346 | - or without version number (the `@` is still needed): `source:/some/file@:10-20,100,103#L99`. Version can be omitted when the path is pointing to a source file that will no longer change (like `source:/tags/...`), otherwise it's better to specify which lines of //which version// of the file you're talking about |