Skip to content

Commit

Permalink
Create site with documentation #164 : fix relative links
Browse files Browse the repository at this point in the history
  • Loading branch information
xonixx committed Mar 6, 2024
1 parent e819df8 commit 5343614
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion mdbooker.awk
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
BEGIN {
Base = ENVIRON["BASE"]
printf "" > (SUMMARY = (BOOK = "book/") "SUMMARY.md")
H = 0
Title = Content = ""
Expand Down Expand Up @@ -35,8 +36,12 @@ 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)
l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH)
print ">>" l
}
Content = Content "\n" l
}
Expand Down

0 comments on commit 5343614

Please sign in to comment.