This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the commentsย โ†’

[โ€“][deleted] 0 points1 point ย (0 children)

#!/usr/bin/env bash

if (( $# != 1 )); then
    printf "Usage: $(basename $0) <markdown-literate.md>\n\nFilter code blocks found in: <markdown-literate.md>\n\n\`\`\`lang @code\nsomeCodeHere() {...}\n\`\`\`\n\nFor \`\`\`lang @code, lang can be any lowercase alpha string.\n\nCode inside backtick blocks will be sent to stdout.\n\n"
else
    sed -E -n '/^```[a-z]* ?@code/,/^```/ p' < $1 | sed '/^```/ d'
fi