aboutsummaryrefslogtreecommitdiffstats
path: root/nikola
diff options
context:
space:
mode:
Diffstat (limited to 'nikola')
-rw-r--r--nikola/__init__.py4
-rw-r--r--nikola/__main__.py37
-rw-r--r--nikola/data/themes/base/assets/css/rst_base.css64
-rw-r--r--nikola/data/themes/base/assets/css/theme.css2
-rw-r--r--nikola/filters.py2
-rw-r--r--nikola/hierarchy_utils.py2
-rw-r--r--nikola/log.py2
-rw-r--r--nikola/metadata_extractors.py2
-rw-r--r--nikola/nikola.py2
-rw-r--r--nikola/packages/datecond/LICENSE2
-rw-r--r--nikola/packages/datecond/__init__.py2
-rw-r--r--nikola/packages/pygments_better_html/LICENSE2
-rw-r--r--nikola/packages/pygments_better_html/__init__.py2
-rw-r--r--nikola/plugin_categories.py2
-rw-r--r--nikola/plugins/basic_import.py2
-rw-r--r--nikola/plugins/command/__init__.py2
-rw-r--r--nikola/plugins/command/auto/__init__.py2
-rw-r--r--nikola/plugins/command/check.py2
-rw-r--r--nikola/plugins/command/console.py2
-rw-r--r--nikola/plugins/command/default_config.py2
-rw-r--r--nikola/plugins/command/deploy.py2
-rw-r--r--nikola/plugins/command/github_deploy.py2
-rw-r--r--nikola/plugins/command/import_wordpress.py4
-rw-r--r--nikola/plugins/command/init.py2
-rw-r--r--nikola/plugins/command/new_page.py2
-rw-r--r--nikola/plugins/command/new_post.py2
-rw-r--r--nikola/plugins/command/orphans.py2
-rw-r--r--nikola/plugins/command/plugin.py2
-rw-r--r--nikola/plugins/command/rst2html/__init__.py2
-rw-r--r--nikola/plugins/command/serve.py2
-rw-r--r--nikola/plugins/command/status.py2
-rw-r--r--nikola/plugins/command/subtheme.py2
-rw-r--r--nikola/plugins/command/theme.py2
-rw-r--r--nikola/plugins/command/version.py2
-rw-r--r--nikola/plugins/compile/__init__.py2
-rw-r--r--nikola/plugins/compile/html.py2
-rw-r--r--nikola/plugins/compile/ipynb.py2
-rw-r--r--nikola/plugins/compile/markdown/__init__.py11
-rw-r--r--nikola/plugins/compile/markdown/mdx_gist.py15
-rw-r--r--nikola/plugins/compile/markdown/mdx_nikola.py2
-rw-r--r--nikola/plugins/compile/markdown/mdx_podcast.py5
-rw-r--r--nikola/plugins/compile/pandoc.py2
-rw-r--r--nikola/plugins/compile/php.py2
-rw-r--r--nikola/plugins/compile/rest/__init__.py4
-rw-r--r--nikola/plugins/compile/rest/chart.py2
-rw-r--r--nikola/plugins/compile/rest/doc.py2
-rw-r--r--nikola/plugins/compile/rest/listing.py33
-rw-r--r--nikola/plugins/compile/rest/media.py2
-rw-r--r--nikola/plugins/compile/rest/post_list.py2
-rw-r--r--nikola/plugins/compile/rest/soundcloud.py2
-rw-r--r--nikola/plugins/compile/rest/thumbnail.py2
-rw-r--r--nikola/plugins/compile/rest/vimeo.py2
-rw-r--r--nikola/plugins/compile/rest/youtube.py15
-rw-r--r--nikola/plugins/misc/__init__.py2
-rw-r--r--nikola/plugins/misc/scan_posts.py2
-rw-r--r--nikola/plugins/misc/taxonomies_classifier.py2
-rw-r--r--nikola/plugins/shortcode/chart.py2
-rw-r--r--nikola/plugins/shortcode/listing.py2
-rw-r--r--nikola/plugins/shortcode/post_list.py2
-rw-r--r--nikola/plugins/shortcode/thumbnail.py2
-rw-r--r--nikola/plugins/task/__init__.py2
-rw-r--r--nikola/plugins/task/archive.py2
-rw-r--r--nikola/plugins/task/authors.py2
-rw-r--r--nikola/plugins/task/bundles.py2
-rw-r--r--nikola/plugins/task/categories.py2
-rw-r--r--nikola/plugins/task/copy_assets.py2
-rw-r--r--nikola/plugins/task/copy_files.py2
-rw-r--r--nikola/plugins/task/galleries.py10
-rw-r--r--nikola/plugins/task/gzip.py2
-rw-r--r--nikola/plugins/task/indexes.py2
-rw-r--r--nikola/plugins/task/listings.py2
-rw-r--r--nikola/plugins/task/page_index.py2
-rw-r--r--nikola/plugins/task/pages.py2
-rw-r--r--nikola/plugins/task/posts.py2
-rw-r--r--nikola/plugins/task/redirect.py2
-rw-r--r--nikola/plugins/task/robots.py2
-rw-r--r--nikola/plugins/task/scale_images.py2
-rw-r--r--nikola/plugins/task/sitemap.py2
-rw-r--r--nikola/plugins/task/sources.py2
-rw-r--r--nikola/plugins/task/tags.py2
-rw-r--r--nikola/plugins/task/taxonomies.py2
-rw-r--r--nikola/plugins/template/__init__.py2
-rw-r--r--nikola/plugins/template/jinja.py2
-rw-r--r--nikola/plugins/template/mako.py2
-rw-r--r--nikola/post.py3
-rw-r--r--nikola/shortcodes.py2
-rw-r--r--nikola/state.py2
-rw-r--r--nikola/utils.py46
-rw-r--r--nikola/winutils.py2
89 files changed, 279 insertions, 124 deletions
diff --git a/nikola/__init__.py b/nikola/__init__.py
index e085f91..200d23d 100644
--- a/nikola/__init__.py
+++ b/nikola/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -29,7 +29,7 @@
import os
import sys
-__version__ = '8.2.0'
+__version__ = '8.2.3'
DEBUG = bool(os.getenv('NIKOLA_DEBUG'))
SHOW_TRACEBACKS = bool(os.getenv('NIKOLA_SHOW_TRACEBACKS'))
diff --git a/nikola/__main__.py b/nikola/__main__.py
index 0035523..03c7a51 100644
--- a/nikola/__main__.py
+++ b/nikola/__main__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -36,8 +36,7 @@ import doit.cmd_base
from collections import defaultdict
from blinker import signal
-from doit.cmd_auto import Auto as DoitAuto
-from doit.cmd_base import TaskLoader, _wrap
+from doit.cmd_base import TaskLoader2, _wrap
from doit.cmd_clean import Clean as DoitClean
from doit.cmd_completion import TabCompletion
from doit.cmd_help import Help as DoitHelp
@@ -247,31 +246,41 @@ class Clean(DoitClean):
# Nikola has its own "auto" commands that uses livereload.
# Expose original doit "auto" command as "doit_auto".
-DoitAuto.name = 'doit_auto'
+# doit_auto is not available with doit>=0.36.0.
+try:
+ from doit.cmd_auto import Auto as DoitAuto
+ DoitAuto.name = 'doit_auto'
+except ImportError:
+ DoitAuto = None
-class NikolaTaskLoader(TaskLoader):
+class NikolaTaskLoader(TaskLoader2):
"""Nikola-specific task loader."""
def __init__(self, nikola, quiet=False):
"""Initialize the loader."""
+ super().__init__()
self.nikola = nikola
self.quiet = quiet
- def load_tasks(self, cmd, opt_values, pos_args):
- """Load Nikola tasks."""
+ def load_doit_config(self):
+ """Load doit configuration."""
if self.quiet:
- DOIT_CONFIG = {
+ doit_config = {
'verbosity': 0,
'reporter': 'zero',
}
else:
- DOIT_CONFIG = {
+ doit_config = {
'reporter': ExecutedOnlyReporter,
'outfile': sys.stderr,
}
- DOIT_CONFIG['default_tasks'] = ['render_site', 'post_render']
- DOIT_CONFIG.update(self.nikola._doit_config)
+ doit_config['default_tasks'] = ['render_site', 'post_render']
+ doit_config.update(self.nikola._doit_config)
+ return doit_config
+
+ def load_tasks(self, cmd, pos_args):
+ """Load Nikola tasks."""
try:
tasks = generate_tasks(
'render_site',
@@ -286,15 +295,17 @@ class NikolaTaskLoader(TaskLoader):
raise
_print_exception()
sys.exit(3)
- return tasks + latetasks, DOIT_CONFIG
+ return tasks + latetasks
class DoitNikola(DoitMain):
"""Nikola-specific implementation of DoitMain."""
# overwite help command
- DOIT_CMDS = list(DoitMain.DOIT_CMDS) + [Help, Build, Clean, DoitAuto]
+ DOIT_CMDS = list(DoitMain.DOIT_CMDS) + [Help, Build, Clean]
TASK_LOADER = NikolaTaskLoader
+ if DoitAuto is not None:
+ DOIT_CMDS.append(DoitAuto)
def __init__(self, nikola, quiet=False):
"""Initialzie DoitNikola."""
diff --git a/nikola/data/themes/base/assets/css/rst_base.css b/nikola/data/themes/base/assets/css/rst_base.css
index 51f92b4..fcd7318 100644
--- a/nikola/data/themes/base/assets/css/rst_base.css
+++ b/nikola/data/themes/base/assets/css/rst_base.css
@@ -123,11 +123,6 @@ dl.option-list > dd > *:first-child
width: 100%;
margin: 0;
}
-/* field names followed by a colon */
-dl.field-list > dt:after,
-dl.docinfo > dt:after {
- content: ":";
-}
/* Bibliographic Fields (docinfo) */
dl.docinfo pre.address {
@@ -140,13 +135,62 @@ dl.docinfo > dd.authors > p { margin: 0; }
dl.option-list > dt { font-weight: normal; }
span.option { white-space: nowrap; }
+
/* Footnotes and Citations */
+
+.footnote, .citation { margin: 1em 0; } /* default paragraph skip (Firefox) */
+/* hanging indent */
+.citation { padding-left: 2em; }
+.footnote { padding-left: 1.7em; }
+.footnote.superscript { padding-left: 1.0em; }
+.citation > .label { margin-left: -2em; }
+.footnote > .label { margin-left: -1.7em; }
+.footnote.superscript > .label { margin-left: -1.0em; }
+
+.footnote > .label + *,
+.citation > .label + * {
+ display: inline-block;
+ margin-top: 0;
+ vertical-align: top;
+}
+.footnote > .backrefs + *,
+.citation > .backrefs + * {
+ margin-top: 0;
+}
+.footnote > .label + p, .footnote > .backrefs + p,
+.citation > .label + p, .citation > .backrefs + p {
+ display: inline;
+ vertical-align: inherit;
+}
+
+.backrefs { user-select: none; }
+.backrefs > a { font-style: italic; }
+
+/* superscript footnotes */
+a[role="doc-noteref"].superscript,
+.footnote.superscript > .label,
+.footnote.superscript > .backrefs {
+ vertical-align: super;
+ font-size: smaller;
+ line-height: 1;
+}
+a[role="doc-noteref"].superscript > .fn-bracket,
+.footnote.superscript > .label > .fn-bracket {
+ /* hide brackets in display but leave for copy/paste */
+ display: inline-block;
+ width: 0;
+ overflow: hidden;
+}
+[role="doc-noteref"].superscript + [role="doc-noteref"].superscript {
+ padding-left: 0.15em; /* separate consecutive footnote references */
+ /* TODO: unfortunately, "+" also selects with text between the references. */
+}
+
+/* Legacy Footnotes and Citations */
dl.footnote.superscript > dd { margin-left: 1em; }
dl.footnote.brackets > dd { margin-left: 2em; }
dl.footnote > dt { font-weight: normal; }
-a.footnote-reference.brackets:before,
dt.label > span.brackets:before { content: "["; }
-a.footnote-reference.brackets:after,
dt.label > span.brackets:after { content: "]"; }
a.footnote-reference.superscript,
dl.footnote.superscript > dt.label {
@@ -363,6 +407,12 @@ table.numbered > caption:before {
/* ----------------------- */
/* line on the left */
+.footnote-list {
+ border-left: solid thin;
+ padding-left: 0.25em;
+}
+
+/* same thing for old docutils versions */
dl.footnote {
padding-left: 1ex;
border-left: solid;
diff --git a/nikola/data/themes/base/assets/css/theme.css b/nikola/data/themes/base/assets/css/theme.css
index 69b5fa7..b198c2c 100644
--- a/nikola/data/themes/base/assets/css/theme.css
+++ b/nikola/data/themes/base/assets/css/theme.css
@@ -1,7 +1,7 @@
@charset "UTF-8";
/*
- Copyright © 2014-2021 Daniel Aleksandersen and others.
+ Copyright © 2014-2022 Daniel Aleksandersen and others.
Permission is hereby granted, free of charge, to any
person obtaining a copy of this software and associated
diff --git a/nikola/filters.py b/nikola/filters.py
index c2b10e2..8deeb89 100644
--- a/nikola/filters.py
+++ b/nikola/filters.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/hierarchy_utils.py b/nikola/hierarchy_utils.py
index 7e1fb1a..7e8d9b8 100644
--- a/nikola/hierarchy_utils.py
+++ b/nikola/hierarchy_utils.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/log.py b/nikola/log.py
index 9d99e30..eedee72 100644
--- a/nikola/log.py
+++ b/nikola/log.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/metadata_extractors.py b/nikola/metadata_extractors.py
index 150632e..4e0ae10 100644
--- a/nikola/metadata_extractors.py
+++ b/nikola/metadata_extractors.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Chris Warrick, Roberto Alsina and others.
+# Copyright © 2012-2022 Chris Warrick, Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/nikola.py b/nikola/nikola.py
index ca8291b..41eeac6 100644
--- a/nikola/nikola.py
+++ b/nikola/nikola.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/packages/datecond/LICENSE b/nikola/packages/datecond/LICENSE
index b6ccdf4..fcc5730 100644
--- a/nikola/packages/datecond/LICENSE
+++ b/nikola/packages/datecond/LICENSE
@@ -1,4 +1,4 @@
-Copyright © 2016-2021, Chris Warrick.
+Copyright © 2016-2022, Chris Warrick.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/nikola/packages/datecond/__init__.py b/nikola/packages/datecond/__init__.py
index 814e3a8..4e9566c 100644
--- a/nikola/packages/datecond/__init__.py
+++ b/nikola/packages/datecond/__init__.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
# Date Conditionals v0.1.7
-# Copyright © 2015-2021, Chris Warrick.
+# Copyright © 2015-2022, Chris Warrick.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
diff --git a/nikola/packages/pygments_better_html/LICENSE b/nikola/packages/pygments_better_html/LICENSE
index 2c07d1e..8312fb8 100644
--- a/nikola/packages/pygments_better_html/LICENSE
+++ b/nikola/packages/pygments_better_html/LICENSE
@@ -1,4 +1,4 @@
-Copyright © 2020-2021, Chris Warrick.
+Copyright © 2020-2022, Chris Warrick.
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/nikola/packages/pygments_better_html/__init__.py b/nikola/packages/pygments_better_html/__init__.py
index 3303abb..565dcb4 100644
--- a/nikola/packages/pygments_better_html/__init__.py
+++ b/nikola/packages/pygments_better_html/__init__.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Better HTML formatter for Pygments.
-Copyright © 2020-2021, Chris Warrick.
+Copyright © 2020-2022, Chris Warrick.
License: 3-clause BSD.
Portions copyright © 2006-2019, the Pygments authors. (2-clause BSD).
"""
diff --git a/nikola/plugin_categories.py b/nikola/plugin_categories.py
index 0ba5991..14760df 100644
--- a/nikola/plugin_categories.py
+++ b/nikola/plugin_categories.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/basic_import.py b/nikola/plugins/basic_import.py
index 8d14fbf..ca88cfb 100644
--- a/nikola/plugins/basic_import.py
+++ b/nikola/plugins/basic_import.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/__init__.py b/nikola/plugins/command/__init__.py
index 1b967fc..6c8e81a 100644
--- a/nikola/plugins/command/__init__.py
+++ b/nikola/plugins/command/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/auto/__init__.py b/nikola/plugins/command/auto/__init__.py
index 2c6d0e7..b13b645 100644
--- a/nikola/plugins/command/auto/__init__.py
+++ b/nikola/plugins/command/auto/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Chris Warrick, Roberto Alsina and others.
+# Copyright © 2012-2022 Chris Warrick, Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/check.py b/nikola/plugins/command/check.py
index 3482316..f9b701b 100644
--- a/nikola/plugins/command/check.py
+++ b/nikola/plugins/command/check.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/console.py b/nikola/plugins/command/console.py
index a0c6811..96fee3e 100644
--- a/nikola/plugins/command/console.py
+++ b/nikola/plugins/command/console.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Chris Warrick, Roberto Alsina and others.
+# Copyright © 2012-2022 Chris Warrick, Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/default_config.py b/nikola/plugins/command/default_config.py
index bd9dc8a..fddda26 100644
--- a/nikola/plugins/command/default_config.py
+++ b/nikola/plugins/command/default_config.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/deploy.py b/nikola/plugins/command/deploy.py
index 64c1c9f..1896a7a 100644
--- a/nikola/plugins/command/deploy.py
+++ b/nikola/plugins/command/deploy.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/github_deploy.py b/nikola/plugins/command/github_deploy.py
index 843f56a..1d3e9c0 100644
--- a/nikola/plugins/command/github_deploy.py
+++ b/nikola/plugins/command/github_deploy.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2014-2021 Puneeth Chaganti and others.
+# Copyright © 2014-2022 Puneeth Chaganti and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/import_wordpress.py b/nikola/plugins/command/import_wordpress.py
index f513e1c..f3feab1 100644
--- a/nikola/plugins/command/import_wordpress.py
+++ b/nikola/plugins/command/import_wordpress.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -1189,7 +1189,7 @@ def separate_qtranslate_tagged_langs(text):
if not c.strip():
continue
elif c[2:qt_end_with_lang_len].startswith(qt_end):
- # a language specific section (with language code at the begining)
+ # a language specific section (with language code at the beginning)
lang = c[:2]
c = c[qt_end_with_lang_len:]
else:
diff --git a/nikola/plugins/command/init.py b/nikola/plugins/command/init.py
index 4f3cd38..4607758 100644
--- a/nikola/plugins/command/init.py
+++ b/nikola/plugins/command/init.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/new_page.py b/nikola/plugins/command/new_page.py
index 2f7f304..94fbc51 100644
--- a/nikola/plugins/command/new_page.py
+++ b/nikola/plugins/command/new_page.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina, Chris Warrick and others.
+# Copyright © 2012-2022 Roberto Alsina, Chris Warrick and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/new_post.py b/nikola/plugins/command/new_post.py
index 4ae2427..f66a188 100644
--- a/nikola/plugins/command/new_post.py
+++ b/nikola/plugins/command/new_post.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/orphans.py b/nikola/plugins/command/orphans.py
index 1018d7e..169cbba 100644
--- a/nikola/plugins/command/orphans.py
+++ b/nikola/plugins/command/orphans.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina, Chris Warrick and others.
+# Copyright © 2012-2022 Roberto Alsina, Chris Warrick and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/plugin.py b/nikola/plugins/command/plugin.py
index 9df13b5..ae0dead 100644
--- a/nikola/plugins/command/plugin.py
+++ b/nikola/plugins/command/plugin.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/rst2html/__init__.py b/nikola/plugins/command/rst2html/__init__.py
index 0dea100..2bf329a 100644
--- a/nikola/plugins/command/rst2html/__init__.py
+++ b/nikola/plugins/command/rst2html/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2015-2021 Chris Warrick and others.
+# Copyright © 2015-2022 Chris Warrick and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/serve.py b/nikola/plugins/command/serve.py
index 06c7422..cbf628c 100644
--- a/nikola/plugins/command/serve.py
+++ b/nikola/plugins/command/serve.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/status.py b/nikola/plugins/command/status.py
index 72d642c..ab6fc1e 100644
--- a/nikola/plugins/command/status.py
+++ b/nikola/plugins/command/status.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/subtheme.py b/nikola/plugins/command/subtheme.py
index 32b0f22..b5c5aff 100644
--- a/nikola/plugins/command/subtheme.py
+++ b/nikola/plugins/command/subtheme.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/theme.py b/nikola/plugins/command/theme.py
index 0a80c29..2f99dd8 100644
--- a/nikola/plugins/command/theme.py
+++ b/nikola/plugins/command/theme.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina, Chris Warrick and others.
+# Copyright © 2012-2022 Roberto Alsina, Chris Warrick and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/command/version.py b/nikola/plugins/command/version.py
index 69ba4d1..4ec8a46 100644
--- a/nikola/plugins/command/version.py
+++ b/nikola/plugins/command/version.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/__init__.py b/nikola/plugins/compile/__init__.py
index bea2e3d..c3abcd4 100644
--- a/nikola/plugins/compile/__init__.py
+++ b/nikola/plugins/compile/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/html.py b/nikola/plugins/compile/html.py
index c69fd6b..ff7d37f 100644
--- a/nikola/plugins/compile/html.py
+++ b/nikola/plugins/compile/html.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/ipynb.py b/nikola/plugins/compile/ipynb.py
index d60f134..7d6e528 100644
--- a/nikola/plugins/compile/ipynb.py
+++ b/nikola/plugins/compile/ipynb.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2013-2021 Damián Avila, Chris Warrick and others.
+# Copyright © 2013-2022 Damián Avila, Chris Warrick and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/markdown/__init__.py b/nikola/plugins/compile/markdown/__init__.py
index 46b2e6e..31a57d9 100644
--- a/nikola/plugins/compile/markdown/__init__.py
+++ b/nikola/plugins/compile/markdown/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -33,13 +33,20 @@ import threading
from nikola import shortcodes as sc
from nikola.plugin_categories import PageCompiler
-from nikola.utils import makedirs, req_missing, write_metadata, LocaleBorg, map_metadata
+from nikola.utils import makedirs, req_missing, write_metadata, LocaleBorg, map_metadata, NikolaPygmentsHTML
try:
from markdown import Markdown
except ImportError:
Markdown = None
+# Override Pygments formatter for Markdown.
+try:
+ import markdown.extensions.codehilite
+ markdown.extensions.codehilite.get_formatter_by_name = lambda _, **args: NikolaPygmentsHTML(**args)
+except ImportError:
+ pass
+
class ThreadLocalMarkdown(threading.local):
"""Convert Markdown to HTML using per-thread Markdown objects.
diff --git a/nikola/plugins/compile/markdown/mdx_gist.py b/nikola/plugins/compile/markdown/mdx_gist.py
index f6ce20a..fc24d34 100644
--- a/nikola/plugins/compile/markdown/mdx_gist.py
+++ b/nikola/plugins/compile/markdown/mdx_gist.py
@@ -76,19 +76,19 @@ Error Case: non-existent file:
"""
import requests
+import xml.etree.ElementTree as etree
from nikola.plugin_categories import MarkdownExtension
from nikola.utils import get_logger
try:
from markdown.extensions import Extension
- from markdown.inlinepatterns import Pattern
+ from markdown.inlinepatterns import InlineProcessor
from markdown.util import AtomicString
- from markdown.util import etree
except ImportError:
# No need to catch this, if you try to use this without Markdown,
# the markdown compiler will fail first
- Extension = Pattern = object
+ Extension = InlineProcessor = AtomicString = object
LOGGER = get_logger('compile_markdown.mdx_gist')
@@ -112,12 +112,12 @@ class GistFetchException(Exception):
status_code, url)
-class GistPattern(Pattern):
+class GistPattern(InlineProcessor):
"""InlinePattern for footnote markers in a document's body text."""
def __init__(self, pattern, configs):
"""Initialize the pattern."""
- Pattern.__init__(self, pattern)
+ InlineProcessor.__init__(self, pattern)
def get_raw_gist_with_filename(self, gist_id, filename):
"""Get raw gist text for a filename."""
@@ -139,8 +139,9 @@ class GistPattern(Pattern):
return resp.text
- def handleMatch(self, m):
+ def handleMatch(self, m, _):
"""Handle pattern match."""
+ # The third arg is "data", wider context around the match; we don't need it.
gist_id = m.group('gist_id')
gist_file = m.group('filename')
@@ -170,7 +171,7 @@ class GistPattern(Pattern):
warning_comment = etree.Comment(' WARNING: {0} '.format(e.message))
noscript_elem.append(warning_comment)
- return gist_elem
+ return (gist_elem, m.start(0), m.end(0))
class GistExtension(MarkdownExtension, Extension):
diff --git a/nikola/plugins/compile/markdown/mdx_nikola.py b/nikola/plugins/compile/markdown/mdx_nikola.py
index 255ea86..af30956 100644
--- a/nikola/plugins/compile/markdown/mdx_nikola.py
+++ b/nikola/plugins/compile/markdown/mdx_nikola.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/markdown/mdx_podcast.py b/nikola/plugins/compile/markdown/mdx_podcast.py
index 647ee1f..e003f40 100644
--- a/nikola/plugins/compile/markdown/mdx_podcast.py
+++ b/nikola/plugins/compile/markdown/mdx_podcast.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright © 2013-2021 Michael Rabbitt, Roberto Alsina and others.
+# Copyright © 2013-2022 Michael Rabbitt, Roberto Alsina and others.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the
@@ -36,11 +36,12 @@ Basic Example:
<p><audio controls=""><source src="https://archive.org/download/Rebeldes_Stereotipos/rs20120609_1.mp3" type="audio/mpeg"></source></audio></p>
"""
+import xml.etree.ElementTree as etree
+
from nikola.plugin_categories import MarkdownExtension
try:
from markdown.extensions import Extension
from markdown.inlinepatterns import Pattern
- from markdown.util import etree
except ImportError:
# No need to catch this, if you try to use this without Markdown,
# the markdown compiler will fail first
diff --git a/nikola/plugins/compile/pandoc.py b/nikola/plugins/compile/pandoc.py
index 62d3e88..a43c8b0 100644
--- a/nikola/plugins/compile/pandoc.py
+++ b/nikola/plugins/compile/pandoc.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/php.py b/nikola/plugins/compile/php.py
index 347f222..d4c67dc 100644
--- a/nikola/plugins/compile/php.py
+++ b/nikola/plugins/compile/php.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/rest/__init__.py b/nikola/plugins/compile/rest/__init__.py
index 082cae0..e5d3998 100644
--- a/nikola/plugins/compile/rest/__init__.py
+++ b/nikola/plugins/compile/rest/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -264,7 +264,7 @@ def add_node(node, visit_function=None, depart_function=None):
"""Register a Docutils node class.
This function is completely optional. It is a same concept as
- `Sphinx add_node function <http://sphinx-doc.org/extdev/appapi.html#sphinx.application.Sphinx.add_node>`_.
+ `Sphinx add_node function <https://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_node>`_.
For example::
diff --git a/nikola/plugins/compile/rest/chart.py b/nikola/plugins/compile/rest/chart.py
index a950292..15ccee7 100644
--- a/nikola/plugins/compile/rest/chart.py
+++ b/nikola/plugins/compile/rest/chart.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/rest/doc.py b/nikola/plugins/compile/rest/doc.py
index 05b0ad2..1d88472 100644
--- a/nikola/plugins/compile/rest/doc.py
+++ b/nikola/plugins/compile/rest/doc.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/rest/listing.py b/nikola/plugins/compile/rest/listing.py
index f669b16..48dbe4c 100644
--- a/nikola/plugins/compile/rest/listing.py
+++ b/nikola/plugins/compile/rest/listing.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -57,7 +57,8 @@ class CodeBlock(Directive):
'name': directives.unchanged,
'number-lines': directives.unchanged, # integer or None
'linenos': directives.unchanged,
- 'tab-width': directives.nonnegative_int}
+ 'tab-width': directives.nonnegative_int,
+ 'emphasize-lines': directives.unchanged_required}
has_content = True
def run(self):
@@ -103,7 +104,33 @@ class CodeBlock(Directive):
else:
anchor_ref = 'rest_code_' + uuid.uuid4().hex
- formatter = utils.NikolaPygmentsHTML(anchor_ref=anchor_ref, classes=classes, linenos=linenos, linenostart=linenostart)
+ linespec = self.options.get('emphasize-lines')
+ if linespec:
+ try:
+ nlines = len(self.content)
+ hl_lines = utils.parselinenos(linespec, nlines)
+ if any(i >= nlines for i in hl_lines):
+ raise self.error(
+ 'line number spec is out of range(1-%d): %r' %
+ (nlines, self.options['emphasize-lines'])
+ )
+ hl_lines = [x + 1 for x in hl_lines if x < nlines]
+ except ValueError as err:
+ raise self.error(err)
+ else:
+ hl_lines = None
+
+ extra_kwargs = {}
+ if hl_lines is not None:
+ extra_kwargs['hl_lines'] = hl_lines
+
+ formatter = utils.NikolaPygmentsHTML(
+ anchor_ref=anchor_ref,
+ classes=classes,
+ linenos=linenos,
+ linenostart=linenostart,
+ **extra_kwargs
+ )
out = pygments.highlight(code, lexer, formatter)
node = nodes.raw('', out, format='html')
diff --git a/nikola/plugins/compile/rest/media.py b/nikola/plugins/compile/rest/media.py
index eb7a69e..6d0436d 100644
--- a/nikola/plugins/compile/rest/media.py
+++ b/nikola/plugins/compile/rest/media.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/rest/post_list.py b/nikola/plugins/compile/rest/post_list.py
index d953372..1799790 100644
--- a/nikola/plugins/compile/rest/post_list.py
+++ b/nikola/plugins/compile/rest/post_list.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2013-2021 Udo Spallek, Roberto Alsina and others.
+# Copyright © 2013-2022 Udo Spallek, Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/rest/soundcloud.py b/nikola/plugins/compile/rest/soundcloud.py
index 65d9e6b..87b1483 100644
--- a/nikola/plugins/compile/rest/soundcloud.py
+++ b/nikola/plugins/compile/rest/soundcloud.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/rest/thumbnail.py b/nikola/plugins/compile/rest/thumbnail.py
index 1cce086..6f10a7f 100644
--- a/nikola/plugins/compile/rest/thumbnail.py
+++ b/nikola/plugins/compile/rest/thumbnail.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2014-2021 Pelle Nilsson and others.
+# Copyright © 2014-2022 Pelle Nilsson and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/rest/vimeo.py b/nikola/plugins/compile/rest/vimeo.py
index 1b1dbcc..b4f89ff 100644
--- a/nikola/plugins/compile/rest/vimeo.py
+++ b/nikola/plugins/compile/rest/vimeo.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/compile/rest/youtube.py b/nikola/plugins/compile/rest/youtube.py
index 24220e5..de3f2fa 100644
--- a/nikola/plugins/compile/rest/youtube.py
+++ b/nikola/plugins/compile/rest/youtube.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -48,7 +48,7 @@ class Plugin(RestExtension):
CODE = """\
<div class="youtube-video{align}">
<iframe width="{width}" height="{height}"
-src="https://www.youtube-nocookie.com/embed/{yid}?rel=0&wmode=transparent"
+src="https://www.youtube-nocookie.com/embed/{yid}?rel=0&wmode=transparent{start_at}"
frameborder="0" allow="encrypted-media" allowfullscreen
></iframe>
</div>"""
@@ -69,7 +69,8 @@ class Youtube(Directive):
option_spec = {
"width": directives.unchanged,
"height": directives.unchanged,
- "align": _align_choice
+ "align": _align_choice,
+ "start_at": directives.unchanged
}
def run(self):
@@ -85,6 +86,14 @@ class Youtube(Directive):
options['align'] = ' align-' + self.options['align']
else:
options['align'] = ''
+
+ start_at = options.get('start_at')
+
+ if start_at:
+ options['start_at'] = '&start=' + start_at
+ else:
+ options['start_at'] = ''
+
return [nodes.raw('', CODE.format(**options), format='html')]
def check_content(self):
diff --git a/nikola/plugins/misc/__init__.py b/nikola/plugins/misc/__init__.py
index 71a3de4..0572088 100644
--- a/nikola/plugins/misc/__init__.py
+++ b/nikola/plugins/misc/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/misc/scan_posts.py b/nikola/plugins/misc/scan_posts.py
index b001b3a..efa797e 100644
--- a/nikola/plugins/misc/scan_posts.py
+++ b/nikola/plugins/misc/scan_posts.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/misc/taxonomies_classifier.py b/nikola/plugins/misc/taxonomies_classifier.py
index 946f57e..c6092b3 100644
--- a/nikola/plugins/misc/taxonomies_classifier.py
+++ b/nikola/plugins/misc/taxonomies_classifier.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/shortcode/chart.py b/nikola/plugins/shortcode/chart.py
index d15dd0d..2b88cfb 100644
--- a/nikola/plugins/shortcode/chart.py
+++ b/nikola/plugins/shortcode/chart.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/shortcode/listing.py b/nikola/plugins/shortcode/listing.py
index 72136ea..3046655 100644
--- a/nikola/plugins/shortcode/listing.py
+++ b/nikola/plugins/shortcode/listing.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2017-2021 Roberto Alsina and others.
+# Copyright © 2017-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/shortcode/post_list.py b/nikola/plugins/shortcode/post_list.py
index 2d8d170..5b24cc6 100644
--- a/nikola/plugins/shortcode/post_list.py
+++ b/nikola/plugins/shortcode/post_list.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2013-2021 Udo Spallek, Roberto Alsina and others.
+# Copyright © 2013-2022 Udo Spallek, Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/shortcode/thumbnail.py b/nikola/plugins/shortcode/thumbnail.py
index 48f5384..7a05320 100644
--- a/nikola/plugins/shortcode/thumbnail.py
+++ b/nikola/plugins/shortcode/thumbnail.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2017-2021 Roberto Alsina, Chris Warrick and others.
+# Copyright © 2017-2022 Roberto Alsina, Chris Warrick and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/__init__.py b/nikola/plugins/task/__init__.py
index 36ca227..10c54d0 100644
--- a/nikola/plugins/task/__init__.py
+++ b/nikola/plugins/task/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/archive.py b/nikola/plugins/task/archive.py
index 6f619e9..f083394 100644
--- a/nikola/plugins/task/archive.py
+++ b/nikola/plugins/task/archive.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/authors.py b/nikola/plugins/task/authors.py
index a62e9f2..d966a4f 100644
--- a/nikola/plugins/task/authors.py
+++ b/nikola/plugins/task/authors.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2015-2021 Juanjo Conti and others.
+# Copyright © 2015-2022 Juanjo Conti and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/bundles.py b/nikola/plugins/task/bundles.py
index f12b3a8..c71c255 100644
--- a/nikola/plugins/task/bundles.py
+++ b/nikola/plugins/task/bundles.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/categories.py b/nikola/plugins/task/categories.py
index b140101..11a0407 100644
--- a/nikola/plugins/task/categories.py
+++ b/nikola/plugins/task/categories.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/copy_assets.py b/nikola/plugins/task/copy_assets.py
index 960b16c..fd22e0d 100644
--- a/nikola/plugins/task/copy_assets.py
+++ b/nikola/plugins/task/copy_assets.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/copy_files.py b/nikola/plugins/task/copy_files.py
index 7d07662..3818808 100644
--- a/nikola/plugins/task/copy_files.py
+++ b/nikola/plugins/task/copy_files.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/galleries.py b/nikola/plugins/task/galleries.py
index c9b1915..a780d76 100644
--- a/nikola/plugins/task/galleries.py
+++ b/nikola/plugins/task/galleries.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -85,6 +85,7 @@ class Galleries(Task, ImageProcessor):
'exif_whitelist': site.config['EXIF_WHITELIST'],
'preserve_icc_profiles': site.config['PRESERVE_ICC_PROFILES'],
'index_path': site.config['INDEX_PATH'],
+ 'index_file': site.config['INDEX_FILE'],
'disable_indexes': site.config['DISABLE_INDEXES'],
'galleries_use_thumbnail': site.config['GALLERIES_USE_THUMBNAIL'],
'galleries_default_thumbnail': site.config['GALLERIES_DEFAULT_THUMBNAIL'],
@@ -270,6 +271,10 @@ class Galleries(Task, ImageProcessor):
for path, folder in folder_list:
fpost = self.parse_index(path, input_folder, output_folder)
if fpost:
+ # do not add galleries to the folders that are either
+ # of these states (#3598)
+ if fpost.is_draft or fpost.is_private or fpost.publish_later:
+ continue
ft = fpost.title(lang) or folder
else:
ft = folder
@@ -522,6 +527,9 @@ class Galleries(Task, ImageProcessor):
post.meta[lang]['title'] = os.path.split(gallery)[1]
# Register the post (via #2417)
self.site.post_per_input_file[index_path] = post
+ # Register post for the sitemap, too (#3598)
+ index_output = os.path.join(gallery, self.kw['index_file'])
+ self.site.post_per_file[index_output] = post
else:
post = None
return post
diff --git a/nikola/plugins/task/gzip.py b/nikola/plugins/task/gzip.py
index 04a78dd..62523c7 100644
--- a/nikola/plugins/task/gzip.py
+++ b/nikola/plugins/task/gzip.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/indexes.py b/nikola/plugins/task/indexes.py
index 1007c57..93c119b 100644
--- a/nikola/plugins/task/indexes.py
+++ b/nikola/plugins/task/indexes.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/listings.py b/nikola/plugins/task/listings.py
index d52ddb2..510411a 100644
--- a/nikola/plugins/task/listings.py
+++ b/nikola/plugins/task/listings.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/page_index.py b/nikola/plugins/task/page_index.py
index d18e150..4002e5c 100644
--- a/nikola/plugins/task/page_index.py
+++ b/nikola/plugins/task/page_index.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/pages.py b/nikola/plugins/task/pages.py
index 0c45f10..d30cdd0 100644
--- a/nikola/plugins/task/pages.py
+++ b/nikola/plugins/task/pages.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/posts.py b/nikola/plugins/task/posts.py
index 7308d55..86c85ae 100644
--- a/nikola/plugins/task/posts.py
+++ b/nikola/plugins/task/posts.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/redirect.py b/nikola/plugins/task/redirect.py
index 9b4db8c..b1262a0 100644
--- a/nikola/plugins/task/redirect.py
+++ b/nikola/plugins/task/redirect.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/robots.py b/nikola/plugins/task/robots.py
index 05ceba3..e1d8d00 100644
--- a/nikola/plugins/task/robots.py
+++ b/nikola/plugins/task/robots.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/scale_images.py b/nikola/plugins/task/scale_images.py
index e5e8a55..f317a3f 100644
--- a/nikola/plugins/task/scale_images.py
+++ b/nikola/plugins/task/scale_images.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2014-2021 Pelle Nilsson and others.
+# Copyright © 2014-2022 Pelle Nilsson and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/sitemap.py b/nikola/plugins/task/sitemap.py
index 17a180f..f99f2de 100644
--- a/nikola/plugins/task/sitemap.py
+++ b/nikola/plugins/task/sitemap.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/sources.py b/nikola/plugins/task/sources.py
index 8d2a9d1..107c8fb 100644
--- a/nikola/plugins/task/sources.py
+++ b/nikola/plugins/task/sources.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/tags.py b/nikola/plugins/task/tags.py
index cc2ced8..4b0cd8c 100644
--- a/nikola/plugins/task/tags.py
+++ b/nikola/plugins/task/tags.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/task/taxonomies.py b/nikola/plugins/task/taxonomies.py
index dee2550..719cf46 100644
--- a/nikola/plugins/task/taxonomies.py
+++ b/nikola/plugins/task/taxonomies.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/template/__init__.py b/nikola/plugins/template/__init__.py
index 5554e53..66f98f7 100644
--- a/nikola/plugins/template/__init__.py
+++ b/nikola/plugins/template/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/template/jinja.py b/nikola/plugins/template/jinja.py
index aec6063..8aa32aa 100644
--- a/nikola/plugins/template/jinja.py
+++ b/nikola/plugins/template/jinja.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/plugins/template/mako.py b/nikola/plugins/template/mako.py
index 8197518..5dc9fe5 100644
--- a/nikola/plugins/template/mako.py
+++ b/nikola/plugins/template/mako.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/post.py b/nikola/post.py
index 06de222..42df0eb 100644
--- a/nikola/post.py
+++ b/nikola/post.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -324,6 +324,7 @@ class Post(object):
for lang in self.translations:
if self.meta[lang].get('data') is not None:
self.data[lang] = utils.load_data(self.meta[lang]['data'])
+ self.register_depfile(self.meta[lang]['data'], lang=lang)
def _load_translated_metadata(self, default_metadata):
"""Load metadata from all translation sources."""
diff --git a/nikola/shortcodes.py b/nikola/shortcodes.py
index 797c1ea..cccea2d 100644
--- a/nikola/shortcodes.py
+++ b/nikola/shortcodes.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/state.py b/nikola/state.py
index 03f6280..a054d69 100644
--- a/nikola/state.py
+++ b/nikola/state.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
diff --git a/nikola/utils.py b/nikola/utils.py
index 363ab40..7157afb 100644
--- a/nikola/utils.py
+++ b/nikola/utils.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated
@@ -62,6 +62,7 @@ from doit import tools
from doit.cmdparse import CmdParse
from pkg_resources import resource_filename
from nikola.packages.pygments_better_html import BetterHtmlFormatter
+from typing import List
from unidecode import unidecode
# Renames
@@ -727,7 +728,7 @@ def load_messages(themes, translations, default_lang, themes_dirs):
for k, v in translation.MESSAGES.items():
if v:
messages[lang][k] = v
- del(translation)
+ del translation
except ImportError as orig:
last_exception = orig
del(english)
@@ -1689,7 +1690,7 @@ class NikolaPygmentsHTML(BetterHtmlFormatter):
kwargs['nowrap'] = False
super().__init__(**kwargs)
- def wrap(self, source, outfile):
+ def wrap(self, source, *args):
"""Wrap the ``source``, which is a generator yielding individual lines, in custom generators."""
style = []
if self.prestyles:
@@ -1707,6 +1708,18 @@ class NikolaPygmentsHTML(BetterHtmlFormatter):
# For consistency, override the default formatter.
pygments.formatters._formatter_cache['HTML'] = NikolaPygmentsHTML
+pygments.formatters._formatter_cache['html'] = NikolaPygmentsHTML
+_original_find_formatter_class = pygments.formatters.find_formatter_class
+
+
+def nikola_find_formatter_class(alias):
+ """Nikola-specific version of find_formatter_class."""
+ if "html" in alias.lower():
+ return NikolaPygmentsHTML
+ return _original_find_formatter_class(alias)
+
+
+pygments.formatters.find_formatter_class = nikola_find_formatter_class
def get_displayed_page_number(i, num_pages, site):
@@ -2007,6 +2020,33 @@ def map_metadata(meta, key, config):
meta[meta_key] = hook(meta[meta_key])
+def parselinenos(spec: str, total: int) -> List[int]:
+ """Parse a line number spec.
+
+ Example: "1,2,4-6" -> [0, 1, 3, 4, 5]
+ """
+ items = list()
+ parts = spec.split(',')
+ for part in parts:
+ try:
+ begend = part.strip().split('-')
+ if ['', ''] == begend:
+ raise ValueError
+ elif len(begend) == 1:
+ items.append(int(begend[0]) - 1)
+ elif len(begend) == 2:
+ start = int(begend[0] or 1) # left half open (cf. -10)
+ end = int(begend[1] or max(start, total)) # right half open (cf. 10-)
+ if start > end: # invalid range (cf. 10-1)
+ raise ValueError
+ items.extend(range(start - 1, end))
+ else:
+ raise ValueError
+ except Exception as exc:
+ raise ValueError('invalid line number spec: %r' % spec) from exc
+ return items
+
+
class ClassificationTranslationManager(object):
"""Keeps track of which classifications could be translated as which others.
diff --git a/nikola/winutils.py b/nikola/winutils.py
index 0a06c44..b5b8ffa 100644
--- a/nikola/winutils.py
+++ b/nikola/winutils.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-# Copyright © 2012-2021 Roberto Alsina and others.
+# Copyright © 2012-2022 Roberto Alsina and others.
# Permission is hereby granted, free of charge, to any
# person obtaining a copy of this software and associated