Re: Escape characters for 'literal'?

Subject: Re: Escape characters for 'literal'?
From: Brandon Ibach <bibach@xxxxxxxxxxxxxx>
Date: Wed, 19 Apr 2000 15:59:38 -0500
Quoting Russell Steven Shawn O'Connor <roconnor@xxxxxxxxxxxx>:
> On Wed, 19 Apr 2000, Malcolm, Douglas J wrote:
> 
> > hanging indent when the title is long enough to wrap to another line.
> > Trouble is, Jade does not like me passing "<table>" and other html tags
> > straight through. 
> 
> Eclose your entire style sheet (excluding the doctype) within 
> 
> [...]
> 
   Yeah... what he said. :)  The reason you need to do this (in case
you're wondering) is because your DSSSL stylesheet is actually an SGML
document, so when the parser sees <table> in there, it thinks it is a
tag in the stylesheet, rather than part of a literal string.  Thus,
the marked section.  You could also accomplish something similar using
a character entity in place of the opening "<" on each tag.
   Beyond that, however, I think you'll have a problem with emitting
tags using (literal), as you will find your angle brackets replaced
with character entities (&gt; and &lt;).  To avoid this, either use
the (make element) construct and properly nest your stuff, or if you
can't properly nest it, use (make empty-element) for each tag (though
I'm not sure, offhand, if this will give you trouble when you try to
emit the end tags).  Alternatively, and possibly your best option,
would be to use (make formatting-instruction data: "<tag><tag><tag>"),
which will emit the string without any escaping.
   Here's a nice little routine to make this sort of thing easy:

(define make-tags (lambda (#!rest args)
  (make formatting-instruction data:
    (let loop ((a (if (list? (car args)) (car args) args)) (s ""))
      (if (null? a) s (loop (cdr a) (apply string-append
            (if (string? (car a)) (list s (car a))
                (list s "<" (symbol->string (car a)) ">")))))))))

   It takes either a single list or a variable number of arguments,
whichever is easier for quoting purposes.  The arguments are symbols
and strings.  The symbols become tags and the strings are passed
through as-is.  This could probably be expanded to allow for attribute
specifications for tags, but I wasn't quite up for it right now. :)
   The following two lines are equivalent, and produce the string
"<hello>world</hello>" with a newline at the end.  Here, "cr" is a
string consisting of a CR-NL pair.

(make-tags 'hello "world" '/hello cr)
(make-tags `(hello "world" /hello ,cr))

-Brandon :)


 DSSSList info and archive:  http://www.mulberrytech.com/dsssl/dssslist


Current Thread