HTML encode a single character, with column/tabsize support.
(html-encode-push char1 col tabsize acc) → new-acc
Function:
(defun html-encode-push (char1 col tabsize acc) (declare (xargs :guard (and (characterp char1) (natp col) (posp tabsize)))) (let ((acl2::__function__ 'html-encode-push)) (declare (ignorable acl2::__function__)) (b* (((the character char1) (mbe :logic (char-fix char1) :exec char1))) (case char1 (#\Space (if (or (atom acc) (eql (car acc) #\Space) (eql (car acc) #\Newline)) (revappend (html-space) acc) (cons #\Space acc))) (#\Newline (revappend (html-newline) acc)) (#\< (revappend (html-less) acc)) (#\> (revappend (html-greater) acc)) (#\& (revappend (html-amp) acc)) (#\" (revappend (html-quote) acc)) (#\Tab (repeated-revappend (distance-to-tab col tabsize) (html-space) acc)) (otherwise (cons char1 acc))))))
Theorem:
(defthm character-listp-of-html-encode-push (implies (character-listp acc) (b* ((new-acc (html-encode-push char1 col tabsize acc))) (character-listp new-acc))) :rule-classes :rewrite)
Theorem:
(defthm html-encode-push-of-char-fix-char1 (equal (html-encode-push (char-fix char1) col tabsize acc) (html-encode-push char1 col tabsize acc)))
Theorem:
(defthm html-encode-push-chareqv-congruence-on-char1 (implies (chareqv char1 char1-equiv) (equal (html-encode-push char1 col tabsize acc) (html-encode-push char1-equiv col tabsize acc))) :rule-classes :congruence)
Theorem:
(defthm html-encode-push-of-nfix-col (equal (html-encode-push char1 (nfix col) tabsize acc) (html-encode-push char1 col tabsize acc)))
Theorem:
(defthm html-encode-push-nat-equiv-congruence-on-col (implies (acl2::nat-equiv col col-equiv) (equal (html-encode-push char1 col tabsize acc) (html-encode-push char1 col-equiv tabsize acc))) :rule-classes :congruence)
Theorem:
(defthm html-encode-push-of-pos-fix-tabsize (equal (html-encode-push char1 col (acl2::pos-fix tabsize) acc) (html-encode-push char1 col tabsize acc)))
Theorem:
(defthm html-encode-push-pos-equiv-congruence-on-tabsize (implies (acl2::pos-equiv tabsize tabsize-equiv) (equal (html-encode-push char1 col tabsize acc) (html-encode-push char1 col tabsize-equiv acc))) :rule-classes :congruence)