JSPM

nuxt-smartscript

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q36610F
  • License Apache-2.0

Smart typography transformations for Nuxt - automatic superscript, subscript, and symbol formatting

Package Exports

  • nuxt-smartscript

Readme

Nuxt SmartScript

npm version npm downloads License Nuxt

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-smartscript

Add 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 exports

Configuration

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 lint

License

Apache-2.0 - MITRE Corporation