[plt-scheme] mztext replacement

From: Eli Barzilay (eli at barzilay.org)
Date: Wed Feb 27 16:34:02 EST 2008

This is intended to poll all mztext users (the fact that there is more
than one surprised me...).

I've hacked up a little scribble-based language that -- I think --
should be better than mztext.  The advantage of mztext is that you can
have arbitrary parsing of your input, and you can also perform
function calls through the textual expansion ("@foo" expands to a
string that has "@bar").  Just like tex, the disadvantage of mztext is
exactly the same feature -- it can lead to very messy files.

On the other hand, a scribble replacement is well behaved, and is very
predictable.  The addition of a proper reader means that there is no
problems debugging your code since you have proper syntax source
information.  You can even use it in DrScheme, with check-syntax,
coverage, or whatever.

It's also easy to construct: start with the `read-inside' scribble
reader (just like in scribble files) and you read the source a
strings; then change the printer to display values like mztext/mzpp
do.  Together with the behavior of scheme/base of printing all
toplevel values you get to write text-files with @ escapes that print
themselves if you just run mzscheme on them.

The questions that I have are:

  * I'm using `scribble/text' as the language -- any objections or

  * It seems to me that just the above is enough for the usual use of
    a saner tex front end.  Do you see any extra bells and whistles
    that are needed?

  * I originally thought to make a command-line interface that is
    similar to mzpp/mztext -- but I think that there is almost nothing
    that this will get that using plain mzscheme doesn't.  That is,
    you can use it with

      mzscheme foo > bar

    which will spit out the "preprocessed" contents of "foo" into
    "bar".  Are there practical uses that need more than that?

One last thing -- something that is convenient to do with mztext is to
write a @command that consumes two {...} arguments.  Like I wrote
earlier, one way to do that with scribble is with currying, for

  @(define ((foo . body1) . body2) ...)

But a more sensible way is to split the input body on a specific
token, for example, implementing an `itemize' like this:

  @(begin (define item "item")
          (define (itemize . body)
            (split-lists-on-token body item)))
  @itemize{@item ... @item ...}

where `split-lists-on-token' will split a list into its sublists that
are separated by things that are `eq?' to the given token value.

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.