diff options
1 files changed, 23 insertions, 0 deletions
| -rw-r--r-- | meta.awk | 23 |
@@ -1,6 +1,10 @@ function emit(ind, val) { print "meta[\"" FILENAME "\", \"" ind "\"]=\"" val "\"" } +function erit(id, href, title) { + print "reference[\"" id "\", \"href\"]=\"" href "\"" + print "reference[\"" id "\", \"title\"]=\"\\\"" title "\\\"\"" +} title != "" && stopdesc == 0 && /^[[:alpha:]]/ { startedGathering = 1 @@ -29,6 +33,25 @@ title == "" && /^# / { title = $0 } +/^\[[^^].*\]:/ { + match($0, /^\[.+\]:/) + id = substr($0, 2, RLENGTH - 3) + + href = substr($0, RLENGTH + 1) + reftitle = "" + if (match(href, /[ \t]+["'(].*[)'"]$/)) { + reftitle = substr(href, RSTART) + href = substr(href, 1, RSTART - 1) + + sub(/^[ \t]["'(]*/, "", reftitle) + sub(/[)'"][ \t]*$/, "", reftitle) + } + sub(/^[ \t]*<?/, "", href) + sub(/>?[ \t]*$/, "", href) + + erit(id, href, reftitle) +} + END { emit("title", title) emit("description", desc) |
