Code Monkey home page Code Monkey logo

rich_text_diff's Introduction

支持富文本的文本对比

import rich_text_diff as diff

new_content = u'<p>\u4eca\u5929\u5929\u6c14\u8fd8\u4e0d\u9519</p><p>\u4eca\u5929\u5929\u6c14\u8fd8\u4e0d\u9519</p><img src="v2-0fdfbce4409625a81e0bd210baf4a7ee.jpg" data-caption="" data-size="normal" data-rawwidth="640" data-rawheight="618" data-watermark="watermark" data-original-src="v2-0fdfbce4409625a81e0bd210baf4a7ee" data-watermark-src="v2-c53c9358c4191a0348eaf3324d20cbfa" data-private-watermark-src=""><p>\u4eca\u5929\u5929\u6c14\u8fd8\u4e0d\u9519</p><video id="None" data-swfurl="" poster="https://pic2.zhimg.com/80/v2-d98a74d35a1d369fd07b1aba5a5e2071_b.jpg" data-sourceurl="https://www.zhihu.com/video/987659040658411520" data-name="" data-video-id="" data-video-playable="true" data-lens-id="987659040658411520"></video><p></p>'
old_content = u'<p>\u4eca\u5929\u5929\u6c14\u8fd8233</p><p>\u4eca\u5929\u5929\u6c14\u8fd8\u4e0d\u9519</p><img src="v2-0fdfbce4409625a81e0bd210baf4a7ee.jpg" data-caption="\u56fe\u7247\u6ce8\u91ca233" data-size="normal" data-rawwidth="640" data-rawheight="618" data-watermark="watermark" data-original-src="v2-0fdfbce4409625a81e0bd210baf4a7ee" data-watermark-src="v2-c53c9358c4191a0348eaf3324d20cbfa" data-private-watermark-src=""><p><br></p><img src="v2-724ec2687676e21539028c54a317a491.jpg" data-caption="" data-size="normal" data-rawwidth="363" data-rawheight="393" data-watermark="watermark" data-original-src="v2-724ec2687676e21539028c54a317a491" data-watermark-src="v2-5cfd32fae8f6254e904c12a95cd1a0b9" data-private-watermark-src=""><p>\u4eca\u5929\u5929\u6c14\u8fd8\u4e0d\u9519</p><video id="None" data-swfurl="" poster="https://pic2.zhimg.com/80/v2-d98a74d35a1d369fd07b1aba5a5e2071_b.jpg" data-sourceurl="https://www.zhihu.com/video/987659040658411520" data-name="\u89c6\u9891\u6807\u9898233" data-video-id="" data-video-playable="true" data-lens-id="987659040658411520"></video><video id="None" data-swfurl="" poster="https://pic1.zhimg.com/80/v2-9b44fdebaec8e7cf8b24d934a914c454_b.jpg" data-sourceurl="https://www.zhihu.com/video/987663649024090113" data-name="" data-video-id="" data-video-playable="true" data-lens-id="987663649024090113"></video><p></p>'

print diff.ContentDiff(new_content, old_content).diff()

rich_text_diff's People

Contributors

c1ay avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.