# HG changeset patch # User Paul Boddie # Date 1389713858 -3600 # Node ID 3436816d7ea08f0cb9f32811c6acf92d5c8994de # Parent 9476faf9055d2bf9b69977b2836751739dffecf1 Fixed the formatting of calendar pages and regions by overriding the page parser when formatting text. diff -r 9476faf9055d -r 3436816d7ea0 EventAggregatorSupport/Formatting.py --- a/EventAggregatorSupport/Formatting.py Tue Jan 14 14:51:01 2014 +0100 +++ b/EventAggregatorSupport/Formatting.py Tue Jan 14 16:37:38 2014 +0100 @@ -2,7 +2,7 @@ """ MoinMoin - EventAggregator event formatting - @copyright: 2008, 2009, 2010, 2011, 2012, 2013 by Paul Boddie + @copyright: 2008, 2009, 2010, 2011, 2012, 2013, 2014 by Paul Boddie @copyright: 2000-2004 Juergen Hermann , 2005-2008 MoinMoin:ThomasWaldmann. @license: GNU GPL (v2 or later), see COPYING.txt for details. @@ -18,11 +18,15 @@ # Event-only formatting. -def formatEvent(event, request, fmt, write=None): +def formatEvent(event, request, fmt, write=None, parser_cls=None): """ Format the given 'event' using the 'request' and formatter 'fmt'. If the 'write' parameter is specified, use it to write output. + + Where 'parser_cls' is specified, override the parser used to format text. + This is essential when dealing with calendar format pages since the page + parser will be unable to handle arbitrary fragments of text. """ details = event.getDetails() @@ -35,7 +39,7 @@ # Promote any title to a heading above the event details. if raw_details.has_key("title"): - write(formatText(raw_details["title"], request, fmt)) + write(formatText(raw_details["title"], request, fmt, parser_cls=parser_cls)) elif details.has_key("title"): write(fmt.heading(on=1, depth=1)) write(fmt.text(details["title"])) @@ -61,13 +65,13 @@ # Try and use the raw details, if available. if raw_value: - write(formatText(raw_value, request, fmt)) + write(formatText(raw_value, request, fmt, parser_cls=parser_cls)) # Otherwise, format the processed details. else: if term in event.list_terms: - write(", ".join([formatText(unicode(v), request, fmt) for v in value])) + write(", ".join([formatText(unicode(v), request, fmt, parser_cls=parser_cls) for v in value])) else: write(fmt.text(unicode(value))) diff -r 9476faf9055d -r 3436816d7ea0 parsers/calendar.py --- a/parsers/calendar.py Tue Jan 14 14:51:01 2014 +0100 +++ b/parsers/calendar.py Tue Jan 14 16:37:38 2014 +0100 @@ -6,7 +6,7 @@ @license: GNU GPL (v2 or later), see COPYING.txt for details. """ -from MoinSupport import parseAttributes +from MoinSupport import parseAttributes, RawParser from EventAggregatorSupport.Formatting import formatEventsForOutputType, \ formatEvent from EventAggregatorSupport.Types import parseEvents, EventCalendar @@ -64,7 +64,7 @@ calendar = EventCalendar("", vCalendar.parse(f), {}) for event in calendar.getEvents(): - formatEvent(event, self.request, fmt, write=write) + formatEvent(event, self.request, fmt, write=write, parser_cls=RawParser) # Extra API methods.