diff --git a/README.md b/README.md
index 03280ed..1078698 100644
--- a/README.md
+++ b/README.md
@@ -91,27 +91,3 @@ wrapping.
- `options.ignoreTags (string[], optional)` – Tags to keep intact in output (e.g., ["b", "mark"])
- `options.wrapWords (number, optional)` – Maximum words per line (takes priority over wrapLength)
- `options.wrapLength (number, optional)` – Maximum characters per line
-
-## Examples
-
-```ts
-import { textify } from 'html-textify';
-
-const html = `
-
Title
- Paragraph with bold and italic
-
-`;
-
-const text = textify({ html });
-console.log(text);
-
-/* Output:
-Title
-
-Paragraph with **bold** and *italic*
-
-- Item 1
-- Item 2
-*/
-```
diff --git a/package.json b/package.json
index 183baaf..0f6c4d7 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "html-textify",
- "version": "1.0.0",
+ "version": "1.0.1",
"description": "Convert html to plain text",
"main": "dist/index.js",
"module": "dist/index.mjs",
diff --git a/src/index.ts b/src/index.ts
index 969ce69..044e3b2 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -4,10 +4,10 @@ import { wrapByWords } from './utils/wrapByWords';
export interface TextifyOptions {
html: string;
- preserveFormatting?: boolean; // optional, default true
- ignoreTags?: string[]; // optional tags to keep intact
- wrapLength?: number; // max chars per line
- wrapWords?: number; // max words per line
+ preserveFormatting?: boolean;
+ ignoreTags?: string[];
+ wrapLength?: number;
+ wrapWords?: number;
}
/**
diff --git a/src/utils/preserveFormat.test.ts b/src/utils/preserveFormat.test.ts
index 90d04ab..27a3ebe 100644
--- a/src/utils/preserveFormat.test.ts
+++ b/src/utils/preserveFormat.test.ts
@@ -31,7 +31,7 @@ describe('preserveFormat', () => {
it('should handle links', () => {
const html = 'Click here';
- const expected = 'Click here (https://example.com)';
+ const expected = '[Click here](https://example.com)';
expect(preserveFormat({ html })).toBe(expected);
});
@@ -119,7 +119,7 @@ describe('preserveFormat', () => {
const result = preserveFormat({ html });
- const expected = `Main Heading\n\nParagraph with **bold** and *italic* text\n\n- Item 1\n- Item 2\n1. First\n2. Second\nLink (https://link.com)> Quote line 1\n> Quote line 2A1 B1\nA2 B2`;
+ const expected = `Main Heading\n\nParagraph with **bold** and *italic* text\n\n- Item 1\n- Item 2\n1. First\n2. Second\n[Link](https://link.com)> Quote line 1\n> Quote line 2A1 B1\nA2 B2`;
expect(result).toBe(expected);
});
});
diff --git a/src/utils/preserveFormat.ts b/src/utils/preserveFormat.ts
index 402377e..07524e3 100644
--- a/src/utils/preserveFormat.ts
+++ b/src/utils/preserveFormat.ts
@@ -66,7 +66,7 @@ export function preserveFormat({
html = !ignoreTags.includes('a')
? html.replace(
/(.*?)<\/a>/gi,
- (_m, href: string, text: string) => `${text} (${href})`
+ (_m, href: string, text: string) => `[${text}](${href})`
)
: html;