diff --git a/docs/changelog.rst b/docs/changelog.rst
index bbe0e76c..064c8fd2 100644
--- a/docs/changelog.rst
+++ b/docs/changelog.rst
@@ -10,7 +10,7 @@ Next release
* Deprecate ``FILES_TO_COPY`` in favor of ``STATIC_PATHS`` and
``EXTRA_PATH_METADATA``
* Add support for ``{}`` in relative links syntax, besides ``||``
-* Add support for |tag| and |category| relative links
+* Add support for ``{tag}`` and ``{category}`` relative links
3.2.1 and 3.2.2
===============
diff --git a/docs/getting_started.rst b/docs/getting_started.rst
index d7a36080..2605c3a1 100644
--- a/docs/getting_started.rst
+++ b/docs/getting_started.rst
@@ -533,6 +533,9 @@ which posts are translations::
That's true, foobar is still alive!
+
+.. _internal_pygments_options:
+
Syntax highlighting
-------------------
@@ -556,6 +559,65 @@ indenting both the identifier and code::
The specified identifier (e.g. ``python``, ``ruby``) should be one that
appears on the `list of available lexers `_.
+When using reStructuredText the following options are available in the
+code-block directive:
+
+============= ============ =========================================
+Option Valid values Description
+============= ============ =========================================
+anchorlinenos N/A If present wrap line numbers in tags.
+classprefix string String to prepend to token class names
+hl_lines numbers List of lines to be highlighted.
+lineanchors string Wrap each line in an anchor using this
+ string and -linenumber.
+linenos string If present or set to "table" output line
+ numbers in a table, if set to
+ "inline" output them inline. "none" means
+ do not output the line numbers for this
+ table.
+linenospecial number If set every nth line will be given the
+ 'special' css class.
+linenostart number Line number for the first line.
+linenostep number Print every nth line number.
+lineseparator string String to print between lines of code,
+ '\n' by default.
+linespans string Wrap each line in a span using this and
+ -linenumber.
+nobackground N/A If set do not output background color for
+ the wrapping element
+nowrap N/A If set do not wrap the tokens at all.
+tagsfile string ctags file to use for name definitions.
+tagurlformat string format for the ctag links.
+============= ============ =========================================
+
+Note that, depending on its version, your pygments module might not have
+all of these available. See the `Pygments documentation
+`_ for the HTML formatter for more
+details on each of the options.
+
+for example the below code block enables line numbers, starting at 153,
+and prefixes the Pygments CSS classes with *pgcss* to make the names
+more unique and avoid possible CSS conflicts::
+
+ .. code-block:: identifier
+ :classprefix: pgcss
+ :linenos: table
+ :linenostart: 153
+
+
+
+It is also possible to specify the ``PYGMENTS_RST_OPTIONS`` variable
+in your Pelican configuration file for settings that will be
+automatically applied to every code block.
+
+For example, if you wanted to have line numbers on for every code block
+and a CSS prefix you would set this variable to::
+
+ PYGMENTS_RST_OPTIONS = { 'classprefix': 'pgcss', 'linenos': 'table'}
+
+If specified, settings for individual code blocks will override the
+defaults in the configuration file.
+
Publishing drafts
-----------------
diff --git a/docs/settings.rst b/docs/settings.rst
index d021bcb0..e8965731 100644
--- a/docs/settings.rst
+++ b/docs/settings.rst
@@ -161,6 +161,9 @@ Setting name (default value) What doe
to enclose the identifier, say ``filename``, in ``{}`` or ``||``.
Identifier between ``{`` and ``}`` goes into the ``what`` capturing group.
For details see :ref:`ref-linking-to-internal-content`.
+`PYGMENTS_RST_OPTIONS` (``[]``) A list of default Pygments settings for your reStructuredText
+ code blocks. See :ref:`internal_pygments_options` for a list of
+ supported options.
===================================================================== =====================================================================
.. [#] Default is the system locale.
@@ -602,7 +605,10 @@ Setting name (default value) What does it do?
`THEME_STATIC_PATHS`. Default is `theme`.
`THEME_STATIC_PATHS` (``['static']``) Static theme paths you want to copy. Default
value is `static`, but if your theme has
- other static paths, you can put them here.
+ other static paths, you can put them here. If files
+ or directories with the same names are included in
+ the paths defined in this settings, they will be
+ progressively overwritten.
`CSS_FILE` (``'main.css'``) Specify the CSS file you want to load.
================================================ =====================================================
diff --git a/pelican/generators.py b/pelican/generators.py
index 26fa40ea..d695c7c8 100644
--- a/pelican/generators.py
+++ b/pelican/generators.py
@@ -544,7 +544,7 @@ class StaticGenerator(Generator):
"""Copy all the paths from source to destination"""
for path in paths:
copy(path, source, os.path.join(output_path, destination),
- final_path, overwrite=True)
+ final_path)
def generate_context(self):
self.staticfiles = []
diff --git a/pelican/rstdirectives.py b/pelican/rstdirectives.py
index 33ed2f03..1bf6971c 100644
--- a/pelican/rstdirectives.py
+++ b/pelican/rstdirectives.py
@@ -7,6 +7,8 @@ from pygments.formatters import HtmlFormatter
from pygments import highlight
from pygments.lexers import get_lexer_by_name, TextLexer
import re
+import six
+import pelican.settings as pys
class Pygments(Directive):
@@ -41,9 +43,19 @@ class Pygments(Directive):
# no lexer found - use the text one instead of an exception
lexer = TextLexer()
+ # Fetch the defaults
+ if pys.PYGMENTS_RST_OPTIONS is not None:
+ for k, v in six.iteritems(pys.PYGMENTS_RST_OPTIONS):
+ # Locally set options overrides the defaults
+ if k not in self.options:
+ self.options[k] = v
+
if ('linenos' in self.options and
self.options['linenos'] not in ('table', 'inline')):
- self.options['linenos'] = 'table'
+ if self.options['linenos'] == 'none':
+ self.options.pop('linenos')
+ else:
+ self.options['linenos'] = 'table'
for flag in ('nowrap', 'nobackground', 'anchorlinenos'):
if flag in self.options:
diff --git a/pelican/settings.py b/pelican/settings.py
index 1c2db677..99828935 100644
--- a/pelican/settings.py
+++ b/pelican/settings.py
@@ -107,12 +107,15 @@ DEFAULT_CONFIG = {
'SUMMARY_MAX_LENGTH': 50,
'PLUGIN_PATH': '',
'PLUGINS': [],
+ 'PYGMENTS_RST_OPTIONS': {},
'TEMPLATE_PAGES': {},
'IGNORE_FILES': ['.#*'],
'SLUG_SUBSTITUTIONS': (),
'INTRASITE_LINK_REGEX': '[{|](?P.*?)[|}]',
}
+PYGMENTS_RST_OPTIONS = None
+
def read_settings(path=None, override=None):
if path:
@@ -131,7 +134,14 @@ def read_settings(path=None, override=None):
if override:
local_settings.update(override)
- return configure_settings(local_settings)
+ parsed_settings = configure_settings(local_settings)
+ # This is because there doesn't seem to be a way to pass extra
+ # parameters to docutils directive handlers, so we have to have a
+ # variable here that we'll import from within Pygments.run (see
+ # rstdirectives.py) to see what the user defaults were.
+ global PYGMENTS_RST_OPTIONS
+ PYGMENTS_RST_OPTIONS = parsed_settings.get('PYGMENTS_RST_OPTIONS', None)
+ return parsed_settings
def get_settings_from_module(module=None, default_settings=DEFAULT_CONFIG):
diff --git a/pelican/tests/output/basic/category/misc.html b/pelican/tests/output/basic/category/misc.html
index e0dfd4e4..5b8af887 100644
--- a/pelican/tests/output/basic/category/misc.html
+++ b/pelican/tests/output/basic/category/misc.html
@@ -86,11 +86,11 @@
Testing sourcecode directive
| formatter = self.options and VARIANTS[self.options.keys()[0]]
- |
Lovely.
-
-
-
Testing more sourcecode directives
-
8 def run(self):
self.assert_has_content()
10 try:
lexer = get_lexer_by_name(self.arguments[0])
12 except ValueError ...
+
+
+
Testing another case
+
This will now have a line number in 'custom' since it's the default in
+pelican.conf, it ...
read more
diff --git a/pelican/tests/output/basic/feeds/all-en.atom.xml b/pelican/tests/output/basic/feeds/all-en.atom.xml
index 5b8eb591..da537344 100644
--- a/pelican/tests/output/basic/feeds/all-en.atom.xml
+++ b/pelican/tests/output/basic/feeds/all-en.atom.xml
@@ -31,7 +31,14 @@ YEAH !</p>
<h2>Testing sourcecode directive</h2>
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
</pre></div>
-</td></tr></table><p>Lovely.</p>
+</td></tr></table></div>
+<div class="section" id="testing-another-case">
+<h2>Testing another case</h2>
+<p>This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
</div>
<div class="section" id="testing-more-sourcecode-directives">
<h2>Testing more sourcecode directives</h2>
@@ -43,5 +50,12 @@ YEAH !</p>
<span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
<p>Lovely.</p>
</div>
+<div class="section" id="testing-overriding-config-defaults">
+<h2>Testing overriding config defaults</h2>
+<p>Even if the default is line numbers, we can override it here</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
+</div>
The baz tag2010-03-14T00:00:00Ztag:,2010-03-14:tag/baz.html<p>This article overrides the listening of the articles under the <em>baz</em> tag.</p>
\ No newline at end of file
diff --git a/pelican/tests/output/basic/feeds/all.atom.xml b/pelican/tests/output/basic/feeds/all.atom.xml
index d19b0c30..d837c895 100644
--- a/pelican/tests/output/basic/feeds/all.atom.xml
+++ b/pelican/tests/output/basic/feeds/all.atom.xml
@@ -32,7 +32,14 @@ YEAH !</p>
<h2>Testing sourcecode directive</h2>
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
</pre></div>
-</td></tr></table><p>Lovely.</p>
+</td></tr></table></div>
+<div class="section" id="testing-another-case">
+<h2>Testing another case</h2>
+<p>This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
</div>
<div class="section" id="testing-more-sourcecode-directives">
<h2>Testing more sourcecode directives</h2>
@@ -44,5 +51,12 @@ YEAH !</p>
<span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
<p>Lovely.</p>
</div>
+<div class="section" id="testing-overriding-config-defaults">
+<h2>Testing overriding config defaults</h2>
+<p>Even if the default is line numbers, we can override it here</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
+</div>
The baz tag2010-03-14T00:00:00Ztag:,2010-03-14:tag/baz.html<p>This article overrides the listening of the articles under the <em>baz</em> tag.</p>
\ No newline at end of file
diff --git a/pelican/tests/output/basic/feeds/misc.atom.xml b/pelican/tests/output/basic/feeds/misc.atom.xml
index 34b6b4fb..8b988614 100644
--- a/pelican/tests/output/basic/feeds/misc.atom.xml
+++ b/pelican/tests/output/basic/feeds/misc.atom.xml
@@ -8,7 +8,14 @@
<h2>Testing sourcecode directive</h2>
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
</pre></div>
-</td></tr></table><p>Lovely.</p>
+</td></tr></table></div>
+<div class="section" id="testing-another-case">
+<h2>Testing another case</h2>
+<p>This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
</div>
<div class="section" id="testing-more-sourcecode-directives">
<h2>Testing more sourcecode directives</h2>
@@ -20,5 +27,12 @@
<span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
<p>Lovely.</p>
</div>
+<div class="section" id="testing-overriding-config-defaults">
+<h2>Testing overriding config defaults</h2>
+<p>Even if the default is line numbers, we can override it here</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
+</div>
The baz tag2010-03-14T00:00:00Ztag:,2010-03-14:tag/baz.html<p>This article overrides the listening of the articles under the <em>baz</em> tag.</p>
\ No newline at end of file
diff --git a/pelican/tests/output/basic/index.html b/pelican/tests/output/basic/index.html
index 08c4ad09..24b00606 100644
--- a/pelican/tests/output/basic/index.html
+++ b/pelican/tests/output/basic/index.html
@@ -219,11 +219,11 @@ YEAH !
Testing sourcecode directive
| formatter = self.options and VARIANTS[self.options.keys()[0]]
- |
Lovely.
-
-
-
Testing more sourcecode directives
-
8 def run(self):
self.assert_has_content()
10 try:
lexer = get_lexer_by_name(self.arguments[0])
12 except ValueError ...
+
+
+
Testing another case
+
This will now have a line number in 'custom' since it's the default in
+pelican.conf, it ...
read more
diff --git a/pelican/tests/output/basic/unbelievable.html b/pelican/tests/output/basic/unbelievable.html
index db8d0bdf..aef78474 100644
--- a/pelican/tests/output/basic/unbelievable.html
+++ b/pelican/tests/output/basic/unbelievable.html
@@ -47,7 +47,14 @@
Testing sourcecode directive
| formatter = self.options and VARIANTS[self.options.keys()[0]]
- |
Lovely.
+
+
+
Testing another case
+
This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.
+
formatter = self.options and VARIANTS[self.options.keys()[0]]
+
+
Lovely.
Testing more sourcecode directives
@@ -58,6 +65,13 @@
Testing even more sourcecode directives
formatter = self.options and VARIANTS[self.options.keys()[0]]
Lovely.
+
+
+
Testing overriding config defaults
+
Even if the default is line numbers, we can override it here
+
formatter = self.options and VARIANTS[self.options.keys()[0]]
+
+
Lovely.
diff --git a/pelican/tests/output/custom/author/alexis-metaireau3.html b/pelican/tests/output/custom/author/alexis-metaireau3.html
index 4b598914..77c9cdfe 100644
--- a/pelican/tests/output/custom/author/alexis-metaireau3.html
+++ b/pelican/tests/output/custom/author/alexis-metaireau3.html
@@ -55,11 +55,11 @@
Testing sourcecode directive
| formatter = self.options and VARIANTS[self.options.keys()[0]]
- |
Lovely.
-
-
-
Testing more sourcecode directives
-
8 def run(self):
self.assert_has_content()
10 try:
lexer = get_lexer_by_name(self.arguments[0])
12 except ValueError ...
+
+
+
Testing another case
+
This will now have a line number in 'custom' since it's the default in
+pelican.conf, it ...
read more
There are comments.
diff --git a/pelican/tests/output/custom/category/misc.html b/pelican/tests/output/custom/category/misc.html
index f32e04c3..36479803 100644
--- a/pelican/tests/output/custom/category/misc.html
+++ b/pelican/tests/output/custom/category/misc.html
@@ -99,11 +99,11 @@
Testing sourcecode directive
| formatter = self.options and VARIANTS[self.options.keys()[0]]
- |
Lovely.
-
-
-
Testing more sourcecode directives
-
8 def run(self):
self.assert_has_content()
10 try:
lexer = get_lexer_by_name(self.arguments[0])
12 except ValueError ...
+
+
+
Testing another case
+
This will now have a line number in 'custom' since it's the default in
+pelican.conf, it ...
read more
There are comments.
diff --git a/pelican/tests/output/custom/feeds/all-en.atom.xml b/pelican/tests/output/custom/feeds/all-en.atom.xml
index ce25290d..69ba08c6 100644
--- a/pelican/tests/output/custom/feeds/all-en.atom.xml
+++ b/pelican/tests/output/custom/feeds/all-en.atom.xml
@@ -31,6 +31,13 @@ YEAH !</p>
<h2>Testing sourcecode directive</h2>
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
</pre></div>
+</td></tr></table></div>
+<div class="section" id="testing-another-case">
+<h2>Testing another case</h2>
+<p>This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.</p>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
</td></tr></table><p>Lovely.</p>
</div>
<div class="section" id="testing-more-sourcecode-directives">
@@ -43,5 +50,12 @@ YEAH !</p>
<span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
<p>Lovely.</p>
</div>
+<div class="section" id="testing-overriding-config-defaults">
+<h2>Testing overriding config defaults</h2>
+<p>Even if the default is line numbers, we can override it here</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
+</div>
The baz tag2010-03-14T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2010-03-14:tag/baz.html<p>This article overrides the listening of the articles under the <em>baz</em> tag.</p>
\ No newline at end of file
diff --git a/pelican/tests/output/custom/feeds/all.atom.xml b/pelican/tests/output/custom/feeds/all.atom.xml
index 68986d40..2eb31731 100644
--- a/pelican/tests/output/custom/feeds/all.atom.xml
+++ b/pelican/tests/output/custom/feeds/all.atom.xml
@@ -33,6 +33,13 @@ YEAH !</p>
<h2>Testing sourcecode directive</h2>
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
</pre></div>
+</td></tr></table></div>
+<div class="section" id="testing-another-case">
+<h2>Testing another case</h2>
+<p>This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.</p>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
</td></tr></table><p>Lovely.</p>
</div>
<div class="section" id="testing-more-sourcecode-directives">
@@ -45,5 +52,12 @@ YEAH !</p>
<span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
<p>Lovely.</p>
</div>
+<div class="section" id="testing-overriding-config-defaults">
+<h2>Testing overriding config defaults</h2>
+<p>Even if the default is line numbers, we can override it here</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
+</div>
The baz tag2010-03-14T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2010-03-14:tag/baz.html<p>This article overrides the listening of the articles under the <em>baz</em> tag.</p>
\ No newline at end of file
diff --git a/pelican/tests/output/custom/feeds/all.rss.xml b/pelican/tests/output/custom/feeds/all.rss.xml
index 7fee491a..69e30bfd 100644
--- a/pelican/tests/output/custom/feeds/all.rss.xml
+++ b/pelican/tests/output/custom/feeds/all.rss.xml
@@ -33,6 +33,13 @@ YEAH !</p>
<h2>Testing sourcecode directive</h2>
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
</pre></div>
+</td></tr></table></div>
+<div class="section" id="testing-another-case">
+<h2>Testing another case</h2>
+<p>This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.</p>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
</td></tr></table><p>Lovely.</p>
</div>
<div class="section" id="testing-more-sourcecode-directives">
@@ -45,5 +52,12 @@ YEAH !</p>
<span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
<p>Lovely.</p>
</div>
+<div class="section" id="testing-overriding-config-defaults">
+<h2>Testing overriding config defaults</h2>
+<p>Even if the default is line numbers, we can override it here</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
+</div>
Alexis MétaireauFri, 15 Oct 2010 20:30:00 +0200tag:blog.notmyidea.org,2010-10-15:unbelievable.html- The baz taghttp://blog.notmyidea.org/tag/baz.html<p>This article overrides the listening of the articles under the <em>baz</em> tag.</p>
Alexis MétaireauSun, 14 Mar 2010 00:00:00 +0100tag:blog.notmyidea.org,2010-03-14:tag/baz.html
\ No newline at end of file
diff --git a/pelican/tests/output/custom/feeds/misc.atom.xml b/pelican/tests/output/custom/feeds/misc.atom.xml
index 9328e05a..91d6b28f 100644
--- a/pelican/tests/output/custom/feeds/misc.atom.xml
+++ b/pelican/tests/output/custom/feeds/misc.atom.xml
@@ -8,6 +8,13 @@
<h2>Testing sourcecode directive</h2>
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
</pre></div>
+</td></tr></table></div>
+<div class="section" id="testing-another-case">
+<h2>Testing another case</h2>
+<p>This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.</p>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
</td></tr></table><p>Lovely.</p>
</div>
<div class="section" id="testing-more-sourcecode-directives">
@@ -20,5 +27,12 @@
<span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
<p>Lovely.</p>
</div>
+<div class="section" id="testing-overriding-config-defaults">
+<h2>Testing overriding config defaults</h2>
+<p>Even if the default is line numbers, we can override it here</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
+</div>
The baz tag2010-03-14T00:00:00+01:00Alexis Métaireautag:blog.notmyidea.org,2010-03-14:tag/baz.html<p>This article overrides the listening of the articles under the <em>baz</em> tag.</p>
\ No newline at end of file
diff --git a/pelican/tests/output/custom/feeds/misc.rss.xml b/pelican/tests/output/custom/feeds/misc.rss.xml
index b708c70d..3493d2a3 100644
--- a/pelican/tests/output/custom/feeds/misc.rss.xml
+++ b/pelican/tests/output/custom/feeds/misc.rss.xml
@@ -8,6 +8,13 @@
<h2>Testing sourcecode directive</h2>
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
</pre></div>
+</td></tr></table></div>
+<div class="section" id="testing-another-case">
+<h2>Testing another case</h2>
+<p>This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.</p>
+<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre>1</pre></div></td><td class="code"><div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
</td></tr></table><p>Lovely.</p>
</div>
<div class="section" id="testing-more-sourcecode-directives">
@@ -20,5 +27,12 @@
<span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
<p>Lovely.</p>
</div>
+<div class="section" id="testing-overriding-config-defaults">
+<h2>Testing overriding config defaults</h2>
+<p>Even if the default is line numbers, we can override it here</p>
+<div class="highlight"><pre><span class="n">formatter</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">options</span> <span class="ow">and</span> <span class="n">VARIANTS</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">keys</span><span class="p">()[</span><span class="mi">0</span><span class="p">]]</span>
+</pre></div>
+<p>Lovely.</p>
+</div>
Alexis MétaireauFri, 15 Oct 2010 20:30:00 +0200tag:blog.notmyidea.org,2010-10-15:unbelievable.html- The baz taghttp://blog.notmyidea.org/tag/baz.html<p>This article overrides the listening of the articles under the <em>baz</em> tag.</p>
Alexis MétaireauSun, 14 Mar 2010 00:00:00 +0100tag:blog.notmyidea.org,2010-03-14:tag/baz.html
\ No newline at end of file
diff --git a/pelican/tests/output/custom/index3.html b/pelican/tests/output/custom/index3.html
index 69f9d20c..b4d9ffc6 100644
--- a/pelican/tests/output/custom/index3.html
+++ b/pelican/tests/output/custom/index3.html
@@ -55,11 +55,11 @@
Testing sourcecode directive
| formatter = self.options and VARIANTS[self.options.keys()[0]]
- |
Lovely.
-
-
-
Testing more sourcecode directives
-
8 def run(self):
self.assert_has_content()
10 try:
lexer = get_lexer_by_name(self.arguments[0])
12 except ValueError ...
+
+
+
Testing another case
+
This will now have a line number in 'custom' since it's the default in
+pelican.conf, it ...
read more
There are comments.
diff --git a/pelican/tests/output/custom/unbelievable.html b/pelican/tests/output/custom/unbelievable.html
index 74bfa83c..03b533bb 100644
--- a/pelican/tests/output/custom/unbelievable.html
+++ b/pelican/tests/output/custom/unbelievable.html
@@ -54,6 +54,13 @@
Testing sourcecode directive
| formatter = self.options and VARIANTS[self.options.keys()[0]]
+ |
+
+
Testing another case
+
This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.
+
| formatter = self.options and VARIANTS[self.options.keys()[0]]
+
|
Lovely.
@@ -65,6 +72,13 @@
Testing even more sourcecode directives
formatter = self.options and VARIANTS[self.options.keys()[0]]
Lovely.
+
+
+
Testing overriding config defaults
+
Even if the default is line numbers, we can override it here
+
formatter = self.options and VARIANTS[self.options.keys()[0]]
+
+
Lovely.
diff --git a/pelican/tests/test_pelican.py b/pelican/tests/test_pelican.py
index d6c0d8e9..8cccc918 100644
--- a/pelican/tests/test_pelican.py
+++ b/pelican/tests/test_pelican.py
@@ -92,3 +92,38 @@ class TestPelican(LoggedTestCase):
mute(True)(pelican.run)()
dcmp = dircmp(self.temp_path, os.path.join(OUTPUT_PATH, 'custom'))
self.assertFilesEqual(recursiveDiff(dcmp))
+
+ def test_theme_static_paths_copy(self):
+ # the same thing with a specified set of settings should work
+ settings = read_settings(path=SAMPLE_CONFIG, override={
+ 'PATH': INPUT_PATH,
+ 'OUTPUT_PATH': self.temp_path,
+ 'THEME_STATIC_PATHS': [os.path.join(SAMPLES_PATH, 'very'),
+ os.path.join(SAMPLES_PATH, 'kinda'),
+ os.path.join(SAMPLES_PATH, 'theme_standard')]
+ })
+ pelican = Pelican(settings=settings)
+ mute(True)(pelican.run)()
+ theme_output = os.path.join(self.temp_path, 'theme')
+ extra_path = os.path.join(theme_output, 'exciting', 'new', 'files')
+
+ for file in ['a_stylesheet', 'a_template']:
+ self.assertTrue(os.path.exists(os.path.join(theme_output, file)))
+
+ for file in ['wow!', 'boom!', 'bap!', 'zap!']:
+ self.assertTrue(os.path.exists(os.path.join(extra_path, file)))
+
+ def test_theme_static_paths_copy_single_file(self):
+ # the same thing with a specified set of settings should work
+ settings = read_settings(path=SAMPLE_CONFIG, override={
+ 'PATH': INPUT_PATH,
+ 'OUTPUT_PATH': self.temp_path,
+ 'THEME_STATIC_PATHS': [os.path.join(SAMPLES_PATH, 'theme_standard')]
+ })
+
+ pelican = Pelican(settings=settings)
+ mute(True)(pelican.run)()
+ theme_output = os.path.join(self.temp_path, 'theme')
+
+ for file in ['a_stylesheet', 'a_template']:
+ self.assertTrue(os.path.exists(os.path.join(theme_output, file)))
diff --git a/pelican/themes/notmyidea/templates/piwik.html b/pelican/themes/notmyidea/templates/piwik.html
index ff459af7..f9126264 100644
--- a/pelican/themes/notmyidea/templates/piwik.html
+++ b/pelican/themes/notmyidea/templates/piwik.html
@@ -1,16 +1,19 @@
{% if PIWIK_URL and PIWIK_SITE_ID %}
-
-{% endif %}
\ No newline at end of file
+
+{% endif %}
diff --git a/pelican/utils.py b/pelican/utils.py
index 054c1f40..f222f63c 100644
--- a/pelican/utils.py
+++ b/pelican/utils.py
@@ -256,7 +256,7 @@ def slugify(value, substitutions=()):
return value.decode('ascii')
-def copy(path, source, destination, destination_path=None, overwrite=False):
+def copy(path, source, destination, destination_path=None):
"""Copy path from origin to destination.
The function is able to copy either files or directories.
@@ -265,8 +265,6 @@ def copy(path, source, destination, destination_path=None, overwrite=False):
:param source: the source dir
:param destination: the destination dir
:param destination_path: the destination path (optional)
- :param overwrite: whether to overwrite the destination if already exists
- or not
"""
if not destination_path:
destination_path = path
@@ -275,16 +273,27 @@ def copy(path, source, destination, destination_path=None, overwrite=False):
destination_ = os.path.abspath(
os.path.expanduser(os.path.join(destination, destination_path)))
+ if not os.path.exists(destination_):
+ os.makedirs(destination_)
+
+ def recurse(source, destination):
+ for entry in os.listdir(source):
+ entry_path = os.path.join(source, entry)
+ if os.path.isdir(entry_path):
+ entry_dest = os.path.join(destination, entry)
+ if os.path.exists(entry_dest):
+ if not os.path.isdir(entry_dest):
+ raise IOError('Failed to copy {0} a directory.'
+ .format(entry_dest))
+ recurse(entry_path, entry_dest)
+ else:
+ shutil.copytree(entry_path, entry_dest)
+ else:
+ shutil.copy(entry_path, destination)
+
+
if os.path.isdir(source_):
- try:
- shutil.copytree(source_, destination_)
- logger.info('copying %s to %s' % (source_, destination_))
- except OSError:
- if overwrite:
- shutil.rmtree(destination_)
- shutil.copytree(source_, destination_)
- logger.info('replacement of %s with %s' % (source_,
- destination_))
+ recurse(source_, destination_)
elif os.path.isfile(source_):
dest_dir = os.path.dirname(destination_)
diff --git a/samples/content/unbelievable.rst b/samples/content/unbelievable.rst
index b990d20c..209e3557 100644
--- a/samples/content/unbelievable.rst
+++ b/samples/content/unbelievable.rst
@@ -12,9 +12,20 @@ Testing sourcecode directive
----------------------------
.. sourcecode:: python
- :linenos:
+ :linenos:
- formatter = self.options and VARIANTS[self.options.keys()[0]]
+ formatter = self.options and VARIANTS[self.options.keys()[0]]
+
+
+Testing another case
+--------------------
+
+This will now have a line number in 'custom' since it's the default in
+pelican.conf, it will have nothing in default.
+
+.. sourcecode:: python
+
+ formatter = self.options and VARIANTS[self.options.keys()[0]]
Lovely.
@@ -71,3 +82,17 @@ Testing even more sourcecode directives
Lovely.
+
+Testing overriding config defaults
+----------------------------------
+
+Even if the default is line numbers, we can override it here
+
+.. sourcecode:: python
+ :linenos: none
+
+
+ formatter = self.options and VARIANTS[self.options.keys()[0]]
+
+
+Lovely.
diff --git a/samples/kinda/exciting/new/files/zap! b/samples/kinda/exciting/new/files/zap!
new file mode 100644
index 00000000..e69de29b
diff --git a/samples/kinda/exciting/old b/samples/kinda/exciting/old
new file mode 100644
index 00000000..e69de29b
diff --git a/samples/pelican.conf.py b/samples/pelican.conf.py
index 4d5cd06d..d6a87923 100755
--- a/samples/pelican.conf.py
+++ b/samples/pelican.conf.py
@@ -48,6 +48,9 @@ STATIC_PATHS = [
# custom page generated with a jinja2 template
TEMPLATE_PAGES = {'pages/jinja2_template.html': 'jinja2_template.html'}
+# code blocks with line numbers
+PYGMENTS_RST_OPTIONS = {'linenos': 'table'}
+
# foobar will not be used, because it's not in caps. All configuration keys
# have to be in caps
foobar = "barbaz"
diff --git a/samples/theme_standard/a_stylesheet b/samples/theme_standard/a_stylesheet
new file mode 100644
index 00000000..e69de29b
diff --git a/samples/theme_standard/a_template b/samples/theme_standard/a_template
new file mode 100644
index 00000000..e69de29b
diff --git a/samples/very/exciting/new/files/bap! b/samples/very/exciting/new/files/bap!
new file mode 100644
index 00000000..e69de29b
diff --git a/samples/very/exciting/new/files/boom! b/samples/very/exciting/new/files/boom!
new file mode 100644
index 00000000..e69de29b
diff --git a/samples/very/exciting/new/files/wow! b/samples/very/exciting/new/files/wow!
new file mode 100644
index 00000000..e69de29b