|
| 1 | +# Default Selectors |
| 2 | + |
| 3 | +This document describes which HTML elements are processed by nuxt-smartscript by default and which are excluded. |
| 4 | + |
| 5 | +## Elements Processed by Default |
| 6 | + |
| 7 | +### Container Elements |
| 8 | +- `main` - Main content areas |
| 9 | +- `article` - Article containers |
| 10 | +- `section` - Content sections |
| 11 | +- `header` - Header areas |
| 12 | +- `footer` - Footer areas |
| 13 | +- `.content` - Elements with "content" class |
| 14 | +- `[role="main"]` - Elements with main ARIA role |
| 15 | +- `.prose` - Prose content (common in documentation) |
| 16 | +- `.blog-post` - Blog post containers |
| 17 | +- `.blog-content` - Blog content areas |
| 18 | + |
| 19 | +### Heading Elements |
| 20 | +All heading levels are processed: |
| 21 | +- `h1`, `h2`, `h3`, `h4`, `h5`, `h6` |
| 22 | + |
| 23 | +### Text Content Elements |
| 24 | +- `p` - Paragraphs |
| 25 | +- `li` - List items |
| 26 | +- `td` - Table cells |
| 27 | +- `th` - Table headers |
| 28 | +- `blockquote` - Block quotes |
| 29 | +- `caption` - Table/figure captions |
| 30 | +- `dt` - Definition terms |
| 31 | +- `dd` - Definition descriptions |
| 32 | +- `figcaption` - Figure captions |
| 33 | + |
| 34 | +### Inline Elements |
| 35 | +- `span` - Generic inline containers |
| 36 | +- `a` - Links |
| 37 | +- `strong` - Strong emphasis |
| 38 | +- `em` - Emphasis |
| 39 | +- `b` - Bold text |
| 40 | +- `i` - Italic text |
| 41 | +- `small` - Small print (often legal text) |
| 42 | +- `cite` - Citations |
| 43 | +- `abbr` - Abbreviations |
| 44 | + |
| 45 | +### Interactive Elements |
| 46 | +- `button` - Button text |
| 47 | +- `label` - Form labels |
| 48 | +- `legend` - Fieldset legends |
| 49 | +- `summary` - Details/summary elements |
| 50 | + |
| 51 | +### Other Semantic Elements |
| 52 | +- `address` - Contact information |
| 53 | + |
| 54 | +## Elements Excluded by Default |
| 55 | + |
| 56 | +### Code Elements |
| 57 | +- `pre` - Preformatted code blocks |
| 58 | +- `code` - Inline code |
| 59 | +- `script` - Script tags |
| 60 | +- `style` - Style tags |
| 61 | + |
| 62 | +### Custom Exclusions |
| 63 | +- `.no-superscript` - Elements with this class |
| 64 | +- `[data-no-superscript]` - Elements with this data attribute |
| 65 | + |
| 66 | +### Already Processed |
| 67 | +These classes indicate content already transformed: |
| 68 | +- `sup.ss-sup` - Already superscripted elements |
| 69 | +- `sub.ss-sub` - Already subscripted elements |
| 70 | +- `.ss-tm` - Trademark symbols |
| 71 | +- `.ss-reg` - Registered symbols |
| 72 | +- `.ss-ordinal` - Ordinal numbers |
| 73 | +- `.ss-chemical` - Chemical formulas |
| 74 | +- `.ss-math` - Mathematical notation |
| 75 | + |
| 76 | +## Customizing Selectors |
| 77 | + |
| 78 | +You can customize which elements are processed in your `nuxt.config.ts`: |
| 79 | + |
| 80 | +```typescript |
| 81 | +export default defineNuxtConfig({ |
| 82 | + smartscript: { |
| 83 | + selectors: { |
| 84 | + // Add more selectors |
| 85 | + include: [ |
| 86 | + ...defaultSelectors, |
| 87 | + '.my-custom-class', |
| 88 | + 'custom-element' |
| 89 | + ], |
| 90 | + // Add more exclusions |
| 91 | + exclude: [ |
| 92 | + ...defaultExclusions, |
| 93 | + '.skip-this', |
| 94 | + '[data-raw-text]' |
| 95 | + ] |
| 96 | + } |
| 97 | + } |
| 98 | +}) |
| 99 | +``` |
| 100 | + |
| 101 | +## Best Practices |
| 102 | + |
| 103 | +1. **Performance**: More specific selectors (classes, IDs) are faster than broad element selectors |
| 104 | +2. **Avoid Over-Processing**: Don't include generic containers like `div` unless necessary |
| 105 | +3. **Test Thoroughly**: When adding new selectors, test that they don't interfere with your layout |
| 106 | +4. **Use Exclusions**: Use the exclusion classes/attributes to skip specific elements |
| 107 | + |
| 108 | +## Common Use Cases |
| 109 | + |
| 110 | +### Documentation Sites |
| 111 | +The default selectors work well for documentation with the `.prose` class and semantic HTML. |
| 112 | + |
| 113 | +### Blogs |
| 114 | +Blog-specific classes like `.blog-post` and `.blog-content` are included by default. |
| 115 | + |
| 116 | +### Applications |
| 117 | +Interactive elements like buttons and form labels are processed to handle branded UI text. |
| 118 | + |
| 119 | +### Legal Text |
| 120 | +The `small` element is included as it often contains copyright notices and legal text with ® and ™ symbols. |
0 commit comments