ó
ÿgdSc @ sL d Z d d l Z d d l m Z d d l m Z d e f d „ ƒ YZ d S( s
sphinx.websupport.storage.differ
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A differ for creating an HTML representations of proposal diffs
:copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
iÿÿÿÿN( t Differ( t
htmlescapet CombinedHtmlDiffc B sM e Z d Z e j d ƒ Z d „ Z d „ Z d „ Z d d „ Z
d „ Z RS( sU Create an HTML representation of the differences between two pieces
of text.
s ([\+\-\^]+)c C sF t | ƒ } t ƒ } t | j | j d ƒ | j d ƒ ƒ ƒ | _ d S( Ni ( R R t listt comparet
splitlinest diff( t selft sourcet proposalt differ( ( sJ /usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyt __init__ s c C s d j | j ƒ S( Ns
( t joinR ( R ( ( sJ /usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyt make_text s c C s« g } | j } | j d ƒ } | j d ƒ } xg t r— | j | j | | ƒ ƒ | } y | j d ƒ } Wq1 t k
r“ | j | j | ƒ ƒ Pq1 Xq1 Wd j | ƒ j ƒ S( s¸ Return the HTML representation of the differences between
`source` and `proposal`.
:param source: the original text
:param proposal: the proposed text
i t ( R t popt Truet appendt _handle_linet
IndexErrorR t rstrip( R t htmlR t linet next( ( sJ /usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyt make_html" s
c C s¬ | d } | d } | d k r$ | S| d k r4 d S| d k r€ | d d k r€ | d k rb d pe d } | j | | | ƒ } n | d k r’ d p• d
} d | | j ƒ f S(
s$ Handle an individual line in a diff.i i t t ?R t +t inst dels
prop-addeds prop-removeds %s
N( t Nonet _highlight_textR ( R R R t prefixt textt tagt css_class( ( sJ /usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyR 7 s
c C s¹ | d } g } d } x‚ | j j | ƒ D]n } | j | | | j ƒ !ƒ | j d | ƒ | j | | j ƒ | j ƒ !ƒ | j d | ƒ | j ƒ } q) W| j | | ƒ d j | ƒ S( s^ Highlight the specific changes made to a line by adding
and tags.
i i s <%s>s %s>R ( t highlight_regext finditerR t startt endR ( R R! R R" t new_textR&