quikdown 1.0.4 → 1.1.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * quikdown_bd - Bidirectional Markdown/HTML Converter
2
+ * quikdown_bd - Bidirectional Markdown Parser
3
3
  * TypeScript definitions
4
4
  */
5
5
 
@@ -7,15 +7,12 @@ declare module 'quikdown/bd' {
7
7
  /**
8
8
  * Options for configuring the quikdown_bd parser
9
9
  */
10
- export interface QuikdownBDOptions {
10
+ export interface QuikdownBdOptions {
11
11
  /**
12
12
  * Custom renderer for fenced code blocks.
13
- * Return undefined to use default rendering.
14
- * @param content - The code block content (unescaped)
15
- * @param language - The language identifier (or empty string)
16
- * @returns HTML string or undefined for default rendering
13
+ * Uses the FencePlugin interface from quikdown module.
17
14
  */
18
- fence_plugin?: (content: string, language: string) => string | undefined;
15
+ fence_plugin?: import('./quikdown').FencePlugin;
19
16
 
20
17
  /**
21
18
  * If true, uses inline styles instead of CSS classes.
@@ -30,24 +27,40 @@ declare module 'quikdown/bd' {
30
27
  * @default false
31
28
  */
32
29
  allow_unsafe_urls?: boolean;
30
+
31
+ /**
32
+ * Always true for quikdown_bd - adds data-qd attributes for bidirectional conversion.
33
+ * @default true
34
+ */
35
+ bidirectional?: boolean;
36
+
37
+ /**
38
+ * If true, single newlines become <br> tags.
39
+ * Useful for chat/LLM applications where Enter should create a line break.
40
+ * @default false
41
+ */
42
+ lazy_linefeeds?: boolean;
33
43
  }
34
44
 
35
45
  /**
36
46
  * Parse markdown to HTML with bidirectional support
37
47
  * @param markdown - The markdown source text
38
48
  * @param options - Optional configuration
39
- * @returns The rendered HTML string with data-qd attributes for reverse conversion
49
+ * @returns The rendered HTML string with data-qd attributes
40
50
  */
41
- function quikdown_bd(markdown: string, options?: QuikdownBDOptions): string;
51
+ function quikdown_bd(markdown: string, options?: QuikdownBdOptions): string;
42
52
 
43
53
  namespace quikdown_bd {
44
54
  /**
45
55
  * Convert HTML back to Markdown
46
56
  * @param htmlOrElement - HTML string or DOM element to convert
47
- * @returns The reconstructed markdown string
57
+ * @param options - Options including fence plugin with reverse handler
58
+ * @returns The recovered markdown string
48
59
  */
49
- export function toMarkdown(htmlOrElement: string | HTMLElement): string;
50
-
60
+ export function toMarkdown(htmlOrElement: string | HTMLElement, options?: {
61
+ fence_plugin?: import('quikdown').FencePlugin;
62
+ }): string;
63
+
51
64
  /**
52
65
  * Generate CSS styles for quikdown classes with theme support
53
66
  * @param prefix - CSS class prefix (default: 'quikdown-')
@@ -61,7 +74,7 @@ declare module 'quikdown/bd' {
61
74
  * @param options - Configuration to apply to all parsing
62
75
  * @returns A parser function with the options pre-applied
63
76
  */
64
- export function configure(options: QuikdownBDOptions): (markdown: string) => string;
77
+ export function configure(options: QuikdownBdOptions): (markdown: string) => string;
65
78
 
66
79
  /**
67
80
  * The version of quikdown_bd (same as core quikdown)
@@ -72,9 +85,30 @@ declare module 'quikdown/bd' {
72
85
  export = quikdown_bd;
73
86
  }
74
87
 
75
- // For direct imports
76
- declare module 'quikdown_bd' {
77
- export * from 'quikdown/bd';
78
- import quikdown_bd from 'quikdown/bd';
79
- export default quikdown_bd;
80
- }
88
+ // For ES6 module imports
89
+ export default quikdown_bd;
90
+ export { QuikdownBdOptions };
91
+
92
+ /**
93
+ * Default export for direct import
94
+ */
95
+ declare function quikdown_bd(markdown: string, options?: QuikdownBdOptions): string;
96
+
97
+ declare namespace quikdown_bd {
98
+ export function toMarkdown(htmlOrElement: string | HTMLElement, options?: {
99
+ fence_plugin?: import('quikdown').FencePlugin;
100
+ }): string;
101
+ export function emitStyles(prefix?: string, theme?: 'light' | 'dark'): string;
102
+ export function configure(options: QuikdownBdOptions): (markdown: string) => string;
103
+ export const version: string;
104
+ }
105
+
106
+ export interface QuikdownBdOptions {
107
+ fence_plugin?: import('./quikdown').FencePlugin;
108
+ inline_styles?: boolean;
109
+ allow_unsafe_urls?: boolean;
110
+ bidirectional?: boolean;
111
+ lazy_linefeeds?: boolean;
112
+ }
113
+
114
+ export default quikdown_bd;