Override pytidylib's BASE_OPTIONS explicitly.
authorAdam Sampson <ats@offog.org>
Mon, 11 Jun 2018 19:30:33 +0000 (20:30 +0100)
committerAdam Sampson <ats@offog.org>
Mon, 11 Jun 2018 19:30:33 +0000 (20:30 +0100)
This variable has moved from tidylib.BASE_OPTIONS to
tidylib.tidy.BASE_OPTIONS as of pytidylib 0.3.2.

NEWS
rawdoglib/rawdog.py

diff --git a/NEWS b/NEWS
index 2e7d5e2fe32850691c703103319e5bd3a5967a30..161290b589e5b101d86a56b6f007aff5b77d67fc 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -7,6 +7,9 @@ of the feed in question).
 Add the --find option, which shows what feedscanner returns for a given
 URL (as --dump does for feedparser).
 
+The location of BASE_OPTIONS has changed in pytidylib 0.3.2; rather than
+trying to change it, override the corresponding options explicitly.
+
 - rawdog 2.22
 
 When handling an HTTP 301 redirect response, check whether the new
index 5c4eaa86d745564328a6b42b72a5de57c87462e2..5731593459b5a12d909728b1628172aded4ae169 100644 (file)
@@ -134,20 +134,27 @@ def sanitise_html(html, baseurl, inline, config):
                        html = "<p>" + html
 
        if config["tidyhtml"]:
+               # This must include: options where the default value in tidy
+               # has changed at some point, and pytidylib's BASE_OPTIONS which
+               # it would otherwise set if we didn't specify them.
                args = {
                        "numeric_entities": 1,
+                       # In tidy 0.99 these are ASCII; in tidy 5, UTF-8.
                        "input_encoding": "ascii",
                        "output_encoding": "ascii",
                        "output_html": 1,
                        "output_xhtml": 0,
                        "output_xml": 0,
+                       "indent": 0,
+                       "tidy-mark": 0,
+                       "alt-text": "",
+                       "doctype": "strict",
+                       "force-output": 1,
                        "wrap": 0,
                        }
                call_hook("mxtidy_args", config, args, baseurl, inline)
                call_hook("tidy_args", config, args, baseurl, inline)
                if tidylib is not None:
-                       # Disable PyTidyLib's somewhat unhelpful defaults.
-                       tidylib.BASE_OPTIONS = {}
                        output = tidylib.tidy_document(html, args)[0]
                elif mxtidy is not None:
                        output = mxtidy.tidy(html, None, None, **args)[2]