diff options
| Commit | e4e71fc25db2c57ac72ba2ae103f868ffbfbd6ea (patch) | |
|---|---|---|
| Author | 2024-08-07 18:09:37 +0300 | |
| Committer | 2024-08-07 18:09:37 +0300 | |
| Files | 21dcdcf32f4fee388027568c81209b513ca71a5e /meta.awk | |
| csg-e4e71fc25db2c57ac72ba2ae103f868ffbfbd6ea.tar csg-e4e71fc25db2c57ac72ba2ae103f868ffbfbd6ea.tar.gz csg-e4e71fc25db2c57ac72ba2ae103f868ffbfbd6ea.zip | ||
| Parent | 707916075efadc55ce432095c333b3025cd01321 (diff) | |
feat(awk): Implemented reference links
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) |
