Skip to content

Instantly share code, notes, and snippets.

@pingyen
Created March 3, 2017 07:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pingyen/3f03cc35e4f177be5721334d8e62c4e6 to your computer and use it in GitHub Desktop.
Save pingyen/3f03cc35e4f177be5721334d8e62c4e6 to your computer and use it in GitHub Desktop.
Add Link to .php .html file name in Markdown
<?php
$path = 'README.md';
$lines = explode("\n", file_get_contents($path));
foreach ($lines as &$line) {
$tokens = explode(' ', $line);
foreach ($tokens as &$token) {
$token = preg_replace('/(.+?)\.(html|php)/', '[$0]($0)', $token);
}
unset($token);
$line = implode(' ', $tokens);
}
unset($line);
file_put_contents($path, implode("\n", $lines));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment