markdown-magic 3.7.0 → 4.0.1

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.
Files changed (131) hide show
  1. package/cli.js +1 -1
  2. package/package.json +22 -26
  3. package/src/{cli.js → cli-run.js} +0 -0
  4. package/src/{cli.test.js → cli-run.test.js} +1 -1
  5. package/src/defaults.js +2 -2
  6. package/src/index.js +26 -20
  7. package/src/index.test.js +2 -2
  8. package/src/process-contents.js +2 -458
  9. package/src/transforms/code/index.js +6 -6
  10. package/src/transforms/fileTree.js +3 -3
  11. package/src/transforms/index.js +21 -21
  12. package/src/transforms/install.js +3 -3
  13. package/src/transforms/sectionToc.js +4 -4
  14. package/src/transforms/toc.js +5 -5
  15. package/src/transforms/wordCount.js +3 -2
  16. package/src/utils/fs.js +22 -0
  17. package/src/utils/fs.test.js +2 -2
  18. package/src/utils/index.js +21 -0
  19. package/src/utils/regex-timeout.js +1 -1
  20. package/src/utils/text.js +103 -11
  21. package/types/_tests/config.d.ts +4 -0
  22. package/types/_tests/config.d.ts.map +1 -0
  23. package/types/_tests/errors.test.d.ts +2 -0
  24. package/types/_tests/errors.test.d.ts.map +1 -0
  25. package/types/_tests/fixtures/js/simple.d.ts +8 -0
  26. package/types/_tests/fixtures/js/simple.d.ts.map +1 -0
  27. package/types/_tests/fixtures/local-code-file-lines.d.ts +1 -0
  28. package/types/_tests/fixtures/local-code-file-lines.d.ts.map +1 -0
  29. package/types/_tests/fixtures/local-code-file.d.ts +2 -0
  30. package/types/_tests/fixtures/local-code-file.d.ts.map +1 -0
  31. package/types/_tests/fixtures/local-code-id.d.ts +3 -0
  32. package/types/_tests/fixtures/local-code-id.d.ts.map +1 -0
  33. package/types/_tests/transforms-toc.test.d.ts +2 -0
  34. package/types/_tests/transforms-toc.test.d.ts.map +1 -0
  35. package/types/_tests/transforms.test.d.ts +2 -0
  36. package/types/_tests/transforms.test.d.ts.map +1 -0
  37. package/types/_tests/utils/diff.d.ts +3 -0
  38. package/types/_tests/utils/diff.d.ts.map +1 -0
  39. package/types/cli.d.ts +3 -0
  40. package/types/cli.d.ts.map +1 -0
  41. package/types/src/argparse/argparse.d.ts +33 -0
  42. package/types/src/argparse/argparse.d.ts.map +1 -0
  43. package/types/src/argparse/argparse.test.d.ts +2 -0
  44. package/types/src/argparse/argparse.test.d.ts.map +1 -0
  45. package/types/src/argparse/index.d.ts +3 -0
  46. package/types/src/argparse/index.d.ts.map +1 -0
  47. package/types/src/argparse/splitOutsideQuotes.d.ts +2 -0
  48. package/types/src/argparse/splitOutsideQuotes.d.ts.map +1 -0
  49. package/types/src/argparse/splitOutsideQuotes.test.d.ts +2 -0
  50. package/types/src/argparse/splitOutsideQuotes.test.d.ts.map +1 -0
  51. package/types/src/cli-run.d.ts +4 -0
  52. package/types/src/cli-run.d.ts.map +1 -0
  53. package/types/src/cli-run.test.d.ts +2 -0
  54. package/types/src/cli-run.test.d.ts.map +1 -0
  55. package/types/src/defaults.d.ts +5 -0
  56. package/types/src/defaults.d.ts.map +1 -0
  57. package/types/src/globparse.d.ts +18 -0
  58. package/types/src/globparse.d.ts.map +1 -0
  59. package/types/src/globparse.test.d.ts +2 -0
  60. package/types/src/globparse.test.d.ts.map +1 -0
  61. package/types/src/index.d.ts +189 -0
  62. package/types/src/index.d.ts.map +1 -0
  63. package/types/src/index.test.d.ts +2 -0
  64. package/types/src/index.test.d.ts.map +1 -0
  65. package/types/src/process-contents.d.ts +3 -0
  66. package/types/src/process-contents.d.ts.map +1 -0
  67. package/types/src/transforms/code/index.d.ts +35 -0
  68. package/types/src/transforms/code/index.d.ts.map +1 -0
  69. package/types/src/transforms/code/resolve-github-file.d.ts +24 -0
  70. package/types/src/transforms/code/resolve-github-file.d.ts.map +1 -0
  71. package/types/src/transforms/code/resolve-github-file.test.d.ts +2 -0
  72. package/types/src/transforms/code/resolve-github-file.test.d.ts.map +1 -0
  73. package/types/src/transforms/file.d.ts +3 -0
  74. package/types/src/transforms/file.d.ts.map +1 -0
  75. package/types/src/transforms/fileTree.d.ts +35 -0
  76. package/types/src/transforms/fileTree.d.ts.map +1 -0
  77. package/types/src/transforms/index.d.ts +9 -0
  78. package/types/src/transforms/index.d.ts.map +1 -0
  79. package/types/src/transforms/install.d.ts +25 -0
  80. package/types/src/transforms/install.d.ts.map +1 -0
  81. package/types/src/transforms/remote.d.ts +3 -0
  82. package/types/src/transforms/remote.d.ts.map +1 -0
  83. package/types/src/transforms/sectionToc.d.ts +3 -0
  84. package/types/src/transforms/sectionToc.d.ts.map +1 -0
  85. package/types/src/transforms/toc.d.ts +31 -0
  86. package/types/src/transforms/toc.d.ts.map +1 -0
  87. package/types/src/transforms/wordCount.d.ts +3 -0
  88. package/types/src/transforms/wordCount.d.ts.map +1 -0
  89. package/types/src/types.d.ts +11 -0
  90. package/types/src/types.d.ts.map +1 -0
  91. package/types/src/utils/details.d.ts +3 -0
  92. package/types/src/utils/details.d.ts.map +1 -0
  93. package/types/src/utils/format-md.d.ts +2 -0
  94. package/types/src/utils/format-md.d.ts.map +1 -0
  95. package/types/src/utils/fs.d.ts +29 -0
  96. package/types/src/utils/fs.d.ts.map +1 -0
  97. package/types/src/utils/fs.test.d.ts +2 -0
  98. package/types/src/utils/fs.test.d.ts.map +1 -0
  99. package/types/src/utils/hash-file.d.ts +2 -0
  100. package/types/src/utils/hash-file.d.ts.map +1 -0
  101. package/types/src/utils/index.d.ts +25 -0
  102. package/types/src/utils/index.d.ts.map +1 -0
  103. package/types/src/utils/load-config.d.ts +2 -0
  104. package/types/src/utils/load-config.d.ts.map +1 -0
  105. package/types/src/utils/logs.d.ts +11 -0
  106. package/types/src/utils/logs.d.ts.map +1 -0
  107. package/types/src/utils/regex-timeout.d.ts +2 -0
  108. package/types/src/utils/regex-timeout.d.ts.map +1 -0
  109. package/types/src/utils/regex.d.ts +7 -0
  110. package/types/src/utils/regex.d.ts.map +1 -0
  111. package/types/src/utils/remoteRequest.d.ts +3 -0
  112. package/types/src/utils/remoteRequest.d.ts.map +1 -0
  113. package/types/src/utils/sortOrder.d.ts +3 -0
  114. package/types/src/utils/sortOrder.d.ts.map +1 -0
  115. package/types/src/utils/string-break.d.ts +3 -0
  116. package/types/src/utils/string-break.d.ts.map +1 -0
  117. package/types/src/utils/syntax.d.ts +77 -0
  118. package/types/src/utils/syntax.d.ts.map +1 -0
  119. package/types/src/utils/text.d.ts +146 -0
  120. package/types/src/utils/text.d.ts.map +1 -0
  121. package/types/src/utils/text.test.d.ts +2 -0
  122. package/types/src/utils/text.test.d.ts.map +1 -0
  123. package/types/src/utils/toc.d.ts +67 -0
  124. package/types/src/utils/toc.d.ts.map +1 -0
  125. package/types/src/utils/toposort.d.ts +7 -0
  126. package/types/src/utils/toposort.d.ts.map +1 -0
  127. package/README.md +0 -700
  128. package/src/block-parser-js.test.js +0 -171
  129. package/src/block-parser.js +0 -405
  130. package/src/block-parser.test.js +0 -481
  131. package/src/process-file.js +0 -66
