aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xc2x14
-rw-r--r--g2x.c3
2 files changed, 15 insertions, 2 deletions
diff --git a/c2x b/c2x
index 195c922..4ffcaf3 100755
--- a/c2x
+++ b/c2x
@@ -1,7 +1,17 @@
#!/bin/sh
-rsync ./"${1}" ./"${1}_xhtml"
-cd ./"${1}_xhtml" || exit
+# creates a $1_xhtml dir and that's your root
+rsync -r "./${1}/" "./${1}_xhtml/"
+cd "./${1}_xhtml" || exit
+printf "Converting gmi->html..."
for file in $(find ./* | grep ".gmi" | sed 's/.gmi//'); do
g2x < "./${file}.gmi" > "./${file}.html"
rm "./${file}.gmi"
done
+printf "done\n"
+# this down removes duplicate files
+# symlink them to the capsule root folder files
+printf "Fixing duplicates..."
+for file in $(find ./* -type f | grep -v ".html"); do
+ ln -sf ../../"${1}"/${file} "./${file}"
+done
+printf "done\n"
diff --git a/g2x.c b/g2x.c
index f6e4f33..c171c13 100644
--- a/g2x.c
+++ b/g2x.c
@@ -73,6 +73,8 @@ int main(void)
for (pos = 3; buf[pos] != ' ';)
putchar(buf[pos++]);
// read entire URL, then check for "gmi" in URL.
+ // TODO use strncmp instead of inline char match.
+ // btw idk how to really use strncmp here at all.
if (
buf[pos-3] == 'g' &&
buf[pos-2] == 'm' &&
@@ -85,6 +87,7 @@ int main(void)
}
else if (!strncmp(buf,"```",3))
{// Match ``` codeblocks, ignore the block-name
+ // TODO don't ignore the block-name
fgets(buf,BUFSIZE,stdin); html("<pre><code>");
while (strncmp(buf,"```",3))
{