Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only one occurrence of {static} is replaced inside a tag #3419

Open
3 tasks done
mart-e opened this issue Nov 3, 2024 · 1 comment
Open
3 tasks done

Only one occurrence of {static} is replaced inside a tag #3419

mart-e opened this issue Nov 3, 2024 · 1 comment
Labels

Comments

@mart-e
Copy link
Contributor

mart-e commented Nov 3, 2024

  • I have read the Filing Issues and subsequent “How to Get Help” sections of the documentation.

  • I can reproduce this problem with stock/default settings file, theme, and sample content (as described in above “How to Get Help” sections of the documentation).

  • I have searched the issues (including closed ones) and believe that this is not a duplicate.

  • OS version and name: Archlinux

  • Python version:Python 3.11

  • Pelican version: 4.10

Issue

Create a page on a new site that contains a tag with two {static} instructions. For instance an image with lazyloading:

Title: Test Article
Date: 2024-11-02 21:30
Author: me
Category: Uncategorized
Tags: 
Slug: test-article
Status: draft

<img
  src="{static}/images/placeholder.png"
  data-src="{static}/images/my_image.png"
  loading="lazy"/>

Bye

Expected output:

<p><img
  src="/images/placeholder.png"
  data-src="/images/my_image.png"
  loading="lazy"/></p>
<p>Bye</p>

Found output:

<p><img
  src="{static}/images/placeholder.png"
  data-src="/images/my_image.png"
  loading="lazy"/></p>
<p>Bye</p>

The issue comes from the regex

(?P<markup><[^\>]+  # match tag with all url-value attributes
(?:href|src|poster|data|cite|formaction|action|content)\s*=\s*)
(?P<quote>["\'])      # require value to be quoted
(?P<path>[{|](?P<what>.*?)[|}](?P<value>.*?))  # the url value
(?P=quote)"""

that will match only the last attribute (greedy). Changing it to (?P<markup><[^\>]+? makes it lazy and matches the first one only so doesn’t really solves the issue either.

Still trying to find a way to solve this without using 2 regex call but I am no expert in regex.
(edit: #3420 maybe?)

@mart-e mart-e added the bug label Nov 3, 2024
mart-e added a commit to mart-e/pelican that referenced this issue Nov 3, 2024
If a markup element contains more than one {static} or {attach} value,
only the last one was replaced.

Simplify the regex to match every occurrence

Fixes getpelican#3419
mart-e added a commit to mart-e/pelican that referenced this issue Nov 3, 2024
If a markup element contains more than one {static} or {attach} value,
only the last one was replaced.

Simplify the regex to match every occurrence

Fixes getpelican#3419
@justinmayer justinmayer changed the title Only one occurrence of {static} is replaced inside a tag Only one occurrence of {static} is replaced inside a tag Nov 3, 2024
@GiovanH
Copy link
Contributor

GiovanH commented Nov 4, 2024

Might relate to #3409?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants