nuxt-smartscript
v0.1.3
Published
Smart typography transformations for Nuxt - automatic superscript, subscript, and symbol formatting
Maintainers
Readme
Nuxt SmartScript
Smart typography transformations for Nuxt - automatic superscript, subscript, and symbol formatting.
Features
- 🔤 Trademark, Registered & Copyright Symbols - Converts (TM) → ™, (R) → ®, and (C) → ©
- 🔢 Ordinal Numbers - 1st, 2nd, 3rd with proper superscript
- 🧪 Chemical Formulas - H2O, CO2 with subscripts
- 📐 Mathematical Notation - x^2 superscript, x_1 subscript
- ⚡ Performance Optimized - Debounced processing, batch updates
- 🎨 Fully Customizable - Adjust positioning for different fonts
- ♿ Accessible - Proper ARIA labels for screen readers
- 🔧 TypeScript Support - Full type safety
Quick Setup
Install the module:
# npm
npm install nuxt-smartscript
# pnpm
pnpm add nuxt-smartscript
# yarn
yarn add nuxt-smartscriptAdd to your nuxt.config.ts:
export default defineNuxtConfig({
modules: ['nuxt-smartscript']
})That's it! The plugin will automatically process your content ✨
Architecture
The module follows a modular architecture for maintainability:
src/runtime/
├── plugin.ts # Main plugin orchestrator
├── composables/
│ └── useSmartScript.ts # Vue composable for components
└── smartscript/
├── types.ts # TypeScript interfaces
├── config.ts # Configuration management
├── patterns.ts # Regex patterns & matchers
├── processor.ts # Text processing logic
├── dom.ts # DOM manipulation utilities
├── engine.ts # Core processing engine
├── errors.ts # Error handling & recovery
└── index.ts # Public API exportsConfiguration
Customize the behavior in nuxt.config.ts:
export default defineNuxtConfig({
modules: ['nuxt-smartscript'],
smartscript: {
// Customize positioning for your font
positioning: {
trademark: {
body: '-0.5em',
headers: '-0.7em'
},
registered: {
body: '-0.25em',
headers: '-0.45em'
}
},
// Performance tuning
performance: {
debounce: 100,
batchSize: 50
}
}
})Vue Composable
Use in your components:
<script setup>
const { process, stats, isProcessing } = useSmartScript()
// Manually trigger processing
onMounted(() => {
process()
})
</script>
<template>
<div>
<p>Processed: {{ stats.total }} transformations</p>
</div>
</template>Contributing
We welcome contributions! Please see CONTRIBUTING.md for detailed guidelines.
Development
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build module
pnpm prepack
# Run playground
pnpm dev
# Lint code
pnpm lintLicense
Apache-2.0 - MITRE Corporation
