Addresses the `# TODO: "S"` marker in pyproject.toml. Adds a per-file
ignore for `pelican/tests/*` covering S-rules that are universally
appropriate to suppress in test code (S101 assert, S105/S106 hardcoded
test passwords, S108 /tmp paths, S311 non-cryptographic randomness,
S603/S607 subprocess fixtures, S104 loopback bindings).
Each remaining library finding gets a targeted `# noqa` with a
justification comment explaining why the call is acceptable in
context. Two `S101` suppressions in `pelican_import.py` and one
`S504` in `server.py` flag latent issues that warrant follow-up but
are intentionally deferred so this commit stays purely lint-enabling.
No behavior changes.
Report whether required metadata is missing, or present but empty,
instead of the vague "could not find information about" message, which
was misleading when a field such as `:title:` was present but empty.
A title made only of punctuation, such as "???", slugifies to an empty
string. When URL patterns use `{slug}`, the content was written to
".html", and two such articles crashed the build. Skip content with such
titles with an error that suggests setting a slug. Patterns that don't
use the slug, such as date-based `ARTICLE_SAVE_AS` patterns, are
unaffected.
When `CATEGORY_SAVE_AS` is disabled but `CATEGORIES_SAVE_AS` is not,
the category index page was still generated, and its links pointed to
category pages that don't exist. This change shows category names
without links in the Simple and NotMyIdea themes in such cases and also
documents that both settings must be disabled to remove all
category-related output.
PR #3589 tied category assignment to `CATEGORY_SAVE_AS`, so disabling
category pages also removed article categories and broke `{category}`
in URL patterns (#3596). PR #3597 restored folder-based categories, but
articles outside a subfolder still lost `DEFAULT_CATEGORY`. This change
assigns it again, so `CATEGORY_SAVE_AS` only controls whether category
pages are generated. Setting `DEFAULT_CATEGORY = None` is now the
documented way to have no categories.
This also stops the Simple and NotMyIdea themes from linking to category
pages that don't exist.
- Check that pages with an empty or `None` title fail validation.
- Use a fixed date in the article test.
- Add a reader-level test using the empty `:title:` source from #3566 to
confirm readers produce an empty title that is then rejected.
On systems such as Windows, JavaScript files can be incorrectly assigned
the "text/plain" MIME type in Python's mimetypes module. This overrides
this behavior when it occurs.
* Strip TOC elements from article summaries
Automatically remove table of contents divs and toc-backref anchor links
from article summaries when displayed outside full article context
(e.g., on homepage, in RSS feeds).
ReStructuredText automatically generates anchor links in section headings
when a table of contents directive is present. These anchors work perfectly
on full article pages, but become broken links when article summaries appear
on homepage or in feeds - the anchor targets don't exist in that context.
This change adds a strip_toc_elements_from_html() function in pelican/utils.py
that uses regex to remove:
- TOC div blocks (<div class="contents">...</div>) containing broken navigation
- toc-backref anchor links from headings while preserving heading text
Both removals are necessary since TOC anchor targets don't exist in summary context.
The function is called automatically in Content.get_summary() so all
summaries are cleaned without requiring configuration or template changes.
Includes comprehensive unit tests covering various TOC formats, edge cases,
and case-insensitive matching.
---------
Co-authored-by: Justin Mayer <entroP@gmail.com>
This fixes `invoke setup` failing in fresh virtual environments.
The top-level import of `livereload` caused tasks.py to fail before any
task could execute, since `livereload` is a development dependency only
installed by PDM as part of the setup task.