#lang racket/base
(require srfi/13 (only-in racket/gui/base get-text-from-user))
(define (surround-char str char [prefix ""] [suffix (string-reverse prefix)])
(let ([line (string-append prefix (build-string (+ 4 (string-length str)) (λ(i) char)) suffix "\n")])
(string-append
line
prefix (string char) " " str " " (string char) suffix "\n"
line)))
(define (string-or-from-user section str)
(if (string=? str "")
(get-text-from-user section (string-append "Enter a " section ":"))
str))
(define-syntax-rule (define-section (fun label str2) body ...)
(begin
(provide fun)
(define (fun str)
(define str2 (string-or-from-user label str))
(and str2
(begin body ...)))))
(define-section (title "Title" str)
(surround-char
(string-append " " (string-titlecase str) " ")
#\* ";;; **"))
(define-section (section "Section" str)
(surround-char str #\= ";=="))
(define-section (subsection "Subsection" str)
(surround-char str #\: ";:"))
(define-section (subsubsection "Subsubsection" str)
(surround-char str #\- ";"))