[ZWeb] FYI: Next step on news
Chris McDonough
chrism@zope.com
19 Nov 2002 10:21:51 -0500
Here's two little scripts that might be useful here.
The first takes a STX document, find all the inline URIs, and link them
using STX notation.
The second takes a stx document and renders it to HTML (presumes your
Zope SOFTWARE_HOME is on your PYTHONPATH).
-- linkmaker --
#!/usr/bin/env python2.1
from string import letters
import re, sys
url_expr=re.compile(r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\+\@\.\,\?\!\/\:\;\-\#\~\=\&\%%]+)' % letters)
def makelinks(file):
while 1:
line = file.readline()
if not line: break
line = url_expr.sub(r'"\1":\1', line)
sys.stdout.write(line)
if __name__ == '__main__':
f = open(sys.argv[1])
makelinks(f)
-- render stx to html ---
#!/usr/bin/env python2.1
import StructuredText
import sys
def main(f):
f = open(f).read()
stx = StructuredText.Basic(f)
doc = StructuredText.DocumentWithImages(stx)
html = StructuredText.HTML(doc)
print html
if __name__ == '__main__':
main(sys.argv[1])
On Tue, 2002-11-19 at 09:55, Martijn Pieters wrote:
> On Tue, Nov 19, 2002 at 03:03:21PM +0100, Paul Everitt wrote:
> > Hmm, this format yields something not quite like the original.
> > Basically, it make sit look like footnotes, which makes sense for a
> > footnote. :^) However, people might want the original to have the
> > hyperlinks as part of the text being hyperlinked, rather jumping down
> > to a named link to then jump to the target.
> >
> > Also, the format you showed doesn't turn the URL in the citation into a
> > hyperlink for the rendered version. You would have to cut-and-paste it
> > into the browser.
> >
> > If I'm incorrect on this, could you point me at a URL that shows the
> > right behavior in action?
>
> Darn, you are correct. Only ZWiki renders inline URLs with an A HREF. Oh
> well, so much for that idea.
>
> --
> Martijn Pieters
> | Software Engineer mailto:mj@zope.com
> | Zope Corporation http://www.zope.com/
> | Creators of Zope http://www.zope.org/
> ---------------------------------------------
>
> _______________________________________________
> Zope-web maillist - Zope-web@zope.org
> http://lists.zope.org/mailman/listinfo/zope-web