Skip to content

Instantly share code, notes, and snippets.

@Grummfy
Created January 30, 2017 21:24
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 Grummfy/5fe09c79f7a86dd9b2495d2d2eec502e to your computer and use it in GitHub Desktop.
Save Grummfy/5fe09c79f7a86dd9b2495d2d2eec502e to your computer and use it in GitHub Desktop.
markdown link to restructured (rst) synthax
<?php
$oldFileContent = file($argv[1]);
$newFileContent = array();
foreach ($oldFileContent as $line)
{
$pattern = '#(.*)\[([[:print:]]*)\]\((https?://.*)\)(.*)#';
$newFileContent[] = preg_replace($pattern, '$1`$2 <$3>`_$4', $line);
}
file_put_contents($argv[1], implode('', $newFileContent));
find -name *.rst -exec php php.php {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment