In an answer, I was adding some links to the documentation, after I wrote some PHP code. As result, the code was altered.
Take as example the following Markdown with an indented code block.
if (isset($item['load_functions'][1]) && !empty($item['map'][1]) && $item['load_functions'][1] == 'node_load') {
$node = $router_item['map'][1];
}
else {
// The menu item is not for a node.
}
After I add the first link (in a regular paragraph), I get the following, as expected.
if (isset($item['load_functions'][1]) && !empty($item['map'][1]) && $item['load_functions'][1] == 'node_load') {
$node = $router_item['map'][1];
}
else {
// The menu item is not for a node.
}
See [menu_get_object()][1]
[1]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_object/7
After I add the second link, I get the following, where the [1]
indexes in the code block have been interpreted as links.
if (isset($item['load_functions'][1]) && !empty($item['map'][2]) && $item['load_functions'][3] == 'node_load') {
$node = $router_item['map'][4];
}
else {
// The menu item is not for a node.
}
See [menu_get_object()][5]
And see [menu_get_item()][6]
[1]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_object/7
[2]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_object/7
[3]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_object/7
[4]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_object/7
[5]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_object/7
[6]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_item/7
Notice that the code is correctly indented with 4 spaces.
I was able to reproduce the bug in the sandbox. I also tried with another browser, as I noticed I was using a not supported browser (Firefox 19.0a1). With Safari 6.0.2, the result is the same.
The issues are two:
- Perfectly valid code is rewritten.
- Markdown links pointing to the same URL are rewritten. Even in the case I didn't write PHP code, but Markdown markup, there isn't any need to re-write all the links.
Suppose I have the following markdown.
[Example link][1]
[Same example link][1]
[The same link once again][1]
[1]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_item/7
If I add another link, the other links should not be changed. This is what instead happens.
[Example link][1]
[Same example link][2]
[The same link once again][3]
[Another link][4]
[1]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_item/7
[2]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_item/7
[3]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_item/7
[4]: http://api.drupal.org/api/drupal/includes!menu.inc/function/menu_get_object/7
See the sandbox example.
backticks