turnish 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +270 -0
- package/dist/index.cjs +68 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.iife.js +68 -0
- package/dist/index.iife.js.map +1 -0
- package/dist/index.mjs +818 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +68 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/collapse-whitespace.d.ts +39 -0
- package/dist/types/default-rules.d.ts +4 -0
- package/dist/types/html-parser.d.ts +4 -0
- package/dist/types/index.d.ts +113 -0
- package/dist/types/node.d.ts +22 -0
- package/dist/types/root-node.d.ts +5 -0
- package/dist/types/rules.d.ts +30 -0
- package/dist/types/utilities.d.ts +16 -0
- package/package.json +56 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ExtendedNode } from './node';
|
|
2
|
+
import { TurnishOptions } from './index';
|
|
3
|
+
export type RuleFilterFunction = (node: ExtendedNode, options: TurnishOptions) => boolean;
|
|
4
|
+
export type RuleFilter = string | string[] | RuleFilterFunction;
|
|
5
|
+
type RuleReplacementFunction = (...args: any[]) => string;
|
|
6
|
+
export interface Rule {
|
|
7
|
+
filter?: RuleFilter;
|
|
8
|
+
replacement: RuleReplacementFunction | ((content: string, node: any, options: TurnishOptions, previousNode?: any) => string);
|
|
9
|
+
references?: string[];
|
|
10
|
+
urlReferenceIdMap?: Map<string, number>;
|
|
11
|
+
append?: (options: TurnishOptions) => string;
|
|
12
|
+
}
|
|
13
|
+
export declare class Rules {
|
|
14
|
+
options: TurnishOptions;
|
|
15
|
+
private _keep;
|
|
16
|
+
private _remove;
|
|
17
|
+
blankRule: Rule;
|
|
18
|
+
keepReplacement: RuleReplacementFunction;
|
|
19
|
+
markdownIncludingHtmlReplacement: RuleReplacementFunction;
|
|
20
|
+
defaultRule: Rule;
|
|
21
|
+
array: Rule[];
|
|
22
|
+
constructor(options: TurnishOptions);
|
|
23
|
+
add(key: string, rule: Rule): void;
|
|
24
|
+
keep(filter: RuleFilter): void;
|
|
25
|
+
remove(filter: RuleFilter): void;
|
|
26
|
+
forNode(node: ExtendedNode): Rule;
|
|
27
|
+
private isUnsupportedElement;
|
|
28
|
+
forEach(fn: (rule: Rule, index: number) => void): void;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare function repeat(character: string, count: number): string;
|
|
2
|
+
export declare function trimLeadingNewlines(string: string): string;
|
|
3
|
+
export declare function trimTrailingNewlines(string: string): string;
|
|
4
|
+
export declare function trimNewlines(string: string): string;
|
|
5
|
+
export declare const blockElements: string[];
|
|
6
|
+
export declare function isBlock(node: Node): boolean;
|
|
7
|
+
export declare const voidElements: string[];
|
|
8
|
+
export declare function isVoid(node: Node): boolean;
|
|
9
|
+
export declare function hasVoid(node: Node): boolean;
|
|
10
|
+
export declare const standardMarkdownElements: string[];
|
|
11
|
+
export declare function isMeaningfulWhenBlank(node: Node): boolean;
|
|
12
|
+
export declare function hasMeaningfulWhenBlank(node: Node): boolean;
|
|
13
|
+
export declare function sanitizeWhitespace(string: string): string;
|
|
14
|
+
export declare function sanitizedLinkContent(content: string): string;
|
|
15
|
+
export declare function sanitizedLinkTitle(content: string): string;
|
|
16
|
+
export type RequireOnly<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "turnish",
|
|
3
|
+
"description": "HTML to Markdown converter",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": "Manabu Nakazawa",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"access": "public"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
13
|
+
"browser": "./dist/index.umd.js",
|
|
14
|
+
"node": "./dist/index.cjs",
|
|
15
|
+
"import": "./dist/index.mjs",
|
|
16
|
+
"require": "./dist/index.cjs",
|
|
17
|
+
"default": "./dist/index.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./package.json": "./package.json"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@mixmark-io/domino": "^2.2.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@rollup/plugin-typescript": "^12.3.0",
|
|
26
|
+
"@types/node": "^24.9.2",
|
|
27
|
+
"standard": "^17.1.2",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"vite": "^7.1.12",
|
|
30
|
+
"vite-plugin-dts": "^4.5.4",
|
|
31
|
+
"vitest": "^4.0.5",
|
|
32
|
+
"@changesets/cli": "^2.29.7"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"keywords": [
|
|
38
|
+
"converter",
|
|
39
|
+
"html",
|
|
40
|
+
"markdown"
|
|
41
|
+
],
|
|
42
|
+
"license": "MIT",
|
|
43
|
+
"repository": {
|
|
44
|
+
"type": "git",
|
|
45
|
+
"url": "https://github.com/mshibanami/turnish.git"
|
|
46
|
+
},
|
|
47
|
+
"scripts": {
|
|
48
|
+
"build": "vite build",
|
|
49
|
+
"dev": "vite",
|
|
50
|
+
"test": "npm run build && vitest",
|
|
51
|
+
"typecheck": "tsc --noEmit",
|
|
52
|
+
"changeset": "changeset",
|
|
53
|
+
"changeset:version": "changeset version",
|
|
54
|
+
"changeset:publish": "changeset publish"
|
|
55
|
+
}
|
|
56
|
+
}
|