Wagtail Custom Revisions Diffing #11730
skelzor06
started this conversation in
Development
Replies: 1 comment 3 replies
-
You can try this ( # in wagtail_hooks.py
from wagtail.admin.compare import register_comparison_class, TextFieldComparison
class MarkdownComparison(TextFieldComparison):
def htmldiff(self):
return diff_text(
markdown_from_html(self.val_a), markdown_from_html(self.val_b)
).to_html()
register_comparison_class(RichTextField, comparison_class=MarkdownComparison) It will apply to all RTF fields, so if you need more control, you may have to subclass RTF and pass |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I've been using Wagtail for while now and I'm trying to change the behavior of revision diffing. No it turns the RTF into a flat string and compare, right? Would be possible for me, somehow, to maybe override RichTextFieldComparison in my own project to convert html to a markdown and then compare? Since markdown is also a kind of text, maybe it will show a better comparison.
Beta Was this translation helpful? Give feedback.
All reactions