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

BUG: strip_attr ignores CSS selectors, strip_tags ignores HTML tags #157

Open
Kalimbim opened this issue Nov 13, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@Kalimbim
Copy link

Version (please complete the following information):

  • OS: MacOS 15.1
  • Browser: Safari
  • Web Clipper version: 0.9.5
  • Obsidian version: 1.7.6

Describe the bug

  • strip_attr:("class") removes all attributes.
  • strip_tags:("b") removes all attributes

Expected behavior

  • strip_attr:("class") should remove either only class or all other attributes (eg id).
  • strip_tags:("b") should remove either <b> … </b> or all the other tags.

I'm not sure about the intended behavior. Help is confusing. Does it strip only or everything but the provided CSS selectors/HTML tags? I'd prefer the former and a different syntax for the latter, but the other way around is also ok.

URLs where the bug occurs

I added the examples from Help to a test page: https://write.as/i52g2kl1kwnghey2.md

To reproduce

Steps to reproduce the behavior:

  1. Write template with note content:
{{selectorHtml:article}}

---

{{selectorHtml:article|strip_attr:("class")}}

---

{{selectorHtml:article|strip_tags:("b")}}

template

  1. Go to: https://write.as/i52g2kl1kwnghey2.md

  2. Open Clipper

  3. See error

result

I expected to see either this result:

<article class="norm h-entry"><h2 id="title" class="p-name">Testing Webclipper</h2><div id="post-body" class="e-content"><div class="test" id="example">Content</div>

<p>Hello <b>world</b>!</p>
</div></article>

---

<article><h2 id="title">Testing Webclipper</h2><div id="post-body"><div id="example">Content</div>

<p>Hello <b>world</b>!</p>
</div></article>

---

<article class="norm h-entry"><h2 id="title" class="p-name">Testing Webclipper</h2><div id="post-body" class="e-content"><div class="test" id="example">Content</div>

<p>Hello world!</p>
</div></article>

Or that result:

<article class="norm h-entry"><h2 id="title" class="p-name">Testing Webclipper</h2><div id="post-body" class="e-content"><div class="test" id="example">Content</div>

<p>Hello <b>world</b>!</p>
</div></article>

---

<article class="norm h-entry"><h2 class="p-name">Testing Webclipper</h2><div class="e-content"><div class="test">Content</div>

<p>Hello <b>world</b>!</p>
</div></article>

---

Content

Hello <b>world</b>

Your template file

{
  "schemaVersion": "0.1.0",
  "name": "Testing Testing",
  "behavior": "create",
  "noteContentFormat": "{{selectorHtml:article}}\n\n---\n\n{{selectorHtml:article|strip_attr:(\"class\")}}\n\n---\n\n{{selectorHtml:article|strip_tags:(\"b\")}}",
  "properties": [],
  "triggers": [],
  "noteNameFormat": "{{title}}",
  "path": "Clippings"
}
@Kalimbim
Copy link
Author

Apparently both filters work without brackets. Test:

{{selectorHtml:article}}

---

{{selectorHtml:article|strip_attr:"class"}}

---

{{selectorHtml:article|strip_tags:"b"}}

works almost like expected:

  • remove all attributes except class
  • remove all tags except b

ex

Open bugs:

  • support notation with brackets for consistency with other filters and for compatibility with help pages
  • fix error in help pages for strip_attr. Help seems to describe the opposite of the actual behavior

@kepano kepano added the bug Something isn't working label Nov 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants