mirror of
https://github.com/php-curl-class/php-curl-class.git
synced 2026-09-07 00:35:10 +00:00
Add table of contents update to readme update script
This commit is contained in:
@@ -26,3 +26,19 @@ echo '```' >> "README.md"
|
||||
echo >> "README.md"
|
||||
|
||||
echo "${after}" >> "README.md"
|
||||
|
||||
# Update table of contents.
|
||||
script=$(cat <<'EOF'
|
||||
$data = file_get_contents('README.md');
|
||||
preg_match_all('/^### ([\w ]+)/m', $data, $matches);
|
||||
$toc = array();
|
||||
foreach ($matches['1'] as $match) {
|
||||
$href = '#' . str_replace(' ', '-', strtolower($match));
|
||||
$toc[] = '- [' . $match . '](' . $href . ')';
|
||||
}
|
||||
$toc = implode("\n", $toc);
|
||||
$toc = '---' . "\n\n" . $toc . "\n\n" . '---' . "\n\n";
|
||||
$data = preg_replace('/---\n\n(?:- .*\n)+?\n---\n\n/', $toc, $data);
|
||||
file_put_contents('README.md', $data);
|
||||
EOF)
|
||||
php --run "${script}"
|
||||
|
||||
Reference in New Issue
Block a user