craftcms / anchors

Add anchor links to headings in your Craft CMS website content.
MIT License
48 stars 7 forks source link

URL formatting issues #31

Closed anita-chouhan closed 1 year ago

anita-chouhan commented 1 year ago

Description

Found 2 cases of URL formatting issues with the Anchors filter.

  1. When the heading contains a word in all caps.
  2. When there are quotes present in the heading.

Usage Example:

Header Text:

  1. Pitch FAQs
  2. We'd love to hear from you

Rendering Code:

{% apply anchors('h2') %}
  <h2>Pitch FAQs</h2>
{% endapply %}

For the case when a quote is present in header It generates two different URLs based on the rendering code


{% apply anchors('h2') %}
  <h2>We'd love to hear from you</h2>
{% endapply %}

Generates: /#wed-love-to-hear-from-you

{{ tag('h2', {
  text: "We'd love to hear from you",
})|anchors }}

Generates: /#we-039-d-love-to-hear-from-you

Generated Output:

  1. .../#pitch-fAQs
  2. .../#we-039-d-love-to-hear-from-you or /#wed-love-to-hear-from-you

Expected Output:

  1. Letters should be all lowercase or in the original form as added.
  2. No numeric characters in the URL.

Additional info

i-just commented 1 year ago

Hi, thanks for reporting! I raised a PR.

angrybrad commented 1 year ago

Resolved in https://github.com/craftcms/anchors/pull/34 and will be included in the next release.

anita-chouhan commented 1 year ago

Hi, thank you for providing the fix. I found that for some special characters, it's still generating incorrect URLs.

For example:

{% apply anchors('h2') %}
  <h2>Let’s talk about clothes.</h2>
{% endapply %}

Generates: #let-rsquo-s-talk-about-clothes
anita-chouhan commented 1 year ago

Hello @angrybrad, any updates on the issue?