/*
* Copyright (C) 2026 Fluxer Contributors
*
* This file is part of Fluxer.
*
* Fluxer is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Fluxer is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Fluxer. If not, see
Hello
')).toBe('Hello'); expect(stripHtmlTags('
')).toBe('');
});
it('strips nested tags', () => {
expect(stripHtmlTags('Nested
One
Two
Three
')).toBe('OneTwoThree'); }); it('handles malformed tags', () => { expect(stripHtmlTags('First paragraph
Second paragraph
')).toBe('First paragraph\n\nSecond paragraph'); }); it('converts br tags to newlines', () => { expect(htmlToMarkdown('Line oneconst x = 1;')).toContain('```\nconst x = 1;\n```');
});
it('converts inline code', () => {
expect(htmlToMarkdown('Use npm install to install')).toBe('Use `npm install` to install');
});
it('converts bold tags', () => {
expect(htmlToMarkdown('Bold text')).toBe('**Bold text**');
expect(htmlToMarkdown('Bold text')).toBe('**Bold text**');
});
it('converts italic tags', () => {
expect(htmlToMarkdown('Italic text')).toBe('_Italic text_');
expect(htmlToMarkdown('Italic text')).toBe('_Italic text_');
});
it('converts links', () => {
expect(htmlToMarkdown('Example')).toBe('[Example](https://example.com)');
});
it('collapses multiple newlines', () => {
expect(htmlToMarkdown('A
B
')).toBe('A\n\nB'); }); it('trims whitespace', () => { expect(htmlToMarkdown('Content
')).toBe('Content'); }); it('decodes HTML entities in the result', () => { expect(htmlToMarkdown('Hello & World
')).toBe('Hello & World'); }); it('handles complex mixed HTML', () => { const html = 'This is bold and italic with a link.
'; const expected = 'This is **bold** and _italic_ with a [link](https://example.com).'; expect(htmlToMarkdown(html)).toBe(expected); }); });