# create docs/index.html
DATA:
template is text
readme is text
html is text
# link parsing
i is number
x is number
len is number
chars is text vector
char is text
link is text
token is text
newfile is text
links is number
is text
is text
PROCEDURE:
store "\e[1;0m> \e[32m" in
store "\e[0m" in
display "loading files..." crlf
load file "docs/index.tpl" in template
load file "README.txt" in readme
sub-procedure escape-html
display "escaping html..." crlf
replace "<" from readme with "<" in readme
replace ">" from readme with ">" in readme
end sub-procedure
call escape-html
sub-procedure replace-link-in-token
get index of "https://" from token in x
if x is equal to 0 then
# in token join "" token ""
store token in link
join "" in token
join token and link in token
join token and "" in token
end if
end sub-procedure
sub-procedure replace-links
count "https://" from readme in links
display "linking " links " links..." crlf
split readme by "" in chars
store length of readme in len
while i is less than len do
store chars:i in char
if char is equal to " " then
call replace-link-in-token
join token and char in token
join newfile and token in newfile
store "" in token
else if char is equal to "\n" then
call replace-link-in-token
join token and char in token
join newfile and token in newfile
store "" in token
else if char is equal to "\r" then
# ignore
else
join token and char in token
end if
incr i
repeat
join newfile and token in readme
end sub-procedure
call replace-links
replace "{{body}}" from template with readme in html
display "saving html..." crlf
write html to file "docs/index.html"
display "built docs/index.html" crlf