We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f9d0b9c commit 56940caCopy full SHA for 56940ca
scripts/update_readme_methods.sh
@@ -26,3 +26,19 @@ echo '```' >> "README.md"
26
echo >> "README.md"
27
28
echo "${after}" >> "README.md"
29
+
30
+# Update table of contents.
31
+script=$(cat <<'EOF'
32
+ $data = file_get_contents('README.md');
33
+ preg_match_all('/^### ([\w ]+)/m', $data, $matches);
34
+ $toc = array();
35
+ foreach ($matches['1'] as $match) {
36
+ $href = '#' . str_replace(' ', '-', strtolower($match));
37
+ $toc[] = '- [' . $match . '](' . $href . ')';
38
+ }
39
+ $toc = implode("\n", $toc);
40
+ $toc = '---' . "\n\n" . $toc . "\n\n" . '---' . "\n\n";
41
+ $data = preg_replace('/---\n\n(?:- .*\n)+?\n---\n\n/', $toc, $data);
42
+ file_put_contents('README.md', $data);
43
+EOF)
44
+php --run "${script}"
0 commit comments