{"_id":"@an-eriksson/markup-converter","_rev":"4-98a7649f32d17e5994f8542014673bd9","name":"@an-eriksson/markup-converter","dist-tags":{"latest":"1.0.2"},"versions":{"1.0.0":{"name":"@an-eriksson/markup-converter","version":"1.0.0","keywords":["markdown","html","converter","markup","parser","text-processing"],"author":{"name":"Andreas Eriksson","email":"ae225ak@student.lnu.se"},"license":"MIT","_id":"@an-eriksson/markup-converter@1.0.0","maintainers":[{"name":"an-eriksson","email":"andreas@andreaseriksson.me"}],"homepage":"https://github.com/AN-Eriksson/MarkupConverter#readme","bugs":{"url":"https://github.com/AN-Eriksson/MarkupConverter/issues"},"dist":{"shasum":"ca62e144ecda8f8bfd46d8573bd06d04a5060993","tarball":"https://registry.npmjs.org/@an-eriksson/markup-converter/-/markup-converter-1.0.0.tgz","fileCount":11,"integrity":"sha512-uDT37o5vicrabrb5w04F+Ey1InQmlvDVMRJVNGlu/qqKYWJt+8Yu5MIv5zYx6k6LGgOzEKNRTMWdNapDlB+/kA==","signatures":[{"sig":"MEQCIDBZrRszMU/1xTx4kjUBoFWE6Tmn1NcMvDJWvAtzorLIAiB5G3whsLW0YMk/2iFz7C8njtDRLxqTJBLzZQ4oWgKjJw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":22204},"main":"index.js","type":"module","engines":{"node":">=18.0.0"},"exports":{".":"./index.js"},"gitHead":"8d5420ec0c09c5394dc145b73582481b3b6bc9e7","scripts":{"lint":"eslint src/ tests/","test":"vitest run","format":"prettier --write src/ tests/","lint:fix":"eslint src/ tests/ --fix","test:unit":"vitest run tests/*Converter.test.js","test:watch":"vitest","format:check":"prettier --check src/ tests/","test:integration":"vitest run tests/MarkupConverter.test.js"},"_npmUser":{"name":"an-eriksson","email":"andreas@andreaseriksson.me"},"repository":{"url":"git+https://github.com/AN-Eriksson/MarkupConverter.git","type":"git"},"_npmVersion":"10.9.2","description":"A JavaScript library for converting Markdown to HTML","directories":{},"_nodeVersion":"22.16.0","_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.36.0","vitest":"^3.2.4","prettier":"^3.6.2","@eslint/js":"^9.36.0","eslint-config-prettier":"^10.1.8"},"_npmOperationalInternal":{"tmp":"tmp/markup-converter_1.0.0_1759128060583_0.4230644108613746","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@an-eriksson/markup-converter","version":"1.0.2","type":"module","main":"index.js","description":"A JavaScript library for converting Markdown to HTML","keywords":["markdown","html","converter","markup","parser","text-processing"],"author":{"name":"Andreas Eriksson","email":"ae225ak@student.lnu.se"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/AN-Eriksson/MarkupConverter.git"},"homepage":"https://github.com/AN-Eriksson/MarkupConverter#readme","bugs":{"url":"https://github.com/AN-Eriksson/MarkupConverter/issues"},"engines":{"node":">=18.0.0"},"exports":{".":"./index.js"},"scripts":{"test":"vitest run","test:unit":"vitest run tests/*Converter.test.js","test:integration":"vitest run tests/MarkupConverter.test.js","test:watch":"vitest","lint":"eslint src/ tests/","lint:fix":"eslint src/ tests/ --fix","format":"prettier --write src/ tests/","format:check":"prettier --check src/ tests/"},"devDependencies":{"@eslint/js":"^9.36.0","eslint":"^9.36.0","eslint-config-prettier":"^10.1.8","prettier":"^3.6.2","vitest":"^3.2.4"},"_id":"@an-eriksson/markup-converter@1.0.2","gitHead":"39cee516d871040b6e657580710bc69a8de3ba8f","_nodeVersion":"22.16.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-rU5g4bLUH50keDw1cOUvUVdeCltH4jit5zcGFv9XKePQEeOaD358tLuF4xeiS6bJcrUDoEl8GLIif3m59LAenA==","shasum":"c7ec62ffd4bfb337798a15d975ab6e5f99ca6e21","tarball":"https://registry.npmjs.org/@an-eriksson/markup-converter/-/markup-converter-1.0.2.tgz","fileCount":11,"unpackedSize":23489,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQC6/uJc9cLDmUIw9fzTRcFnSW/YZVAPwErPhsMdKX9F8AIhAPgfpdz6DTP8H+Y5wXNS1Q4KRWYhUm4wYkuU5chPGTZO"}]},"_npmUser":{"name":"an-eriksson","email":"andreas@andreaseriksson.me"},"directories":{},"maintainers":[{"name":"an-eriksson","email":"andreas@andreaseriksson.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/markup-converter_1.0.2_1760693487748_0.34128374107314086"},"_hasShrinkwrap":false}},"time":{"created":"2025-09-29T06:41:00.434Z","modified":"2025-10-17T09:31:28.165Z","1.0.0":"2025-09-29T06:41:00.786Z","1.0.1":"2025-10-17T09:24:03.247Z","1.0.2":"2025-10-17T09:31:27.956Z"},"bugs":{"url":"https://github.com/AN-Eriksson/MarkupConverter/issues"},"author":{"name":"Andreas Eriksson","email":"ae225ak@student.lnu.se"},"license":"MIT","homepage":"https://github.com/AN-Eriksson/MarkupConverter#readme","keywords":["markdown","html","converter","markup","parser","text-processing"],"repository":{"type":"git","url":"git+https://github.com/AN-Eriksson/MarkupConverter.git"},"description":"A JavaScript library for converting Markdown to HTML","maintainers":[{"name":"an-eriksson","email":"andreas@andreaseriksson.me"}],"readme":"# Markup Converter\n\nA JavaScript library for converting markup to HTML.\n\n## Installation\n```bash\nnpm install @an-eriksson/markup-converter\n```\n\n### Using the Main Converter\n```javascript\nimport { MarkupConverter } from '@an-eriksson/markup-converter'\n\nconst converter = new MarkupConverter()\nconst html = converter.convert('# Hello **World**!')\n// Output: <h1>Hello <strong>World</strong>!</h1>\n```\n\n### Using Individual Converters\n```javascript\nimport { HeadingConverter, InlineStyleConverter } from '@an-eriksson/markup-converter'\n\n// Use only heading conversion\nconst headingConverter = new HeadingConverter()\nconst headingHtml = headingConverter.convert('# My Heading')\n// Output: <h1>My Heading</h1>\n\n// Use only inline style conversion\nconst styleConverter = new InlineStyleConverter()\nconst styledHtml = styleConverter.convert('This is **bold** and *italic*')\n// Output: This is <strong>bold</strong> and <em>italic</em>\n```\n\n### Complete Example\n```javascript\nimport { MarkupConverter } from '@an-eriksson/markup-converter'\n\nconst converter = new MarkupConverter()\nconst markdown = `# My Blog Post\n\nThis is an introduction paragraph with **bold** and *italic* text.\n\n## Code Example\n\n\\`\\`\\`\nconst greet = () => \"Hello World!\"\n\\`\\`\\`\n\n### Features\n\n- Easy to use\n- **Lightweight** library  \n- Supports \\`inline code\\`\n\n### Steps\n\n1. Install the package\n2. Import and use\n\n## Conclusion\n\nAnother paragraph with ~~strikethrough~~ text.`\n\nconst html = converter.convert(markdown)\nconsole.log(html)\n// Output:\n// <h1>My Blog Post</h1>\n//\n// <p>This is an introduction paragraph with <strong>bold</strong> and <em>italic</em> text.</p>\n//\n// <h2>Code Example</h2>\n//\n// <pre><code>\n// const greet = () => \"Hello World!\"\n// </code></pre>\n//\n// <h3>Features</h3>\n//\n// <ul>\n// <li>Easy to use</li>\n// <li><strong>Lightweight</strong> library</li>\n// <li>Supports <code>inline code</code></li>\n// </ul>\n//\n// <h3>Steps</h3>\n//\n// <ol>\n// <li>Install the package</li>\n// <li>Import and use</li>\n// </ol>\n//\n// <h2>Conclusion</h2>\n//\n// <p>Another paragraph with <del>strikethrough</del> text.</p>\n```\n\n## Features\n- Convert headings (# ## ###)\n- Convert bold text (**text**)\n- Convert italic text (*text*)\n- Convert strikethrough text (~~text~~)\n- Convert inline code (`code`)\n- Convert code blocks (``` code ```)\n- Convert unordered lists (- item)\n- Convert ordered lists (1. item)\n- Convert paragraphs (wrap plain text in `<p>` tags)\n- Select individual converters for specific use cases\n\n## Missing Functionality / Future Enhancements\n\nWhile Markup Converter provides core markdown conversion capabilities, there are several features that are **not yet implemented**:\n\n### 📋 **Lists**\n- [ ] **Nested lists** - Currently only supports single-level lists\n- [ ] **Mixed list types** - Cannot mix ordered/unordered lists in same structure\n- [ ] **List items with multiple paragraphs** - Limited to single-line items\n\n### 🔗 **Links and Media**\n- [ ] **Links** - `[text](url)` syntax not supported\n- [ ] **Images** - `![alt](src)` syntax not supported\n\n### 📊 **Advanced Formatting**\n- [ ] **Tables** - Markdown table syntax not supported\n- [ ] **Blockquotes** - `>` syntax for quoted text\n- [ ] **Horizontal rules** - `---` or `***` syntax\n- [ ] **Line breaks** - `  ` (double space) for `<br>` tags\n\n### 🎨 **Styling and Extensions**\n- [ ] **HTML attributes** - Class names, IDs, data attributes\n\n### ⚙️ **Configuration**\n- [ ] **Custom converter options** - Configurable behavior per converter\n- [ ] **Output formatting** - Prettify output with indentation etc.\n\n### Workarounds\n\nFor missing functionality, consider:\n- **Links/Images**: Use raw HTML in your markdown\n- **Tables**: Convert to HTML table markup manually  \n- **Advanced lists**: Structure as separate simple lists\n- **Blockquotes**: Use HTML `<blockquote>` tags directly\n\n### Flexible Architecture\nYou can use the complete `MarkupConverter` for full markdown processing, or import individual converters to handle only specific formatting:\n\n```javascript\n// Full conversion pipeline\nimport { MarkupConverter } from '@an-eriksson/markup-converter'\n\n// Cherry-pick specific converters\nimport { HeadingConverter, InlineStyleConverter } from '@an-eriksson/markup-converter'\n```\n\nThis modular approach allows you to:\n- Build custom conversion pipelines\n- Handle specific markdown features in isolation\n\n### Available Converters\n\nThis library includes several specialized converters that can be used individually or together:\n\n### HeadingConverter\nConverts markdown headings to HTML heading tags.\n\n**Converts:**\n- `# Heading 1` → `<h1>Heading 1</h1>`\n- `## Heading 2` → `<h2>Heading 2</h2>`\n- `### Heading 3` → `<h3>Heading 3</h3>`\n\n### InlineStyleConverter\nHandles all inline text formatting within paragraphs and other content.\n\n**Converts:**\n- `**bold text**` → `<strong>bold text</strong>`\n- `*italic text*` → `<em>italic text</em>`\n- `~~strikethrough~~` → `<del>strikethrough</del>`\n- `` `inline code` `` → `<code>inline code</code>`\n\n### CodeBlockConverter\nConverts markdown code blocks to HTML pre and code elements.\n````markdown\n```\nfunction example() {\n  return \"Hello World\"\n}\n```\n````\n\n→\n````html\n<pre><code>\nfunction example() {\n  return \"Hello World\"\n}\n</code></pre>\n````\n\n### ListConverter\nConverts both ordered and unordered lists.\n\n**Converts:**\n```markdown\n- Item 1\n- Item 2\n- Item 3\n```\n→\n```html\n<ul>\n<li>Item 1</li>\n<li>Item 2</li>\n<li>Item 3</li>\n</ul>\n```\n\n```markdown\n1. First item\n2. Second item\n3. Third item\n```\n→\n```html\n<ol>\n<li>First item</li>\n<li>Second item</li>\n<li>Third item</li>\n</ol>\n```\n\n### ParagraphConverter\nWraps plain text blocks in paragraph tags while preserving other HTML elements.\n\n**Converts:**\n```markdown\nThis is a paragraph.\n\nThis is another paragraph.\n```\n→\n```html\n<p>This is a paragraph.</p>\n\n<p>This is another paragraph.</p>\n```\n\n## API Reference\n\n### MarkupConverter\n\n#### `constructor()`\nCreates a new MarkupConverter instance with all converters.\n\n#### `convert(text: string): string`\nConverts markdown text to HTML.\n\n**Parameters:**\n- `text` - The markdown text to convert\n\n**Returns:**\n- HTML string\n\n### Individual Converters\n\nAll converters extend `AbstractConverter` and implement the same interface:\n\n- `HeadingConverter` - Converts `# ## ###` to `<h1> <h2> <h3>`\n- `CodeBlockConverter` - Converts code blocks to `<pre><code>`\n- `InlineStyleConverter` - Converts `**bold**`, `*italic*`, `~~strikethrough~~`, `` `inline code` ``\n- `ListConverter` - Converts `- item` and `1. item` to `<ul>` and `<ol>`\n- `ParagraphConverter` - Wraps plain text in `<p>` tags\n\n## Testing\n\nThis project uses a comprehensive testing approach:\n\n- **Unit Tests**: Individual converters are tested in isolation (`tests/*Converter.test.js`)\n- **Integration Tests**: The complete `MarkupConverter` pipeline is tested end-to-end (`tests/MarkupConverter.test.js`)\n\n```bash\nnpm test                    # Run all tests\nnpm run test:watch          # Run tests in watch mode\n\n# Run specific test types\nnpm test -- tests/HeadingConverter.test.js         # Unit tests for headings\nnpm test -- tests/CodeBlockConverter.test.js       # Unit tests for code blocks\nnpm test -- tests/InlineStyleConverter.test.js     # Unit tests for inline styles\nnpm test -- tests/ParagraphConverter.test.js       # Unit tests for paragraphs\nnpm test -- tests/ListConverter.test.js            # Unit tests for lists\nnpm test -- tests/MarkupConverter.test.js          # Integration tests for full pipeline\n```","readmeFilename":"README.md"}