1.1 --- a/MoinSupport.py Fri Jun 07 23:41:04 2013 +0200
1.2 +++ b/MoinSupport.py Fri Jun 14 00:44:13 2013 +0200
1.3 @@ -3,11 +3,12 @@
1.4 MoinMoin - MoinSupport library (derived from EventAggregatorSupport)
1.5
1.6 @copyright: 2008, 2009, 2010, 2011, 2012, 2013 by Paul Boddie <paul@boddie.org.uk>
1.7 - @copyright: 2000-2004 Juergen Hermann <jh@web.de>,
1.8 - 2004 by Florian Festi,
1.9 - 2006 by Mikko Virkkil,
1.10 - 2005-2008 MoinMoin:ThomasWaldmann,
1.11 - 2007 MoinMoin:ReimarBauer.
1.12 + @copyright: 2000-2004 Juergen Hermann <jh@web.de>
1.13 + 2004 by Florian Festi
1.14 + 2006 by Mikko Virkkil
1.15 + 2005-2008 MoinMoin:ThomasWaldmann
1.16 + 2007 MoinMoin:ReimarBauer
1.17 + 2008 MoinMoin:FlorianKrupicka (redirectedOutput code)
1.18 @license: GNU GPL (v2 or later), see COPYING.txt for details.
1.19 """
1.20
1.21 @@ -767,6 +768,26 @@
1.22
1.23 # Page parsing and formatting of embedded content.
1.24
1.25 +def getOutputTypes(request, format):
1.26 +
1.27 + """
1.28 + Using the 'request' and the 'format' of a fragment, return the media types
1.29 + available for the fragment.
1.30 + """
1.31 +
1.32 + return getParserOutputTypes(getParserClass(request, format))
1.33 +
1.34 +def getParserOutputTypes(parser):
1.35 +
1.36 + "Return the media types supported by the given 'parser'."
1.37 +
1.38 + # This uses an extended parser API method if available.
1.39 +
1.40 + if parser and hasattr(parser, "getOutputTypes"):
1.41 + return parser.getOutputTypes()
1.42 + else:
1.43 + return ["text/html"]
1.44 +
1.45 def getPageParserClass(request):
1.46
1.47 "Using 'request', return a parser class for the current page's format."
1.48 @@ -820,6 +841,21 @@
1.49 finally:
1.50 request.formatter = old_fmt
1.51
1.52 +def formatTextForOutputType(text, request, parser_cls, output_type):
1.53 +
1.54 + """
1.55 + Format the given 'text' using the specified 'request' and parser class
1.56 + 'parser_cls', producing output of the given 'output_type'.
1.57 + """
1.58 +
1.59 + parser = parser_cls(text, request)
1.60 + buf = StringIO()
1.61 + try:
1.62 + parser.formatForOutputType(output_type, buf.write)
1.63 + return buf.getvalue()
1.64 + finally:
1.65 + buf.close()
1.66 +
1.67 def redirectedOutput(request, parser, fmt, **kw):
1.68
1.69 "A fixed version of the request method of the same name."
2.1 --- a/README.txt Fri Jun 07 23:41:04 2013 +0200
2.2 +++ b/README.txt Fri Jun 14 00:44:13 2013 +0200
2.3 @@ -76,6 +76,7 @@
2.4 * Added a common wikidict entry parsing function.
2.5 * Added a superuser parameter to getWikiDict to make the function usable by
2.6 auth handlers.
2.7 + * Added various parsing and formatting utility methods for enhanced parsers.
2.8
2.9 New in MoinSupport 0.3 (Changes since MoinSupport 0.2)
2.10 ------------------------------------------------------
3.1 --- a/docs/COPYING.txt Fri Jun 07 23:41:04 2013 +0200
3.2 +++ b/docs/COPYING.txt Fri Jun 14 00:44:13 2013 +0200
3.3 @@ -8,7 +8,11 @@
3.4 and are thus covered by the following copyrights:
3.5
3.6 Copyright (C) 2000-2004 Juergen Hermann <jh@web.de>
3.7 +Copyright (C) 2004 by Florian Festi
3.8 Copyright (C) 2005-2008 MoinMoin:ThomasWaldmann
3.9 +Copyright (C) 2006 by Mikko Virkkil
3.10 +Copyright (C) 2007 MoinMoin:ReimarBauer
3.11 +Copyright (C) 2008 MoinMoin:FlorianKrupicka (redirectedOutput code)
3.12
3.13 This software is free software; you can redistribute it and/or
3.14 modify it under the terms of the GNU General Public License as