diff options
| author | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-06-21 00:11:44 +0000 |
|---|---|---|
| committer | wiemann <wiemann@929543f6-e4f2-0310-98a6-ba3bd3dd1d04> | 2005-06-21 00:11:44 +0000 |
| commit | 4ec9b10c1fc81388dcfc718f7f87d56b2cfe8be4 (patch) | |
| tree | f0d400ad24e408624a89f2e8ef73c8230936dd38 | |
| parent | 8d2616ab18e3881d35037cd11eae69dec6b30ef5 (diff) | |
| download | docutils-4ec9b10c1fc81388dcfc718f7f87d56b2cfe8be4.tar.gz | |
issue a warning rather than an error when no stylesheet is given;
default for "stylesheet" is now None, not -1
git-svn-id: http://svn.code.sf.net/p/docutils/code/trunk@3549 929543f6-e4f2-0310-98a6-ba3bd3dd1d04
| -rw-r--r-- | docutils/HISTORY.txt | 4 | ||||
| -rw-r--r-- | docutils/docs/user/config.txt | 9 | ||||
| -rw-r--r-- | docutils/docutils/writers/html4css1.py | 17 | ||||
| -rw-r--r-- | docutils/test/DocutilsTestSupport.py | 2 |
4 files changed, 15 insertions, 17 deletions
diff --git a/docutils/HISTORY.txt b/docutils/HISTORY.txt index 732e4c903..6966f6949 100644 --- a/docutils/HISTORY.txt +++ b/docutils/HISTORY.txt @@ -49,8 +49,8 @@ Changes Since 0.3.9 - Added support for image width and height units. - Made ``xmlcharrefreplace`` the default output encoding error handler. - - Specifying either ``--stylesheet`` or ``--stylesheet-path`` is - mandatory now. + - A warning is now issued if neither ``--stylesheet`` nor + ``--stylesheet-path`` is specified. - Made ``--embed-stylesheet`` the default rather than ``--link-stylesheet``. diff --git a/docutils/docs/user/config.txt b/docutils/docs/user/config.txt index 73444397f..d7b08bf48 100644 --- a/docutils/docs/user/config.txt +++ b/docutils/docs/user/config.txt @@ -618,8 +618,6 @@ _`initial_header_level` Default: 1 (for "<h1>"). Option: ``--initial-header-level``. -.. _stylesheet [html4css1 writer]: - _`option_limit` The maximum width (in characters) for options in option lists. Longer options will span an entire row of the table used to render @@ -628,11 +626,14 @@ _`option_limit` Default: 14 characters. Option: ``--option-limit``. +.. _stylesheet [html4css1 writer]: + stylesheet CSS stylesheet URL, used verbatim. Overrides stylesheet_path - [#override]_. + [#override]_. Pass an empty string to deactivate stylesheet + inclusion. - Default: "default.css". Options: ``--stylesheet``. + Default: None. Options: ``--stylesheet``. (Setting also defined for the `LaTeX Writer`__.) diff --git a/docutils/docutils/writers/html4css1.py b/docutils/docutils/writers/html4css1.py index 387ebdf77..f20ff2105 100644 --- a/docutils/docutils/writers/html4css1.py +++ b/docutils/docutils/writers/html4css1.py @@ -42,8 +42,7 @@ class Writer(writers.Writer): '--stylesheet-path. Either --stylesheet or --stylesheet-path ' 'must be specified.', ['--stylesheet'], - {'default': -1, 'metavar': '<URL>', - 'overrides': 'stylesheet_path'}), + {'metavar': '<URL>', 'overrides': 'stylesheet_path'}), ('Specify a stylesheet file, relative to the current working ' 'directory. The path is adjusted relative to the output HTML ' 'file. Overrides --stylesheet.', @@ -217,24 +216,22 @@ class HTMLTranslator(nodes.NodeVisitor): self.html_prolog.append(self.doctype) self.head = self.meta[:] stylesheet = utils.get_stylesheet_reference(settings) - if stylesheet == -1: - raise ValueError( + self.stylesheet = [] + if stylesheet is None: + self.document.reporter.warning( 'No stylesheet path or URI given.\nUse the --stylesheet ' 'or --stylesheet-path option to specify the location of\n' 'default.css (in the tools/stylesheets/ directory ' - 'of the Docutils distribution).') - if settings.embed_stylesheet and stylesheet: + 'of the Docutils distribution).\n') + elif settings.embed_stylesheet and stylesheet: stylesheet = utils.get_stylesheet_reference(settings, os.path.join(os.getcwd(), 'dummy')) settings.record_dependencies.add(stylesheet) stylesheet_text = open(stylesheet).read() self.stylesheet = [self.embedded_stylesheet % stylesheet_text] - else: - if stylesheet: + elif stylesheet: self.stylesheet = [self.stylesheet_link % self.encode(stylesheet)] - else: - self.stylesheet = [] self.body_prefix = ['</head>\n<body>\n'] # document title, subtitle display self.body_pre_docinfo = [] diff --git a/docutils/test/DocutilsTestSupport.py b/docutils/test/DocutilsTestSupport.py index f1fa277a7..5452f1929 100644 --- a/docutils/test/DocutilsTestSupport.py +++ b/docutils/test/DocutilsTestSupport.py @@ -715,7 +715,7 @@ class HtmlWriterPublishPartsTestCase(WriterPublishTestCase): settings_default_overrides = \ WriterPublishTestCase.settings_default_overrides.copy() - settings_default_overrides['stylesheet'] = None + settings_default_overrides['stylesheet'] = '' def __init__(self, *args, **kwargs): self.settings_overrides = kwargs['settings_overrides'] |
