Skip to content

Commit

Permalink
Create site with documentation #164 : fix img links
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Mar 6, 2024
1 parent 5343614 commit 8f1410b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions mdbooker.awk
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
BEGIN {
Base = ENVIRON["BASE"]
Repo = ENVIRON["REPO"]
LinkBase = "https://github.com/" Repo "/blob/main/"
RawBase = "https://github.com/" Repo "/raw/main/"
printf "" > (SUMMARY = (BOOK = "book/") "SUMMARY.md")
H = 0
Title = Content = ""
Expand Down Expand Up @@ -36,12 +38,14 @@ function pass2( l,f,t) {
handleTitle(RLENGTH, 2)
else {
if (match(l = $0, /]\(#[^)]+\)/)) {
print " fix link: #" (f = substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f])
print " fix #link: #" (f = substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f])
l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH)
} else if (match(l,/]\([^)]+\)/) && (f = substr(l, RSTART + 2, RLENGTH - 3)) !~ /https?:/) {
print " fix link: " f " -> " (t = Base f)
} else if (match(l, /]\([^)]+\)/) && (f = substr(l, RSTART + 2, RLENGTH - 3)) !~ /https?:/) {
if (l ~ /!\[/)
print " fix image link: " f " -> " (t = RawBase f)
else
print " fix relative link: " f " -> " (t = LinkBase f)
l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH)
print ">>" l
}
Content = Content "\n" l
}
Expand Down

0 comments on commit 8f1410b

Please sign in to comment.