core.html_diff
Diffs HTML fragments. Nice to show what changed between two revisions of a document for an arbitrary user.
Examples: .. code-block:: pycon
>>> from htmldiff import render_html_diff
>>> render_html_diff('Foo <b>bar</b> baz', 'Foo <i>bar</i> baz')
'<div class="diff">Foo <i class="tagdiff_replaced">bar</i> baz</div>'
>>> render_html_diff('Foo bar baz', 'Foo baz')
'<div class="diff">Foo <del>bar</del> baz</div>'
>>> render_html_diff('Foo baz', 'Foo blah baz')
'<div class="diff">Foo <ins>blah</ins> baz</div>'
- copyright:
2011 by Armin Ronacher
- license:
BSD
Attributes
Classes
A class that can diff a stream of Genshi events. It will inject |
Functions
|
Renders a creole diff for two texts. |
|
Renders the diff between two HTML fragments. |
|
Parse an HTML fragment into a Genshi stream. |
Module Contents
- core.html_diff.diff_genshi_stream(old_stream: genshi.core.Stream, new_stream: genshi.core.Stream) genshi.core.Stream [source]
Renders a creole diff for two texts.
- core.html_diff.render_html_diff(old: str, new: str, wrapper_element: str = 'div', wrapper_class: str = 'diff') markupsafe.Markup [source]
Renders the diff between two HTML fragments.
- core.html_diff.parse_html(html: str, wrapper_element: str = 'div', wrapper_class: str = 'diff') genshi.input.ET [source]
Parse an HTML fragment into a Genshi stream.
- class core.html_diff.StreamDiffer(old_stream: genshi.input.ET, new_stream: genshi.input.ET)[source]
A class that can diff a stream of Genshi events. It will inject
<ins>
and<del>
tags into the stream. It probably breaks in very ugly ways if you pass a random Genshi stream to it. I’m not exactly sure if it’s correct what creoleparser is doing here, but it appears that it’s not using a namespace. That’s fine with me so the tags the StreamDiffer adds are also unnamespaced.