-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
The following code in translate_markup
// Translate Trac-style links to Markdown
$data = preg_replace('/\[([^ ]+) ([^\]]+)\]/', '[$2]($1)', $data);should not be applied inside a code block.
Example file: mo.txt
Example code for easy reproduction:
<?php
$data = file_get_contents("mo.txt");
file_put_contents("gh.txt", translate_markup($data));
function translate_markup($data) {
// Replace code blocks with an associated language
$data = preg_replace('/\{\{\{(\s*#!(\w+))?/m', '```$2', $data);
$data = preg_replace('/\}\}\}/', '```', $data);
// Avoid non-ASCII characters, as that will cause trouble with json_encode()
$data = preg_replace('/[^(\x00-\x7F)]*/','', $data);
// Translate Trac-style links to Markdown
$data = preg_replace('/\[([^ ]+) ([^\]]+)\]/', '[$2]($1)', $data);
// Possibly translate other markup as well?
return $data;
}
?>Metadata
Metadata
Assignees
Labels
No labels