Edgewall Software

Ticket #4356: trac_wiki_creole-r4428.patch

File trac_wiki_creole-r4428.patch, 2.9 KB (added by cboos, 3 years ago)

Adapt Trac WikiFormatting to be more compatible with WikiCreole

  • trac/wiki/formatter.py

     
    152152 
    153153    BOLDITALIC_TOKEN = "'''''" 
    154154    BOLD_TOKEN = "'''" 
     155    BOLD_TOKEN_WC = r"\*\*" 
    155156    ITALIC_TOKEN = "''" 
     157    ITALIC_TOKEN_WC = "//" 
    156158    UNDERLINE_TOKEN = "__" 
    157159    STRIKE_TOKEN = "~~" 
    158160    SUBSCRIPT_TOKEN = ",," 
     
    182184        # Font styles 
    183185        r"(?P<bolditalic>!?%s)" % BOLDITALIC_TOKEN, 
    184186        r"(?P<bold>!?%s)" % BOLD_TOKEN, 
     187        r"(?P<bold_wc>!?%s)" % BOLD_TOKEN_WC, 
    185188        r"(?P<italic>!?%s)" % ITALIC_TOKEN, 
     189        r"(?P<italic_wc>!?%s)" % ITALIC_TOKEN_WC, 
    186190        r"(?P<underline>!?%s)" % UNDERLINE_TOKEN, 
    187191        r"(?P<strike>!?%s)" % STRIKE_TOKEN, 
    188192        r"(?P<subscript>!?%s)" % SUBSCRIPT_TOKEN, 
     
    199203        r"(?P<citation>^(?P<cdepth>>(?: *>)*))", 
    200204        # &, < and > to &amp;, &lt; and &gt; 
    201205        r"(?P<htmlescape>[&<>])", 
     206        # [[macro]] call 
     207        (r"(?P<macro>!?\[\[(?P<macroname>[\w/+-]+)" 
     208         r"(\]\]|\((?P<macroargs>.*?)\)\]\]))"), 
    202209        # wiki:TracLinks 
    203210        r"(?P<shref>!?((?P<sns>%s):(?P<stgt>%s|%s(?:%s*%s)?)))" \ 
    204211        % (LINK_SCHEME, QUOTED_STRING, 
    205212           SHREF_TARGET_FIRST, SHREF_TARGET_MIDDLE, SHREF_TARGET_LAST), 
    206213        # [wiki:TracLinks with optional label] or [/relative label] 
    207         (r"(?P<lhref>!?\[(?:" 
     214        (r"(?P<lhref>!?\[\[?(?:" 
    208215         r"(?P<rel>%s)|" % LHREF_RELATIVE_TARGET + # ./... or /... 
    209          r"(?P<lns>%s):(?P<ltgt>%s|[^\]\s]*))" % \ 
     216         r"(?P<lns>%s):(?P<ltgt>%s|[^\]\s\|]*))" % \ 
    210217         (LINK_SCHEME, QUOTED_STRING) + # wiki:TracLinks or wiki:"trac links" 
    211          r"(?:\s+(?P<label>%s|[^\]]+))?\])" % QUOTED_STRING), # optional label 
    212         # [[macro]] call 
    213         (r"(?P<macro>!?\[\[(?P<macroname>[\w/+-]+)" 
    214          r"(\]\]|\((?P<macroargs>.*?)\)\]\]))"), 
     218         r"(?:(?:\s+|\|)(?P<label>%s|[^\]]+))?\]\]?)" % QUOTED_STRING), # label 
    215219        # == heading == #hanchor 
    216220        r"(?P<heading>^\s*(?P<hdepth>=+)\s.*\s(?P=hdepth)\s*" 
    217221        r"(?P<hanchor>#%s)?$)" % XML_NAME, 
     
    302306 
    303307    def _bold_formatter(self, match, fullmatch): 
    304308        return self.simple_tag_handler(match, '<strong>', '</strong>') 
     309    # should be <b> 
    305310 
     311    def _bold_wc_formatter(self, match, fullmatch): 
     312        return self.simple_tag_handler(match, '<b>', '</b>') 
     313    # should be <strong> 
     314 
    306315    def _italic_formatter(self, match, fullmatch): 
    307316        return self.simple_tag_handler(match, '<i>', '</i>') 
    308317 
     318    def _italic_wc_formatter(self, match, fullmatch): 
     319        return self.simple_tag_handler(match, '<em>', '</em>') 
     320 
    309321    def _underline_formatter(self, match, fullmatch): 
    310322        return self.simple_tag_handler(match, '<span class="underline">', 
    311323                                       '</span>')