@@ -0,0 +1,77 @@
1
+ export function getSyntaxInfo(syntax?: string): any;
2
+ export namespace syntaxMap {
3
+ export { html as md };
4
+ export { html as markdown };
5
+ export { html };
6
+ export { js };
7
+ export { js as json };
8
+ export { jsx };
9
+ export { jsx as mdx };
10
+ export { yaml as yml };
11
+ export { yaml };
12
+ export { sql };
13
+ export { toml };
14
+ }
15
+ declare namespace html {
16
+ let tags: string[];
17
+ let pattern: string[];
18
+ }
19
+ declare namespace js {
20
+ let tags_1: string[];
21
+ export { tags_1 as tags };
22
+ let pattern_1: string[];
23
+ export { pattern_1 as pattern };
24
+ export let singleLineTag: string;
25
+ export let singleLinePattern: string;
26
+ export let singleLine: string;
27
+ }
28
+ declare namespace jsx {
29
+ let tags_2: string[];
30
+ export { tags_2 as tags };
31
+ let pattern_2: string[];
32
+ export { pattern_2 as pattern };
33
+ }
34
+ declare namespace yaml {
35
+ let tags_3: string[];
36
+ export { tags_3 as tags };
37
+ let pattern_3: string[];
38
+ export { pattern_3 as pattern };
39
+ let singleLineTag_1: string;
40
+ export { singleLineTag_1 as singleLineTag };
41
+ let singleLinePattern_1: string;
42
+ export { singleLinePattern_1 as singleLinePattern };
43
+ let singleLine_1: string;
44
+ export { singleLine_1 as singleLine };
45
+ export let content: string;
46
+ export function converter(str?: string): string;
47
+ }
48
+ declare namespace sql {
49
+ let tags_4: string[];
50
+ export { tags_4 as tags };
51
+ let pattern_4: string[];
52
+ export { pattern_4 as pattern };
53
+ let singleLineTag_2: string;
54
+ export { singleLineTag_2 as singleLineTag };
55
+ let singleLinePattern_2: string;
56
+ export { singleLinePattern_2 as singleLinePattern };
57
+ let singleLine_2: string;
58
+ export { singleLine_2 as singleLine };
59
+ let content_1: string;
60
+ export { content_1 as content };
61
+ }
62
+ declare namespace toml {
63
+ let tags_5: string[];
64
+ export { tags_5 as tags };
65
+ let pattern_5: string[];
66
+ export { pattern_5 as pattern };
67
+ let singleLineTag_3: string;
68
+ export { singleLineTag_3 as singleLineTag };
69
+ let singleLinePattern_3: string;
70
+ export { singleLinePattern_3 as singleLinePattern };
71
+ let singleLine_3: string;
72
+ export { singleLine_3 as singleLine };
73
+ let content_2: string;
74
+ export { content_2 as content };
75
+ }
76
+ export {};
77
+ //# sourceMappingURL=syntax.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"syntax.d.ts","sourceRoot":"","sources":["../../../src/utils/syntax.js"],"names":[],"mappings":"AAuGA,oDAEC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAzDY,gDAIV"}
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Convert string to Title Case
3
+ * @param {string} str - Input string
4
+ * @returns {string} Title Case string
5
+ */
6
+ export function toTitleCase(str?: string): string;
7
+ /**
8
+ * Split string into lines
9
+ * @param {string} str - Input string
10
+ * @returns {string[]} Array of lines
11
+ */
12
+ export function getLines(str?: string): string[];
13
+ /**
14
+ * Get line count from string
15
+ * @param {string} str - Input string
16
+ * @returns {number} Number of lines
17
+ */
18
+ export function getLineCount(str?: string): number;
19
+ /**
20
+ * Get word count from string
21
+ * @param {string} str - Input string
22
+ * @returns {number} Word count
23
+ */
24
+ export function getWordCount(str?: string): number;
25
+ /**
26
+ * Get leading spaces from text
27
+ * @param {string} text - Input text
28
+ * @returns {string} Leading spaces
29
+ */
30
+ export function getLeadingSpaces(text: string): string;
31
+ /**
32
+ * Get first character from string
33
+ * @param {string} str - Input string
34
+ * @returns {string} First character
35
+ */
36
+ export function getFirstCharacter(str: string): string;
37
+ /**
38
+ * Get last character from string
39
+ * @param {string} str - Input string
40
+ * @returns {string} Last character
41
+ */
42
+ export function getLastCharacter(str: string): string;
43
+ /**
44
+ * Get row and column position from character index
45
+ * @param {string} input - Input string
46
+ * @param {number} indexToFind - Character index to find
47
+ * @returns {{row: number, col: number}} Row and column position
48
+ */
49
+ export function getRowAndColumnFromCharPos(input: string, indexToFind: number): {
50
+ row: number;
51
+ col: number;
52
+ };
53
+ /**
54
+ * Get text between character positions
55
+ * @param {string} text - Input text
56
+ * @param {number} start - Start position
57
+ * @param {number} end - End position
58
+ * @returns {string} Text between positions
59
+ */
60
+ export function getTextBetweenChars(text: string, start: number, end: number): string;
61
+ /**
62
+ * Get text between two words
63
+ * @param {string} s
64
+ * @param {string} prefix
65
+ * @param {string} suffix
66
+ * @returns {string}
67
+ */
68
+ export function getTextBetweenWords(s: string, prefix: string, suffix: string): string;
69
+ /**
70
+ * Retrieves the text content between the specified start and end lines.
71
+ *
72
+ * @param {string} content - The content to extract text from.
73
+ * @param {number} startLine - The line number where the extraction should start.
74
+ * @param {number} endLine - The line number where the extraction should end.
75
+ * @returns {string|undefined} - The extracted text content, or undefined if both startLine and endLine are not defined.
76
+ */
77
+ export function getTextBetweenLines(content: string, startLine: number, endLine: number): string | undefined;
78
+ /**
79
+ * Replace text between character positions
80
+ * @param {string} str - Input string
81
+ * @param {number} start - Start position
82
+ * @param {number} end - End position
83
+ * @param {string} newStr - Replacement string
84
+ * @returns {string} Modified string
85
+ */
86
+ export function replaceTextBetweenChars(str: string, start: number, end: number, newStr: string): string;
87
+ /**
88
+ * Strip indentation from string
89
+ * @param {string} string - Input string
90
+ * @param {number} [indentation] - Indentation level to strip
91
+ * @returns {string} String with indentation stripped
92
+ */
93
+ export function stripIndent(string: string, indentation?: number): string;
94
+ /**
95
+ * Add indentation to string
96
+ * @param {string} string - Input string
97
+ * @param {number} [count=1] - Number of indentations to add
98
+ * @param {object} [options={}] - Options for indentation
99
+ * @param {string} [options.indent=' '] - Character(s) to use for indentation
100
+ * @param {boolean} [options.includeEmptyLines=false] - Whether to indent empty lines
101
+ * @returns {string} Indented string
102
+ */
103
+ export function indentString(string: string, count?: number, options?: {
104
+ indent?: string;
105
+ includeEmptyLines?: boolean;
106
+ }): string;
107
+ /**
108
+ * Removes the indentation of multiline strings
109
+ * @link https://github.com/victornpb/tiny-dedent/
110
+ * @param {string} str - A template literal string
111
+ * @returns {string} A string without the indentation
112
+ */
113
+ export function dedentString(str: string): string;
114
+ /**
115
+ * Strip out comment blocks
116
+ * @param {string} str
117
+ * @param {import('../types').SyntaxType} syntax
118
+ * @returns {string} clean comment-less string
119
+ */
120
+ export function stripComments(str: string, syntax?: import("../types").SyntaxType): string;
121
+ export function convertCommentSyntax(str: any, { from, to }: {
122
+ from: any;
123
+ to: any;
124
+ }): any;
125
+ export function stripSingleLineDoubleSlashComments(str?: string): string;
126
+ export function stripMultiLineDoubleSlashComments(str?: string): string;
127
+ export function stripHTMLComments(block: any, opts: any): any;
128
+ /**
129
+ * Trim leading & trailing spaces/line breaks in code and keeps the indentation of the first non-empty line
130
+ * @param {string|number} str
131
+ * @returns {string}
132
+ */
133
+ export function trimString(str?: string | number): string;
134
+ /**
135
+ * Find minimum indentation in string
136
+ * @param {string} string - Input string
137
+ * @returns {number} Minimum indentation level
138
+ */
139
+ export function findMinIndent(string: string): number;
140
+ /**
141
+ * Check if string is uppercase
142
+ * @param {string} str - Input string
143
+ * @returns {boolean} True if uppercase
144
+ */
145
+ export function isUpperCase(str: string): boolean;
146
+ //# sourceMappingURL=text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../src/utils/text.js"],"names":[],"mappings":"AAgaA;;;;GAIG;AACH,kCAHW,MAAM,GACJ,MAAM,CAmBlB;AApbD;;;;GAIG;AACH,+BAHW,MAAM,GACJ,MAAM,EAAE,CAIpB;AAED;;;;GAIG;AACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;AAgBD;;;;GAIG;AACH,mCAHW,MAAM,GACJ,MAAM,CAIlB;AAoBD;;;;GAIG;AACH,uCAHW,MAAM,GACJ,MAAM,CAKlB;AA1BD;;;;GAIG;AACH,uCAHW,MAAM,GACJ,MAAM,CAIlB;AAED;;;;GAIG;AACH,sCAHW,MAAM,GACJ,MAAM,CAIlB;AAvCD;;;;;GAKG;AACH,kDAJW,MAAM,eACN,MAAM,GACJ;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAC,CAQtC;AAuCD;;;;;;GAMG;AACH,0CALW,MAAM,SACN,MAAM,OACN,MAAM,GACJ,MAAM,CAIlB;AAED;;;;;;GAMG;AACH,uCALW,MAAM,UACN,MAAM,UACN,MAAM,GACJ,MAAM,CAYlB;AAcD;;;;;;;GAOG;AACH,6CALW,MAAM,aACN,MAAM,WACN,MAAM,GACJ,MAAM,GAAC,SAAS,CAiB5B;AAnCD;;;;;;;GAOG;AACH,6CANW,MAAM,SACN,MAAM,OACN,MAAM,UACN,MAAM,GACJ,MAAM,CAIlB;AAgDD;;;;;GAKG;AACH,oCAJW,MAAM,gBACN,MAAM,GACJ,MAAM,CASlB;AAaD;;;;;;;;GAQG;AACH,qCAPW,MAAM,UACN,MAAM,YAEd;IAAyB,MAAM,GAAvB,MAAM;IACY,iBAAiB,GAAnC,OAAO;CACf,GAAU,MAAM,CAclB;AAED;;;;;GAKG;AACH,kCAHW,MAAM,GACJ,MAAM,CAOlB;AAuCD;;;;;GAKG;AACH,mCAJW,MAAM,WACN,OAAO,UAAU,EAAE,UAAU,GAC3B,MAAM,CAmBlB;AA4DD;;;QAmCC;AAvFD,yEAEC;AAND,wEAEC;AAeD,8DAqCC;AArKD;;;;GAIG;AACF,iCAHU,MAAM,GAAC,MAAM,GACX,MAAM,CAMlB;AAnCD;;;;GAIG;AACH,sCAHW,MAAM,GACJ,MAAM,CAMlB;AAnBD;;;;GAIG;AACH,iCAHW,MAAM,GACJ,OAAO,CAInB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=text.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text.test.d.ts","sourceRoot":"","sources":["../../../src/utils/text.test.js"],"names":[],"mappings":""}
@@ -0,0 +1,67 @@
1
+ export type TocOptions = {
2
+ /**
3
+ * - Collapse toc in <details> pane
4
+ */
5
+ collapse?: boolean;
6
+ /**
7
+ * - Text in expand pane
8
+ */
9
+ collapseText?: string;
10
+ /**
11
+ * - Text to exclude from toc
12
+ */
13
+ excludeText?: string;
14
+ /**
15
+ * - Exclude first heading from toc
16
+ */
17
+ firsth1?: boolean;
18
+ /**
19
+ * - Mark as sub section table of contents
20
+ */
21
+ sub?: boolean;
22
+ /**
23
+ * - Max depth of headings to add to toc.
24
+ */
25
+ maxDepth?: number;
26
+ };
27
+ export type TocAPI = {
28
+ /**
29
+ * - Toc generation options
30
+ */
31
+ options: TocOptions;
32
+ /**
33
+ * - Markdown contents
34
+ */
35
+ fileContent: string;
36
+ /**
37
+ * - Path to markdown file
38
+ */
39
+ srcPath: string;
40
+ /**
41
+ * - Get block details for sub tables
42
+ */
43
+ getBlockDetails: Function;
44
+ };
45
+ /**
46
+ * @typedef {object} TocOptions
47
+ * @property {boolean} [collapse = false] - Collapse toc in <details> pane
48
+ * @property {string} [collapseText] - Text in expand pane
49
+ * @property {string} [excludeText] - Text to exclude from toc
50
+ * @property {boolean} [firsth1 = true] - Exclude first heading from toc
51
+ * @property {boolean} [sub = false] - Mark as sub section table of contents
52
+ * @property {number} [maxDepth = 4] - Max depth of headings to add to toc.
53
+ */
54
+ /**
55
+ * @typedef {object} TocAPI
56
+ * @property {TocOptions} options - Toc generation options
57
+ * @property {string} fileContent - Markdown contents
58
+ * @property {string} srcPath - Path to markdown file
59
+ * @property {function} getBlockDetails - Get block details for sub tables
60
+ */
61
+ /**
62
+ * Generate a table of contents
63
+ * @param {TocAPI} api
64
+ * @returns
65
+ */
66
+ export function odlGenerateToc({ options, fileContent, srcPath, getBlockDetails }: TocAPI): Promise<any>;
67
+ //# sourceMappingURL=toc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toc.d.ts","sourceRoot":"","sources":["../../../src/utils/toc.js"],"names":[],"mappings":";;;;eASc,OAAO;;;;mBACP,MAAM;;;;kBACN,MAAM;;;;cACN,OAAO;;;;UACP,OAAO;;;;eACP,MAAM;;;;;;aAKN,UAAU;;;;iBACV,MAAM;;;;aACN,MAAM;;;;;;AAdpB;;;;;;;;GAQG;AAEH;;;;;;GAMG;AAEH;;;;GAIG;AACH,mFAHW,MAAM,gBA4RhB"}
@@ -0,0 +1,7 @@
1
+ declare function _exports(edges: any[]): any[];
2
+ declare namespace _exports {
3
+ export { toposort as array };
4
+ }
5
+ export = _exports;
6
+ declare function toposort(nodes: any, edges: any): any[];
7
+ //# sourceMappingURL=toposort.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toposort.d.ts","sourceRoot":"","sources":["../../../src/utils/toposort.js"],"names":[],"mappings":"AASiB,+CAEhB;;;;;AAID,yDAsDC"}