From d194694f31002068868a378d121ed0e2db01c378 Mon Sep 17 00:00:00 2001 From: nathansmith Date: Thu, 22 May 2025 12:11:10 -0600 Subject: Messy folder --- testTheThing/clean_up_html.scm | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 testTheThing/clean_up_html.scm (limited to 'testTheThing/clean_up_html.scm') diff --git a/testTheThing/clean_up_html.scm b/testTheThing/clean_up_html.scm new file mode 100755 index 0000000..6ee81c5 --- /dev/null +++ b/testTheThing/clean_up_html.scm @@ -0,0 +1,45 @@ +#! /usr/bin/guile \ +-e main -s +!# + +;; Loads an entire text file into a string +(define (read-entire-file-port fp) + (letrec ((read-characters + (lambda (fp) + (let ((character (read-char fp))) + (if (eof-object? character) + "" + (string-append (string character) + (read-characters fp))))))) + (read-characters fp))) + +(define (trim-words-all content word) + (let ((index (string-contains content word))) + (if index + (trim-words-all (string-append + (substring content 0 index) + (substring content + (+ index (string-length word)) + (string-length content))) + word) + content))) + +(define (clean-up-html file-name) + (call-with-input-file file-name + (lambda (fp) + (let ((content (read-entire-file-port fp)) + (remove-list '("" + "
" + "
" + "" + "" + "" + ""))) + (for-each + (lambda (item) + (set! content (trim-words-all content item))) + remove-list) + (display content))))) + +(define (main args) + (clean-up-html (cadr args))) -- cgit v1.2.3