summaryrefslogtreecommitdiffstats
path: root/apps/plugins/puzzles/genhelp.sh
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/puzzles/genhelp.sh')
-rwxr-xr-xapps/plugins/puzzles/genhelp.sh84
1 files changed, 56 insertions, 28 deletions
diff --git a/apps/plugins/puzzles/genhelp.sh b/apps/plugins/puzzles/genhelp.sh
index 1d4dac794b..007cdafd21 100755
--- a/apps/plugins/puzzles/genhelp.sh
+++ b/apps/plugins/puzzles/genhelp.sh
@@ -21,37 +21,65 @@ rm puzzles.txt.tmp
# now split into different files
mkdir -p help
-cat puzzles.txt | awk 'BEGIN { file = "none"; }
- /#Chapter/ {
- if($0 !~ / 1:/ && $0 !~ / 2:/)
- {
- if(file != "none")
- print ";" > file;
- file = "help/"tolower($3$4)".c";
- if($3 ~ "Rectangles")
- file = "help/rect.c";
- print "/* auto-generated by genhelp.sh */" > file;
- print "/* DO NOT EDIT! */" > file;
- print "const char help_text[] = " > file; }
- }
- file != "none" {
- gsub(/\\/,"\\\\");
- if($0 !~ /Chapter/ && substr($0, 1, 1) == "#")
- begin = "\\n";
- else begin = "";
- last = substr($0, length($0), 1);
- if(length($0) == 0 || last == "|" || last == "-" || (term == "\\n" && last == "3"))
- term="\\n";
- else term = " ";
- print "\"" begin $0 term "\"" > file;
- }
- END {
- print ";" > file;
- }
+cat puzzles.txt | awk '
+BEGIN {
+ file = "none";
+}
+
+/#Chapter/ {
+ if($0 !~ / 1:/ && $0 !~ / 2:/)
+ {
+ if(file != "none")
+ print ";" > file;
+ file = "help/"tolower($3$4)".c";
+
+ if($3 ~ "Rectangles")
+ file = "help/rect.c";
+
+ print "/* auto-generated by genhelp.sh (intermediate file) */" > file;
+ print "/* DO NOT EDIT! */" > file;
+ print "const char help_text[] = " > file;
+ }
+}
+
+file != "none" {
+ /* escape backslashes */
+ gsub(/\\/,"\\\\");
+
+ if($0 ~ /\$/)
+ print("WARNING: text contains dollar sign: change special character!" $0);
+
+ /* replace underscores with dollar signs (not used in any of the puzzles docs) */
+ if($0 ~ /http/)
+ gsub(/_/,"$");
+
+ begin = "";
+
+ last = substr($0, length($0), 1);
+
+ /* hack for chapter titles */
+ if(substr($0, 1, 1) == "#" || length($0) == 0)
+ term=" \\n";
+ else
+ term = " ";
+
+ /* custom code markup (halibut modification required) */
+ if(substr($0, 1, 2) == ">>")
+ {
+ gsub(/>> /,"");
+ term = " \\n";
+ }
+
+ print "\"" begin $0 term "\"" > file;
+}
+
+END {
+ print ";" > file;
+}
'
# now compress
-for f in help/*
+for f in help/*.c
do
echo "Compressing: "$f
gcc compress.c $f -llz4 -o compress -O0