Re: Curly Quotes and HTML

Fred L. Drake (fdrake@CNRI.Reston.VA.US)
Tue, 31 Dec 1996 16:21:46 -0500 (EST)


From: "Fred L. Drake" <fdrake@CNRI.Reston.VA.US>
Message-Id: <199612312121.QAA03148@weyr.CNRI.Reston.Va.US>
Subject: Re: Curly Quotes and HTML
To: Peter Flynn <pflynn@curia.ucc.ie>
Date: Tue, 31 Dec 1996 16:21:46 -0500 (EST)
Cc: www-html@www10.w3.org
In-Reply-To: <199612312042.UAA15960@curia.ucc.ie> from "Peter Flynn" at Dec 31, 96 08:42:42 pm

> 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