Skip to content

Instantly share code, notes, and snippets.

@notmayo
Created March 27, 2026 19:59
Show Gist options
  • Select an option

  • Save notmayo/c79774848630155ae7929f923d317fb6 to your computer and use it in GitHub Desktop.

Select an option

Save notmayo/c79774848630155ae7929f923d317fb6 to your computer and use it in GitHub Desktop.
Confluence HTML export - Find all macros used per page
grep -I -oH '<[^>]*macro[^>]*>' ./*.html \
| grep -Fv 'src=confmacro' \
| awk -F: '
{
file=$1
tag=$0
sub(/^[^:]*:/, "", tag)
out=tag
if (match(tag, /class="[^"]*macro[^"]*"/)) {
out=substr(tag, RSTART+7, RLENGTH-8)
} else if (match(tag, /class='\''[^'\'']*macro[^'\'']*'\''/)) {
out=substr(tag, RSTART+7, RLENGTH-8)
} else if (match(tag, /aria-label="[^"]*"/)) {
out=substr(tag, RSTART+12, RLENGTH-13)
} else if (match(tag, /[[:alnum:]_-]*macro[[:alnum:]_-]*/)) {
out=substr(tag, RSTART, RLENGTH)
}
gsub(/rbtoc[0-9]+/, "rbtoc", out)
key=file SUBSEP out
if (seen[key]++) next
if (file != last_file) {
if (last_file != "") print ""
print file
last_file=file
}
print " - " out
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment