Skip to content

Commit 1ef4725

Browse files
committed
Improve doc
1 parent 75acc97 commit 1ef4725

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

content/terms/explanation/filters.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,9 @@ Filters are necessary when standard CSS selectors and range selectors cannot ade
1313

1414
Use filters when:
1515

16-
- **CSS selectors are insufficient**: When noise appears within content that can't be targeted with selectors or [range selectors]({{< relref "terms/explanation/range-selectors" >}}) with the [`select`]({{< relref "terms/reference/declaration/#ref-select" >}}) and [`remove`]({{< relref "terms/reference/declaration/#ref-remove" >}}) properties.
17-
- **Content is dynamically generated**: When elements change on each page load, such as:
18-
- Tracking parameters in URLs (e.g., `utm_source`, `utm_medium`)
19-
- Dynamic elements with changing classes or IDs
20-
- **Complex tasks are needed**: When content transformation is needed such as:
21-
- Converting images to base64 to store them in the terms version.
22-
- Converting date-based content to a more stable format (e.g., "Updated X days ago" to "Last updated on YYYY-MM-DD")
16+
- **CSS selectors are insufficient**, for example when noise appears within content that can't be targeted with selectors or [range selectors]({{< relref "terms/explanation/range-selectors" >}}) with the [`select`]({{< relref "terms/reference/declaration/#ref-select" >}}) and [`remove`]({{< relref "terms/reference/declaration/#ref-remove" >}}) properties.
17+
- **Content is dynamically generated**, for example when elements change on each page load with tracking parameters in URLs (like `utm_source`, `utm_medium`) or dynamic elements with changing classes or IDs.
18+
- **Complex tasks are needed**, for example when content transformation is required such as converting images to base64 to store them in the terms version or converting date-based content to a more stable format (like "Updated X days ago" to "Last updated on YYYY-MM-DD").
2319

2420
## How filters work
2521

@@ -29,16 +25,16 @@ Filters are JavaScript functions that receive a JSDOM document instance and can
2925

3026
When designing filters, follow these core principles:
3127

32-
- **Be specific**: Target only the noise you want to remove. Avoid broad selectors that might accidentally remove important content.
28+
- **Be specific**: target only the noise you want to remove. Avoid broad selectors that might accidentally remove important content.
3329

3430
> For example, if your filter converts relative dates to absolute dates, use `.metadata time` not `time` which might also affect important effective dates within the terms content.
3531
36-
- **Be idempotent**: Filters should produce the same result even if run multiple times on their own output. This ensures consistency and prevents unexpected behavior.
32+
- **Be idempotent**: filters should produce the same result even if run multiple times on their own output. This ensures consistency and prevents unexpected behavior.
3733

3834
> For example, if your filter adds section numbers like "1." to headings, check if numbers already exist to prevent "1. Privacy Policy" from becoming "1. 1. Privacy Policy" on repeated runs.
3935
40-
- **Be efficient**: Use efficient DOM queries and avoid unnecessary operations. Process only the elements you need to modify.
36+
- **Be efficient**: use efficient DOM queries and avoid unnecessary operations. Process only the elements you need to modify.
4137

4238
> For example, if your filter updates timestamp elements with a specific class, use `document.querySelector('.timestamp')` instead of `document.querySelectorAll('*')` followed by filtering for timestamp elements.
4339
44-
- **Be safe**: Filters should not accidentally remove important content. The generated version should always be checked after adding a filter to ensure it still contains the whole terms content.
40+
- **Be safe**: filters should not accidentally remove important content. The generated version should always be checked after adding a filter to ensure it still contains the whole terms content.

content/terms/reference/filters.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ Result:
175175
import fetch from 'isomorphic-fetch';
176176

177177
export async function convertImagesToBase64(document, selector, documentDeclaration) {
178-
const images = Array.from(document.querySelectorAll(`selector`));
178+
const images = Array.from(document.querySelectorAll(selector));
179179

180180
return Promise.all(images.map(async ({ src }, index) => {
181181
if (src.startsWith('data:')) {

0 commit comments

Comments
 (0)