Re: Curly Quotes and HTML

> That's what <Q> was for, but no browser implemented it. I'm not sure
> what you mean by "curly quotes"...do you mean the normal printer's


  The Grail browser can support this using the file below; after
installing Grail, save this file as ~/.grail/html/q.py.  It's simple,
but works quite handily.


  -Fred

--
Fred L. Drake, Jr.
fdrake@cnri.reston.va.us
Corporation for National Research Initiatives
1895 Preston White Drive
Reston, VA    20191-5434


======================================================================
"""Simple implementation of the <Q> tag.

This needs a bit of elaboration to support multiple languages, but is
otherwise quite servicable.
"""

ATTRIBUTES_AS_KEYWORDS = 1


_quote_styles = (('``', "''"), ("`", "'"))


def start_q(parser, attrs):
    qs, open, close = _fetch_info(parser)
    parser.handle_data(open)
    qs[1] = qs[1] + 1


def end_q(parser):
    qs, open, close = _fetch_info(parser)
    parser.handle_data(close)
    qs[1] = max(0, qs[1] - 1)


def _fetch_info(parser):
    if hasattr(parser, "_quote_info"):
	qs = parser._quote_info
    else:
	qs = [_quote_styles, 0]
	parser._quote_info = qs
    styles = qs[0]
    numstyles = len(styles)
    open = styles[qs[1] % numstyles][0]
    close = styles[(qs[1]-1) % numstyles][1]
    return qs, open, close

#
#  end of file

Received on Tuesday, 31 December 1996 16:28:15 UTC