[Zope-Checkins] CVS: Zope2 - DocumentClass.py:1.11 HTMLWithImages.py:1.3
Amos Latteier
amos@digicool.com
Tue, 20 Mar 2001 17:58:25 -0500 (EST)
Update of /cvs-repository/Zope2/lib/python/StructuredText
In directory korak:/tmp/cvs-serv12368
Modified Files:
DocumentClass.py HTMLWithImages.py
Log Message:
Added support for x-refs and fixed image support including x-refs to figures.
--- Updated File DocumentClass.py in package Zope2 --
--- DocumentClass.py 2001/03/13 20:11:17 1.10
+++ DocumentClass.py 2001/03/20 22:58:25 1.11
@@ -338,6 +338,8 @@
class StructuredTextLink(StructuredTextMarkup): pass
+class StructuredTextXref(StructuredTextMarkup): pass
+
class DocumentClass:
"""
Class instance calls [ex.=> x()] require a structured text
@@ -368,7 +370,8 @@
'doc_strong',
'doc_emphasize',
'doc_literal',
- 'doc_sgml'
+ 'doc_sgml',
+ 'doc_xref',
]
def __call__(self, doc):
@@ -976,3 +979,18 @@
start,end = r.span()
text = s[start:end]
return (StructuredTextSGML(text),start,end)
+
+
+ def doc_xref(self, s,
+ expr = re.compile('\[([a-zA-Z0-9\-.:/;,\n\~]+)\]').search
+ ):
+ r = expr(s)
+ if r:
+ start, end = r.span(1)
+ return (StructuredTextXref(s[start:end]), start-1, end+1)
+ else:
+ return None
+
+
+
+
--- Updated File HTMLWithImages.py in package Zope2 --
--- HTMLWithImages.py 2001/01/04 15:01:59 1.2
+++ HTMLWithImages.py 2001/03/20 22:58:25 1.3
@@ -109,21 +109,16 @@
output('</body>\n')
output('</html>\n')
-
def image(self, doc, level, output):
- output('<img src="%s" alt="%s">' % (doc.href, doc.getNodeValue()))
-
-
- def image(self, doc, level, output):
if hasattr(doc, 'key'):
- output('<a name="%s"></a>\n<img src="%s" alt="%s">' % (doc.key, doc.href, doc.getNodeValue()))
- else:
- output('<img src="%s" alt="%s">' % (doc.href, doc.getNodeValue()))
-
+ output('<a name="%s"></a>\n' % doc.key)
+ output('<img src="%s" alt="%s">\n' % (doc.href, doc.getNodeValue()))
+ if doc.getNodeValue() and hasattr(doc, 'key'):
+ output('<p><b>Figure %s</b> %s</p>\n' % (doc.key, doc.getNodeValue()))
def xref(self, doc, level, output):
val = doc.getNodeValue()
- output('<a href="#%s">%s</a>' % (val, val) )
+ output('<a href="#%s">Figure %s</a>' % (val, val) )