Skip to content
Permalink
Browse files

Implement depend-on-config-options for reSt extensions (Fix Issue #1919)

  • Loading branch information...
ralsina committed Aug 5, 2015
1 parent 32845cd commit b56555307b2b71085d09f62b43579790e6ed90a3
Showing with 16 additions and 1 deletion.
  1. +2 −0 CHANGES.txt
  2. +9 −0 docs/extending.txt
  3. +5 −1 nikola/plugins/task/posts.py
@@ -4,6 +4,8 @@ New in master
Features
--------

* Added mechanism for rest extensions to depend on configuration options
(Issue #1919)
* Render Jupyter notebooks (ipynb) in listings (Issue #1900)

Bugfixes
@@ -384,6 +384,15 @@ RestExtension Plugins

Implement directives for reStructuredText, see `media.py <https://github.com/getnikola/nikola/blob/master/nikola/plugins/compile/rest/media.py>`__ for a simple example.

If your output depends on a config value, you need to make your post record a dependency on a pseudo-path like this::

####MAGIC####CONFIG:OPTIONNAME

Then, whenever the ``OPTIONNAME`` option is changed in conf.py, the file will be rebuilt.

If your directive depends or may depend on the whole timeline like, for example, the post-list directive, where adding new posts
to the site could make it stale, you should record a dependency on the pseudo-path ``####MAGIC####TIMELINE``

MarkdownExtension Plugins
-------------------------

@@ -77,7 +77,11 @@ def tl_ch():
deps_dict = copy(kw)
deps_dict.pop('timeline')
for post in kw['timeline']:

# Extra config dependencies picked from config
for p in post.fragment_deps(lang):
if p.startswith('####MAGIC####CONFIG:'):
k = p.split('####MAGIC####CONFIG:',1)[-1]
deps_dict[k] = self.site.config.get(k)
dest = post.translated_base_path(lang)
file_dep = [p for p in post.fragment_deps(lang) if not p.startswith("####MAGIC####")]
task = {

0 comments on commit b565553

Please sign in to comment.
You can’t perform that action at this time.