ó ÿgdSc@sLdZddlZddlmZddlmZdefd„ƒYZdS(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(tDiffer(t htmlescapetCombinedHtmlDiffcBsMeZdZejdƒZd„Zd„Zd„Zdd„Z d„Z RS(sUCreate an HTML representation of the differences between two pieces of text. s ([\+\-\^]+)cCsFt|ƒ}tƒ}t|j|jdƒ|jdƒƒƒ|_dS(Ni(RRtlisttcomparet splitlinestdiff(tselftsourcetproposaltdiffer((sJ/usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyt__init__s  cCsdj|jƒS(Ns (tjoinR(R((sJ/usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyt make_textscCs«g}|j}|jdƒ}|jdƒ}xgtr—|j|j||ƒƒ|}y|jdƒ}Wq1tk r“|j|j|ƒƒPq1Xq1Wdj|ƒjƒS(s¸Return the HTML representation of the differences between `source` and `proposal`. :param source: the original text :param proposal: the proposed text it(RtpoptTruetappendt _handle_linet IndexErrorR trstrip(RthtmlRtlinetnext((sJ/usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyt make_html"s    cCs¬|d}|d}|dkr$|S|dkr4dS|d k r€|ddkr€|dkrbdped}|j|||ƒ}n|dkr’d p•d }d ||jƒfS( s$Handle an individual line in a diff.iit t?Rt+tinstdels prop-addeds prop-removeds%s N(tNonet_highlight_textR(RRRtprefixttextttagt css_class((sJ/usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyR7s    cCs¹|d}g}d}x‚|jj|ƒD]n}|j|||jƒ!ƒ|jd|ƒ|j||jƒ|jƒ!ƒ|jd|ƒ|jƒ}q)W|j||ƒdj|ƒS(s^Highlight the specific changes made to a line by adding and tags. iis<%s>sR(thighlight_regextfinditerRtstarttendR (RR!RR"tnew_textR&tmatch((sJ/usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyRHs  N( t__name__t __module__t__doc__tretcompileR$R R RRRR(((sJ/usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyRs    (R,R-tdifflibRtsphinx.util.pycompatRtobjectR(((sJ/usr/local/lib/python2.7/site-packages/sphinx/websupport/storage/differ.pyt s