(a, b)
| 15 | |
| 16 | |
| 17 | def _highlight_diff(a, b): |
| 18 | # begin of mdpopups code view |
| 19 | yield '<div class="highlight">' |
| 20 | cruncher = difflib.SequenceMatcher(None, a, b, False) |
| 21 | for tag, alo, ahi, blo, bhi in cruncher.get_opcodes(): |
| 22 | if tag == 'replace': |
| 23 | g = _fancy_replace(a, alo, ahi, b, blo, bhi) |
| 24 | elif tag == 'delete': |
| 25 | g = _dump_lines('del', a, alo, ahi) |
| 26 | elif tag == 'insert': |
| 27 | g = _dump_lines('ins', b, blo, bhi) |
| 28 | elif tag == 'equal': |
| 29 | g = _dump_lines(None, a, alo, ahi) |
| 30 | else: |
| 31 | raise ValueError('unknown tag {0}'.format(tag)) |
| 32 | yield from g |
| 33 | # end of mdpopups code view |
| 34 | yield '</div>' |
| 35 | |
| 36 | |
| 37 | def _plain_replace(a, alo, ahi, b, blo, bhi): |
no test coverage detected