mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
Convert summaries.md into a script
This commit is contained in:
parent
4be3501939
commit
81e15f4d9e
2 changed files with 158 additions and 2 deletions
36
scripts/pipe-convert-for-readme.sh
Executable file
36
scripts/pipe-convert-for-readme.sh
Executable file
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# To use this script, pipe the contents of a MD file into it.
|
||||
# It will output that content reformatted for Readme.
|
||||
|
||||
# Examples:
|
||||
# Reformat the contents of the clipboard
|
||||
# xclip -o | ./pipe-convert-for-readme | xclip -selection clipboard
|
||||
#
|
||||
# Reformat a file and write it to a new file
|
||||
# cat ../_includes/devdoc/guide_block_chain.md | ./pipe-convert-for-readme > ../_readme/guide_block_chain.md
|
||||
|
||||
perl -0 \
|
||||
-pe "s/<!--.+?-->//gs;" \
|
||||
-pe "s/\{% comment %\}.+?{% endcomment %\}//gs;" \
|
||||
-pe "s/\{% include helpers\/subhead-links\.md %\}//g;" \
|
||||
-pe "s/\{% (end)?autocrossref %\}//gs;" \
|
||||
-pe "s/\{% assign .+? %\}//g;" \
|
||||
-pe "s/\{:\.no_toc\}//g;" \
|
||||
-pe "s/\[([^\]]+)\]\[.+?\.term\}/<<glossary:\1>>/g;" \
|
||||
-pe "s/\{% highlight ([^%]+) %\}(.+?\n){% endhighlight %\}/\`\`\` \1\2\`\`\`/gs;" \
|
||||
-pe "s/<<([^>]+)\n([^>]+)>>/<<\1 \2>>/gs;" \
|
||||
-pe "s!\(/img!(https://dash-docs.github.io/img!g;" \
|
||||
-pe "s/{% itemplate ntpd1 %}/Name | Type | Presence | Description\n--- | --- | --- | ---/g;" \
|
||||
-pe "s/\n+- n: \"(.*?)\"\s+t: \"(.*?)\"\s+p: \"(.*?)\"\s+d: \"(.*?)\"/\n\1 | \2 | \3 | \4/g;" \
|
||||
-pe "s/{% enditemplate %}/\n\n/g;" \
|
||||
-pe "s/~~~/\`\`\`/g;" \
|
||||
-pe "s/([0-9a-zA-Z\(\)\[\],\.\-\`])\n *([0-9a-zA-Z\(\)\[\],\.\-\`<])(?=([^\`]|\`(?!\`))*((\`\`\`[^\`]+\`\`\`)([^\`]|\`(?!\`))*)*$)/\1 \2/g;" \
|
||||
-pe "s/(\n\n\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|?)\n(?!\| *-+ *\|)/\n\n\1\n|---|---|---|---|---|---|---|\n/g;" \
|
||||
-pe "s/(\n\n\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|?)\n(?!\| *-+ *\|)/\n\n\1\n|---|---|---|---|---|---|\n/g;" \
|
||||
-pe "s/(\n\n\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|?)\n(?!\| *-+ *\|)/\n\n\1\n|---|---|---|---|---|\n/g;" \
|
||||
-pe "s/(\n\n\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|?)\n(?!\| *-+ *\|)/\n\n\1\n|---|---|---|---|\n/g;" \
|
||||
-pe "s/(\n\n\|[^\|\n]+\|[^\|\n]+\|[^\|\n]+\|?)\n(?!\| *-+ *\|)/\n\n\1\n|---|---|---|\n/g;" \
|
||||
-pe "s/(\n\n\|[^\|\n]+\|[^\|\n]+\|?)\n(?!\| *-+ *\|)/\n\n\1\n|---|---|\n/g;" \
|
||||
-pe "s/\|[-]+(?=[\|\n])/| --- /g;" \
|
||||
-pe "s/\n\n+/\n\n/g;"
|
Loading…
Add table
Add a link
Reference in a new issue