longdown 2026.2.1 → 2026.4.5

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 (130) hide show
  1. package/README.md +37 -0
  2. package/bin/cli.js +2 -2
  3. package/lib/longdown/cli.mjs +81 -0
  4. package/lib/longdown/lib.mjs +293 -0
  5. package/package.json +16 -5
  6. package/src/index.d.ts +27 -0
  7. package/src/index.mjs +7 -0
  8. package/lib/cli.js +0 -122
  9. package/lib/cljs-runtime/cljs.core.js +0 -38285
  10. package/lib/cljs-runtime/cljs.core.js.map +0 -1
  11. package/lib/cljs-runtime/cljs_env.js +0 -1268
  12. package/lib/cljs-runtime/clojure.string.js +0 -477
  13. package/lib/cljs-runtime/clojure.string.js.map +0 -1
  14. package/lib/cljs-runtime/clojure.tools.cli.js +0 -1684
  15. package/lib/cljs-runtime/clojure.tools.cli.js.map +0 -1
  16. package/lib/cljs-runtime/clojure.walk.js +0 -131
  17. package/lib/cljs-runtime/clojure.walk.js.map +0 -1
  18. package/lib/cljs-runtime/goog.array.array.js +0 -658
  19. package/lib/cljs-runtime/goog.array.array.js.map +0 -9
  20. package/lib/cljs-runtime/goog.asserts.asserts.js +0 -131
  21. package/lib/cljs-runtime/goog.asserts.asserts.js.map +0 -9
  22. package/lib/cljs-runtime/goog.asserts.dom.js +0 -87
  23. package/lib/cljs-runtime/goog.asserts.dom.js.map +0 -9
  24. package/lib/cljs-runtime/goog.base.js +0 -1242
  25. package/lib/cljs-runtime/goog.base.js.map +0 -9
  26. package/lib/cljs-runtime/goog.collections.maps.js +0 -79
  27. package/lib/cljs-runtime/goog.collections.maps.js.map +0 -9
  28. package/lib/cljs-runtime/goog.debug.error.js +0 -29
  29. package/lib/cljs-runtime/goog.debug.error.js.map +0 -9
  30. package/lib/cljs-runtime/goog.dom.asserts.js +0 -39
  31. package/lib/cljs-runtime/goog.dom.asserts.js.map +0 -9
  32. package/lib/cljs-runtime/goog.dom.element.js +0 -67
  33. package/lib/cljs-runtime/goog.dom.element.js.map +0 -9
  34. package/lib/cljs-runtime/goog.dom.htmlelement.js +0 -6
  35. package/lib/cljs-runtime/goog.dom.htmlelement.js.map +0 -9
  36. package/lib/cljs-runtime/goog.dom.nodetype.js +0 -5
  37. package/lib/cljs-runtime/goog.dom.nodetype.js.map +0 -9
  38. package/lib/cljs-runtime/goog.dom.safe.js +0 -265
  39. package/lib/cljs-runtime/goog.dom.safe.js.map +0 -9
  40. package/lib/cljs-runtime/goog.dom.tagname.js +0 -146
  41. package/lib/cljs-runtime/goog.dom.tagname.js.map +0 -9
  42. package/lib/cljs-runtime/goog.dom.tags.js +0 -9
  43. package/lib/cljs-runtime/goog.dom.tags.js.map +0 -9
  44. package/lib/cljs-runtime/goog.flags.flags.js +0 -11
  45. package/lib/cljs-runtime/goog.flags.flags.js.map +0 -9
  46. package/lib/cljs-runtime/goog.fs.blob.js +0 -37
  47. package/lib/cljs-runtime/goog.fs.blob.js.map +0 -9
  48. package/lib/cljs-runtime/goog.fs.url.js +0 -36
  49. package/lib/cljs-runtime/goog.fs.url.js.map +0 -9
  50. package/lib/cljs-runtime/goog.functions.functions.js +0 -210
  51. package/lib/cljs-runtime/goog.functions.functions.js.map +0 -9
  52. package/lib/cljs-runtime/goog.html.safehtml.js +0 -306
  53. package/lib/cljs-runtime/goog.html.safehtml.js.map +0 -9
  54. package/lib/cljs-runtime/goog.html.safescript.js +0 -61
  55. package/lib/cljs-runtime/goog.html.safescript.js.map +0 -9
  56. package/lib/cljs-runtime/goog.html.safestyle.js +0 -170
  57. package/lib/cljs-runtime/goog.html.safestyle.js.map +0 -9
  58. package/lib/cljs-runtime/goog.html.safestylesheet.js +0 -93
  59. package/lib/cljs-runtime/goog.html.safestylesheet.js.map +0 -9
  60. package/lib/cljs-runtime/goog.html.safeurl.js +0 -225
  61. package/lib/cljs-runtime/goog.html.safeurl.js.map +0 -9
  62. package/lib/cljs-runtime/goog.html.trustedresourceurl.js +0 -113
  63. package/lib/cljs-runtime/goog.html.trustedresourceurl.js.map +0 -9
  64. package/lib/cljs-runtime/goog.html.trustedtypes.js +0 -15
  65. package/lib/cljs-runtime/goog.html.trustedtypes.js.map +0 -9
  66. package/lib/cljs-runtime/goog.html.uncheckedconversions.js +0 -43
  67. package/lib/cljs-runtime/goog.html.uncheckedconversions.js.map +0 -9
  68. package/lib/cljs-runtime/goog.labs.useragent.browser.js +0 -332
  69. package/lib/cljs-runtime/goog.labs.useragent.browser.js.map +0 -9
  70. package/lib/cljs-runtime/goog.labs.useragent.highentropy.highentropydata.js +0 -13
  71. package/lib/cljs-runtime/goog.labs.useragent.highentropy.highentropydata.js.map +0 -9
  72. package/lib/cljs-runtime/goog.labs.useragent.highentropy.highentropyvalue.js +0 -72
  73. package/lib/cljs-runtime/goog.labs.useragent.highentropy.highentropyvalue.js.map +0 -9
  74. package/lib/cljs-runtime/goog.labs.useragent.useragent.js +0 -20
  75. package/lib/cljs-runtime/goog.labs.useragent.useragent.js.map +0 -9
  76. package/lib/cljs-runtime/goog.labs.useragent.util.js +0 -77
  77. package/lib/cljs-runtime/goog.labs.useragent.util.js.map +0 -9
  78. package/lib/cljs-runtime/goog.math.integer.js +0 -425
  79. package/lib/cljs-runtime/goog.math.integer.js.map +0 -9
  80. package/lib/cljs-runtime/goog.math.long.js +0 -427
  81. package/lib/cljs-runtime/goog.math.long.js.map +0 -9
  82. package/lib/cljs-runtime/goog.object.object.js +0 -283
  83. package/lib/cljs-runtime/goog.object.object.js.map +0 -9
  84. package/lib/cljs-runtime/goog.reflect.reflect.js +0 -31
  85. package/lib/cljs-runtime/goog.reflect.reflect.js.map +0 -9
  86. package/lib/cljs-runtime/goog.string.const.js +0 -33
  87. package/lib/cljs-runtime/goog.string.const.js.map +0 -9
  88. package/lib/cljs-runtime/goog.string.internal.js +0 -118
  89. package/lib/cljs-runtime/goog.string.internal.js.map +0 -9
  90. package/lib/cljs-runtime/goog.string.string.js +0 -458
  91. package/lib/cljs-runtime/goog.string.string.js.map +0 -9
  92. package/lib/cljs-runtime/goog.string.stringbuffer.js +0 -31
  93. package/lib/cljs-runtime/goog.string.stringbuffer.js.map +0 -9
  94. package/lib/cljs-runtime/goog.string.stringformat.js +0 -74
  95. package/lib/cljs-runtime/goog.string.stringformat.js.map +0 -9
  96. package/lib/cljs-runtime/goog.string.typedstring.js +0 -8
  97. package/lib/cljs-runtime/goog.string.typedstring.js.map +0 -9
  98. package/lib/cljs-runtime/goog.structs.structs.js +0 -188
  99. package/lib/cljs-runtime/goog.structs.structs.js.map +0 -9
  100. package/lib/cljs-runtime/goog.uri.uri.js +0 -616
  101. package/lib/cljs-runtime/goog.uri.uri.js.map +0 -9
  102. package/lib/cljs-runtime/goog.uri.utils.js +0 -320
  103. package/lib/cljs-runtime/goog.uri.utils.js.map +0 -9
  104. package/lib/cljs-runtime/longdown.cli.js +0 -144
  105. package/lib/cljs-runtime/longdown.cli.js.map +0 -1
  106. package/lib/cljs-runtime/longdown.lib.js +0 -229
  107. package/lib/cljs-runtime/longdown.lib.js.map +0 -1
  108. package/lib/cljs-runtime/shadow.esm.esm_import$mdast_util_from_markdown.js +0 -5
  109. package/lib/cljs-runtime/shadow.esm.esm_import$mdast_util_from_markdown.js.map +0 -9
  110. package/lib/cljs-runtime/shadow.esm.esm_import$mdast_util_to_markdown.js +0 -5
  111. package/lib/cljs-runtime/shadow.esm.esm_import$mdast_util_to_markdown.js.map +0 -9
  112. package/lib/cljs-runtime/shadow.esm.esm_import$node_fs.js +0 -5
  113. package/lib/cljs-runtime/shadow.esm.esm_import$node_fs.js.map +0 -9
  114. package/lib/cljs-runtime/shadow.esm.esm_import$node_path.js +0 -5
  115. package/lib/cljs-runtime/shadow.esm.esm_import$node_path.js.map +0 -9
  116. package/lib/cljs-runtime/shadow.esm.esm_import$rehype_parse.js +0 -5
  117. package/lib/cljs-runtime/shadow.esm.esm_import$rehype_parse.js.map +0 -9
  118. package/lib/cljs-runtime/shadow.esm.esm_import$rehype_remark.js +0 -5
  119. package/lib/cljs-runtime/shadow.esm.esm_import$rehype_remark.js.map +0 -9
  120. package/lib/cljs-runtime/shadow.esm.esm_import$remark_parse.js +0 -5
  121. package/lib/cljs-runtime/shadow.esm.esm_import$remark_parse.js.map +0 -9
  122. package/lib/cljs-runtime/shadow.esm.esm_import$remark_stringify.js +0 -5
  123. package/lib/cljs-runtime/shadow.esm.esm_import$remark_stringify.js.map +0 -9
  124. package/lib/cljs-runtime/shadow.esm.esm_import$unified.js +0 -5
  125. package/lib/cljs-runtime/shadow.esm.esm_import$unified.js.map +0 -9
  126. package/lib/cljs-runtime/shadow.module.cli.append.js +0 -1
  127. package/lib/cljs-runtime/shadow.module.cli.prepend.js +0 -19
  128. package/lib/cljs-runtime/shadow.module.lib.append.js +0 -1
  129. package/lib/cljs-runtime/shadow.module.lib.prepend.js +0 -2
  130. package/lib/lib.js +0 -8
package/README.md CHANGED
@@ -114,6 +114,43 @@ With `--strip-highlights`:
114
114
  - normal item
115
115
  ```
116
116
 
117
+ ## Library API
118
+
119
+ Longdown can also be used as a library, exposing unified plugins for composing custom pipelines.
120
+
121
+ ```js
122
+ import { unified } from 'unified'
123
+ import { remarkParseLongdown, remarkStratify, remarkStripHighlights } from 'longdown'
124
+
125
+ const processor = unified()
126
+ .use(remarkParseLongdown)
127
+ .use(remarkStratify)
128
+ .use(remarkStripHighlights)
129
+
130
+ const ast = processor.runSync(processor.parse(markdown))
131
+ ```
132
+
133
+ Available plugins:
134
+ - `remarkParseLongdown` — markdown parser with longdown-specific extensions
135
+ - `remarkStratify` — transforms flat MDAST into a nested list structure based on heading depth
136
+ - `remarkStripHighlights` — strips heading markers, leading numbers, and unwraps leading bold
137
+
138
+ Convenience functions for simple string conversion:
139
+
140
+ ```js
141
+ import { longformToOutline, htmlToOutline } from 'longdown'
142
+
143
+ longformToOutline('# Hello\n\nWorld')
144
+ // => '- # Hello\n - World\n'
145
+
146
+ htmlToOutline('<h1>Hello</h1><p>World</p>')
147
+ // => '- # Hello\n - World\n'
148
+
149
+ // Pass { stripHighlights: true } to strip heading markers and leading bold
150
+ longformToOutline('## 1. **Title**\n\nContent', { stripHighlights: true })
151
+ // => '- Title\n - Content\n'
152
+ ```
153
+
117
154
  ## License
118
155
 
119
156
  0BSD
package/bin/cli.js CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
- import { main } from "../lib/cli.js"
3
- main.apply(null, process.argv.slice(2))
2
+ import { _main } from "../lib/longdown/cli.mjs"
3
+ _main()
@@ -0,0 +1,81 @@
1
+ import * as squint_core from 'squint-cljs/core.js';
2
+ import * as fs from 'node:fs';
3
+ import * as path from 'node:path';
4
+ import { parseArgs } from 'node:util';
5
+ import * as str from 'squint-cljs/src/squint/string.js';
6
+ import * as lib from './lib.mjs';
7
+ var slurp = function (path) {
8
+ return fs.readFileSync(path, "utf-8");
9
+
10
+ };
11
+ var spit = function (path, output) {
12
+ return fs.writeFileSync(path, output);
13
+
14
+ };
15
+ var cli_options = ({"help": ({"type": "boolean", "short": "h"}), "out-dir": ({"type": "string", "short": "d"}), "html": ({"type": "boolean"}), "strip-highlights": ({"type": "boolean"})});
16
+ var usage_text = str.join("\n", ["Convert longform markdown files to outline format used by Logseq", "", "Usage: longdown [options] file.md...", " longdown -", "", "When file is -, reads standard input and prints to standard output.", "", "Options:", " -d, --out-dir DIR Output directory", " --html Read HTML input instead of markdown", " --strip-highlights Strip headers and leading bold formatting", " -h, --help Show this help"]);
17
+ var convert_files = function (out_dir, filenames, convert_fn) {
18
+ for (let G__1 of squint_core.iterable(filenames)) {
19
+ const in_path2 = G__1;
20
+ const out_path3 = path.join(out_dir, in_path2);
21
+ fs.mkdirSync(path.dirname(out_path3), ({"recursive": true}));
22
+ spit(out_path3, convert_fn(slurp(in_path2)))
23
+ }
24
+ return null;
25
+
26
+ };
27
+ var convert_from_stdin = function (convert_fn) {
28
+ return squint_core.println(convert_fn(slurp(process.stdin.fd)).replace(/\n+$/, ""));
29
+
30
+ };
31
+ var _main = (() => {
32
+ const f1 = (function (var_args) {
33
+ const args21 = [];
34
+ const len__23360__auto__2 = arguments.length;
35
+ let i33 = 0;
36
+ while(true){
37
+ if ((i33 < len__23360__auto__2)) {
38
+ args21.push((arguments[i33]));
39
+ let G__4 = (i33 + 1);
40
+ i33 = G__4;
41
+ continue;
42
+ };break;
43
+ }
44
+ ;
45
+ const argseq__23545__auto__5 = (((0 < args21.length)) ? (args21.slice(0)) : (null));
46
+ return f1.cljs$core$IFn$_invoke$arity$variadic(argseq__23545__auto__5);
47
+
48
+ });
49
+ f1.cljs$core$IFn$_invoke$arity$variadic = (function (_args) {
50
+ const parsed6 = parseArgs(({"options": cli_options, "allowPositionals": true, "args": process.argv.slice(2)}));
51
+ const opts7 = parsed6.values;
52
+ const arguments$8 = parsed6.positionals;
53
+ const html9 = opts7.html;
54
+ const strip_highlights10 = opts7.strip_highlights;
55
+ const out_dir11 = opts7["out-dir"];
56
+ const convert_fn12 = lib.make_converter(({"html": html9, "strip-highlights?": strip_highlights10}));
57
+ if (squint_core.truth_((() => {
58
+ const or__23522__auto__13 = opts7.help;
59
+ if (squint_core.truth_(or__23522__auto__13)) {
60
+ return or__23522__auto__13} else {
61
+ return squint_core.empty_QMARK_(arguments$8)};
62
+
63
+ })())) {
64
+ return squint_core.println(usage_text)} else {
65
+ if (squint_core.truth_(((squint_core.count(arguments$8) === 1) && (squint_core.first(arguments$8) === "-")))) {
66
+ return convert_from_stdin(convert_fn12)} else {
67
+ if ((out_dir11 == null)) {
68
+ squint_core.println("Output directory is required");
69
+ return process.exit(1);
70
+ } else {
71
+ if ("else") {
72
+ return convert_files(out_dir11, arguments$8, convert_fn12)} else {
73
+ return null}}}};
74
+
75
+ });
76
+ f1.cljs$lang$maxFixedArity = 0;
77
+ return f1;
78
+
79
+ })();
80
+
81
+ export { cli_options, usage_text, convert_files, convert_from_stdin, _main }
@@ -0,0 +1,293 @@
1
+ import * as squint_core from 'squint-cljs/core.js';
2
+ import { defaultHandlers } from 'mdast-util-to-markdown';
3
+ import rehype_parse from 'rehype-parse';
4
+ import rehype_remark from 'rehype-remark';
5
+ import remark_parse from 'remark-parse';
6
+ import remark_stringify from 'remark-stringify';
7
+ import { unified } from 'unified';
8
+ import * as str from 'squint-cljs/src/squint/string.js';
9
+ var stratify_nodes = function (p__5) {
10
+ const vec__14 = p__5;
11
+ const seq__25 = squint_core.seq(vec__14);
12
+ const first__36 = squint_core.first(seq__25);
13
+ const seq__27 = squint_core.next(seq__25);
14
+ const node8 = first__36;
15
+ const remaining9 = seq__27;
16
+ const G__610 = squint_core.get(node8, "type");
17
+ switch (G__610) {case "heading":
18
+ const map__1213 = node8;
19
+ const depth14 = squint_core.get(map__1213, "depth");
20
+ let nodes15 = remaining9;
21
+ let children16 = [];
22
+ while(true){
23
+ const child17 = squint_core.first(nodes15);
24
+ if (squint_core.truth_((() => {
25
+ const and__23554__auto__18 = child17;
26
+ if (squint_core.truth_(and__23554__auto__18)) {
27
+ const or__23522__auto__19 = !(squint_core.get(child17, "type") === "heading");
28
+ if (or__23522__auto__19) {
29
+ return or__23522__auto__19} else {
30
+ return (depth14 < squint_core.get(child17, "depth"))};
31
+ } else {
32
+ return and__23554__auto__18};
33
+
34
+ })())) {
35
+ const vec__2023 = stratify_nodes(nodes15);
36
+ const nodes24 = squint_core.nth(vec__2023, 0, null);
37
+ const child25 = squint_core.nth(vec__2023, 1, null);
38
+ let G__26 = nodes24;
39
+ let G__27 = squint_core.conj(children16, child25);
40
+ nodes15 = G__26;
41
+ children16 = G__27;
42
+ continue;
43
+ } else {
44
+ return [nodes15, ({"type": "listItem", "children": [node8, ({"type": "list", "children": children16})]})]};
45
+ ;break;
46
+ }
47
+ ;
48
+
49
+ break;
50
+ case "list":
51
+ return [remaining9, ({"type": "listItem", "children": [({"type": "paragraph", "children": [({"type": "text", "text": ""})]}), node8]})];
52
+
53
+ break;
54
+ default:
55
+ return [remaining9, ({"type": "listItem", "children": [node8]})]};
56
+
57
+ };
58
+ var stratify = function (node) {
59
+ if ((squint_core.get(node, "type") === "root")) {
60
+ } else {
61
+ throw (new Error("Assert failed: (= (:type node) \"root\")"))};
62
+ let nodes1 = squint_core.get(node, "children");
63
+ let children2 = [];
64
+ while(true){
65
+ if (squint_core.truth_(squint_core.seq(nodes1))) {
66
+ const vec__36 = stratify_nodes(nodes1);
67
+ const nodes7 = squint_core.nth(vec__36, 0, null);
68
+ const child8 = squint_core.nth(vec__36, 1, null);
69
+ let G__9 = nodes7;
70
+ let G__10 = squint_core.conj(children2, child8);
71
+ nodes1 = G__9;
72
+ children2 = G__10;
73
+ continue;
74
+ } else {
75
+ return squint_core.assoc(node, "children", [({"type": "list", "children": children2})])};
76
+ ;break;
77
+ }
78
+ ;
79
+
80
+ };
81
+ var strip_leading_number = function (text) {
82
+ return str.replace(text, /^\d+\.\s*/, "");
83
+
84
+ };
85
+ var heading__GT_paragraph = function (node) {
86
+ return squint_core.update(squint_core.dissoc(squint_core.assoc(node, "type", "paragraph"), "depth"), "children", (function (children) {
87
+ return squint_core.mapv((function (child) {
88
+ if ((squint_core.get(child, "type") === "text")) {
89
+ return squint_core.update(child, "value", strip_leading_number)} else {
90
+ return child};
91
+
92
+ }), children);
93
+
94
+ }));
95
+
96
+ };
97
+ var empty_text_node_QMARK_ = function (node) {
98
+ return ((squint_core.get(node, "type") === "text") && squint_core.empty_QMARK_(squint_core.get(node, "value")));
99
+
100
+ };
101
+ var unwrap_leading_strong = function (children) {
102
+ const non_empty1 = squint_core.drop_while(empty_text_node_QMARK_, children);
103
+ const temp__23064__auto__2 = squint_core.first(non_empty1);
104
+ if (squint_core.truth_(temp__23064__auto__2)) {
105
+ const first_child3 = temp__23064__auto__2;
106
+ if ((squint_core.get(first_child3, "type") === "strong")) {
107
+ return squint_core.concat(squint_core.get(first_child3, "children"), squint_core.rest(non_empty1))} else {
108
+ return children};
109
+ } else {
110
+ return children};
111
+
112
+ };
113
+ var strip_leading_bold_in_node = function (node) {
114
+ if (squint_core.truth_(squint_core.contains_QMARK_((new Set (["paragraph", "listItem"])), squint_core.get(node, "type")))) {
115
+ return squint_core.update(node, "children", squint_core.comp(squint_core.vec, unwrap_leading_strong))} else {
116
+ return node};
117
+
118
+ };
119
+ var strip_highlights = function (node) {
120
+ const transformed1 = (((squint_core.get(node, "type") === "heading")) ? (strip_leading_bold_in_node(heading__GT_paragraph(node))) : ((((squint_core.get(node, "type") === "paragraph")) ? (strip_leading_bold_in_node(node)) : ((("else") ? (node) : (null))))));
121
+ if (squint_core.truth_(squint_core.get(transformed1, "children"))) {
122
+ return squint_core.update(transformed1, "children", (function (_PERCENT_1) {
123
+ return squint_core.mapv(strip_highlights, _PERCENT_1);
124
+
125
+ }))} else {
126
+ return transformed1};
127
+
128
+ };
129
+ var remark_stratify = function () {
130
+ return function (tree, _file, cb) {
131
+ const next_tree1 = stratify(tree);
132
+ return cb(null, next_tree1);
133
+
134
+ };
135
+
136
+ };
137
+ var remark_strip_highlights = function () {
138
+ return function (tree, _file, cb) {
139
+ const next_tree1 = strip_highlights(tree);
140
+ return cb(null, next_tree1);
141
+
142
+ };
143
+
144
+ };
145
+ var onenterlineprefix = function (token) {
146
+ const this$1 = this;
147
+ const node2 = this$1.stack[(this$1.stack.length - 1)];
148
+ if ((node2.type === "paragraph")) {
149
+ return this$1.config.enter.data.call(this$1, token);
150
+ };
151
+
152
+ };
153
+ var onexitlineprefix = function (token) {
154
+ const this$1 = this;
155
+ const node2 = this$1.stack[(this$1.stack.length - 1)];
156
+ if ((node2.type === "text")) {
157
+ return this$1.config.exit.data.call(this$1, token);
158
+ };
159
+
160
+ };
161
+ var preserve_leading_whitespace_extension = ({"enter": ({"linePrefix": onenterlineprefix}), "exit": ({"linePrefix": onexitlineprefix})});
162
+ var remark_preserve_leading_whitespace = function () {
163
+ const this$1 = this;
164
+ this$1.data("fromMarkdownExtensions", [preserve_leading_whitespace_extension]);
165
+ return null;
166
+
167
+ };
168
+ var remark_parse_longdown = function () {
169
+ const this$1 = this;
170
+ this$1.use(remark_parse).use(remark_preserve_leading_whitespace);
171
+ return null;
172
+
173
+ };
174
+ var filter_unsafe = function (unsafe_arr) {
175
+ return unsafe_arr.filter((function (x) {
176
+ return (squint_core.not(((x.inConstruct === "phrasing") && (() => {
177
+ const or__23522__auto__1 = (x.character === " ");
178
+ if (or__23522__auto__1) {
179
+ return or__23522__auto__1} else {
180
+ return (x.character === "\t")};
181
+
182
+ })())) && (!(x.character === "_") && (!(x.character === "&") && (!(x.character === "[") && !(x.character === "]")))));
183
+
184
+ }));
185
+
186
+ };
187
+ var custom_paragraph = function (node, _, state, info) {
188
+ const orig_unsafe1 = state.unsafe;
189
+ const _2 = state.unsafe = filter_unsafe(orig_unsafe1);
190
+ const value3 = defaultHandlers.paragraph(node, _2, state, info);
191
+ const _4 = state.unsafe = orig_unsafe1;
192
+ return value3;
193
+
194
+ };
195
+ var stringify_options = ({"bullet": "-", "listItemIndent": "one", "fences": true, "join": [(function (_left, _right, _parent, _state) {
196
+ return 0;
197
+
198
+ })], "handlers": ({"paragraph": custom_paragraph})});
199
+ var markdown_parser = unified().use(remark_parse_longdown).use(remark_stratify).freeze();
200
+ var html_parser = unified().use(rehype_parse).use(rehype_remark).use(remark_stratify).freeze();
201
+ var markdown_stringifier = unified().use(remark_stringify, stringify_options).freeze();
202
+ var parse_markdown = function (input) {
203
+ return markdown_parser.runSync(markdown_parser.parse(input));
204
+
205
+ };
206
+ var parse_html = function (input) {
207
+ return html_parser.runSync(html_parser.parse(input));
208
+
209
+ };
210
+ var stringify_markdown = function (ast) {
211
+ return `${markdown_stringifier.stringify(ast)??''}`;
212
+
213
+ };
214
+ var convert = function (parse_fn, input, opts) {
215
+ const ast1 = parse_fn(input);
216
+ const ast2 = ((squint_core.truth_((() => {
217
+ const and__23554__auto__3 = opts;
218
+ if (squint_core.truth_(and__23554__auto__3)) {
219
+ return opts.stripHighlights} else {
220
+ return and__23554__auto__3};
221
+
222
+ })())) ? (strip_highlights(ast1)) : (ast1));
223
+ return stringify_markdown(ast2);
224
+
225
+ };
226
+ var longform__GT_outline = (() => {
227
+ const f7 = (function (...args8) {
228
+ const G__91 = args8.length;
229
+ switch (G__91) {case 1:
230
+ return f7.cljs$core$IFn$_invoke$arity$1(args8[0]);
231
+
232
+ break;
233
+ case 2:
234
+ return f7.cljs$core$IFn$_invoke$arity$2(args8[0], args8[1]);
235
+
236
+ break;
237
+ default:
238
+ throw (new Error(`${"Invalid arity: "}${args8.length??''}`))};
239
+
240
+ });
241
+ f7.cljs$core$IFn$_invoke$arity$1 = (function (input) {
242
+ return convert(parse_markdown, input, null);
243
+
244
+ });
245
+ f7.cljs$core$IFn$_invoke$arity$2 = (function (input, opts) {
246
+ return convert(parse_markdown, input, opts);
247
+
248
+ });
249
+ f7.cljs$lang$maxFixedArity = 2;
250
+ return f7;
251
+
252
+ })();
253
+ var html__GT_outline = (() => {
254
+ const f10 = (function (...args11) {
255
+ const G__121 = args11.length;
256
+ switch (G__121) {case 1:
257
+ return f10.cljs$core$IFn$_invoke$arity$1(args11[0]);
258
+
259
+ break;
260
+ case 2:
261
+ return f10.cljs$core$IFn$_invoke$arity$2(args11[0], args11[1]);
262
+
263
+ break;
264
+ default:
265
+ throw (new Error(`${"Invalid arity: "}${args11.length??''}`))};
266
+
267
+ });
268
+ f10.cljs$core$IFn$_invoke$arity$1 = (function (input) {
269
+ return convert(parse_html, input, null);
270
+
271
+ });
272
+ f10.cljs$core$IFn$_invoke$arity$2 = (function (input, opts) {
273
+ return convert(parse_html, input, opts);
274
+
275
+ });
276
+ f10.cljs$lang$maxFixedArity = 2;
277
+ return f10;
278
+
279
+ })();
280
+ var make_converter = function (p__13) {
281
+ const map__12 = p__13;
282
+ const html3 = squint_core.get(map__12, "html");
283
+ const strip_highlights_QMARK_4 = squint_core.get(map__12, "strip-highlights?");
284
+ const convert_fn5 = ((squint_core.truth_(html3)) ? (html__GT_outline) : (longform__GT_outline));
285
+ const opts6 = ((squint_core.truth_(strip_highlights_QMARK_4)) ? (({"stripHighlights": true})) : (null));
286
+ return function (input) {
287
+ return convert_fn5(input, opts6);
288
+
289
+ };
290
+
291
+ };
292
+
293
+ export { parse_html, custom_paragraph, stringify_markdown, parse_markdown, stringify_options, make_converter, longform__GT_outline, remark_stratify, remark_strip_highlights, remark_parse_longdown, stratify, strip_highlights, html__GT_outline }
package/package.json CHANGED
@@ -1,22 +1,33 @@
1
1
  {
2
2
  "name": "longdown",
3
- "version": "2026.02.01",
3
+ "version": "2026.04.05",
4
4
  "description": "Convert longform markdown files to outline format used by Logseq",
5
5
  "type": "module",
6
+ "types": "./src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./src/index.d.ts",
10
+ "default": "./src/index.mjs"
11
+ }
12
+ },
6
13
  "bin": {
7
14
  "longdown": "./bin/cli.js"
8
15
  },
9
16
  "files": [
17
+ "src/index.mjs",
18
+ "src/index.d.ts",
10
19
  "bin",
11
- "lib"
20
+ "lib",
21
+ "!lib/**/*_test.*"
12
22
  ],
13
- "devDependencies": {
23
+ "dependencies": {
24
+ "mdast-util-to-markdown": "^2.1.2",
14
25
  "rehype-parse": "^9.0.1",
15
26
  "rehype-remark": "^10.0.1",
16
27
  "remark-parse": "^11.0.0",
17
28
  "remark-stringify": "^11.0.0",
18
- "unified": "^11.0.0",
19
- "source-map-support": "^0.5.21"
29
+ "squint-cljs": "^0.10.186",
30
+ "unified": "^11.0.5"
20
31
  },
21
32
  "repository": {
22
33
  "type": "git",
package/src/index.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import type { Plugin } from "unified";
2
+ import type { Root } from "mdast";
3
+
4
+ export interface ConvertOptions {
5
+ stripHighlights?: boolean;
6
+ }
7
+
8
+ /** Remark plugin that parses markdown with longdown extensions (preserves leading whitespace). */
9
+ export declare const remarkParseLongdown: Plugin<[], string, Root>;
10
+
11
+ /** Remark plugin that transforms flat headings into a nested list structure. */
12
+ export declare const remarkStratify: Plugin<[], Root>;
13
+
14
+ /** Remark plugin that strips heading markers, leading numbers, and bold formatting. */
15
+ export declare const remarkStripHighlights: Plugin<[], Root>;
16
+
17
+ /** Convert longform markdown to outline format. */
18
+ export declare function longformToOutline(
19
+ input: string,
20
+ opts?: ConvertOptions
21
+ ): string;
22
+
23
+ /** Convert HTML to outline format. */
24
+ export declare function htmlToOutline(
25
+ input: string,
26
+ opts?: ConvertOptions
27
+ ): string;
package/src/index.mjs ADDED
@@ -0,0 +1,7 @@
1
+ export {
2
+ remark_parse_longdown as remarkParseLongdown,
3
+ remark_stratify as remarkStratify,
4
+ remark_strip_highlights as remarkStripHighlights,
5
+ longform__GT_outline as longformToOutline,
6
+ html__GT_outline as htmlToOutline,
7
+ } from '../lib/longdown/lib.mjs'
package/lib/cli.js DELETED
@@ -1,122 +0,0 @@
1
-
2
- import "./lib.js";
3
- import "./cljs-runtime/shadow.module.cli.prepend.js";
4
- SHADOW_ENV.setLoaded("shadow.module.cli.prepend.js");
5
- import "./cljs-runtime/goog.debug.error.js";
6
- SHADOW_ENV.setLoaded("goog.debug.error.js");
7
- import "./cljs-runtime/goog.dom.nodetype.js";
8
- SHADOW_ENV.setLoaded("goog.dom.nodetype.js");
9
- import "./cljs-runtime/goog.asserts.asserts.js";
10
- SHADOW_ENV.setLoaded("goog.asserts.asserts.js");
11
- import "./cljs-runtime/goog.reflect.reflect.js";
12
- SHADOW_ENV.setLoaded("goog.reflect.reflect.js");
13
- import "./cljs-runtime/goog.math.long.js";
14
- SHADOW_ENV.setLoaded("goog.math.long.js");
15
- import "./cljs-runtime/goog.math.integer.js";
16
- SHADOW_ENV.setLoaded("goog.math.integer.js");
17
- import "./cljs-runtime/goog.dom.htmlelement.js";
18
- SHADOW_ENV.setLoaded("goog.dom.htmlelement.js");
19
- import "./cljs-runtime/goog.dom.tagname.js";
20
- SHADOW_ENV.setLoaded("goog.dom.tagname.js");
21
- import "./cljs-runtime/goog.dom.element.js";
22
- SHADOW_ENV.setLoaded("goog.dom.element.js");
23
- import "./cljs-runtime/goog.asserts.dom.js";
24
- SHADOW_ENV.setLoaded("goog.asserts.dom.js");
25
- import "./cljs-runtime/goog.dom.asserts.js";
26
- SHADOW_ENV.setLoaded("goog.dom.asserts.js");
27
- import "./cljs-runtime/goog.functions.functions.js";
28
- SHADOW_ENV.setLoaded("goog.functions.functions.js");
29
- import "./cljs-runtime/goog.string.typedstring.js";
30
- SHADOW_ENV.setLoaded("goog.string.typedstring.js");
31
- import "./cljs-runtime/goog.string.const.js";
32
- SHADOW_ENV.setLoaded("goog.string.const.js");
33
- import "./cljs-runtime/goog.html.trustedtypes.js";
34
- SHADOW_ENV.setLoaded("goog.html.trustedtypes.js");
35
- import "./cljs-runtime/goog.html.safescript.js";
36
- SHADOW_ENV.setLoaded("goog.html.safescript.js");
37
- import "./cljs-runtime/goog.fs.url.js";
38
- SHADOW_ENV.setLoaded("goog.fs.url.js");
39
- import "./cljs-runtime/goog.fs.blob.js";
40
- SHADOW_ENV.setLoaded("goog.fs.blob.js");
41
- import "./cljs-runtime/goog.html.trustedresourceurl.js";
42
- SHADOW_ENV.setLoaded("goog.html.trustedresourceurl.js");
43
- import "./cljs-runtime/goog.string.internal.js";
44
- SHADOW_ENV.setLoaded("goog.string.internal.js");
45
- import "./cljs-runtime/goog.html.safeurl.js";
46
- SHADOW_ENV.setLoaded("goog.html.safeurl.js");
47
- import "./cljs-runtime/goog.html.safestyle.js";
48
- SHADOW_ENV.setLoaded("goog.html.safestyle.js");
49
- import "./cljs-runtime/goog.object.object.js";
50
- SHADOW_ENV.setLoaded("goog.object.object.js");
51
- import "./cljs-runtime/goog.html.safestylesheet.js";
52
- SHADOW_ENV.setLoaded("goog.html.safestylesheet.js");
53
- import "./cljs-runtime/goog.flags.flags.js";
54
- SHADOW_ENV.setLoaded("goog.flags.flags.js");
55
- import "./cljs-runtime/goog.labs.useragent.useragent.js";
56
- SHADOW_ENV.setLoaded("goog.labs.useragent.useragent.js");
57
- import "./cljs-runtime/goog.labs.useragent.util.js";
58
- SHADOW_ENV.setLoaded("goog.labs.useragent.util.js");
59
- import "./cljs-runtime/goog.labs.useragent.highentropy.highentropyvalue.js";
60
- SHADOW_ENV.setLoaded("goog.labs.useragent.highentropy.highentropyvalue.js");
61
- import "./cljs-runtime/goog.labs.useragent.highentropy.highentropydata.js";
62
- SHADOW_ENV.setLoaded("goog.labs.useragent.highentropy.highentropydata.js");
63
- import "./cljs-runtime/goog.labs.useragent.browser.js";
64
- SHADOW_ENV.setLoaded("goog.labs.useragent.browser.js");
65
- import "./cljs-runtime/goog.array.array.js";
66
- SHADOW_ENV.setLoaded("goog.array.array.js");
67
- import "./cljs-runtime/goog.dom.tags.js";
68
- SHADOW_ENV.setLoaded("goog.dom.tags.js");
69
- import "./cljs-runtime/goog.html.safehtml.js";
70
- SHADOW_ENV.setLoaded("goog.html.safehtml.js");
71
- import "./cljs-runtime/goog.html.uncheckedconversions.js";
72
- SHADOW_ENV.setLoaded("goog.html.uncheckedconversions.js");
73
- import "./cljs-runtime/goog.dom.safe.js";
74
- SHADOW_ENV.setLoaded("goog.dom.safe.js");
75
- import "./cljs-runtime/goog.string.string.js";
76
- SHADOW_ENV.setLoaded("goog.string.string.js");
77
- import "./cljs-runtime/goog.collections.maps.js";
78
- SHADOW_ENV.setLoaded("goog.collections.maps.js");
79
- import "./cljs-runtime/goog.structs.structs.js";
80
- SHADOW_ENV.setLoaded("goog.structs.structs.js");
81
- import "./cljs-runtime/goog.uri.utils.js";
82
- SHADOW_ENV.setLoaded("goog.uri.utils.js");
83
- import "./cljs-runtime/goog.uri.uri.js";
84
- SHADOW_ENV.setLoaded("goog.uri.uri.js");
85
- import "./cljs-runtime/goog.string.stringbuffer.js";
86
- SHADOW_ENV.setLoaded("goog.string.stringbuffer.js");
87
- import "./cljs-runtime/cljs.core.js";
88
- SHADOW_ENV.setLoaded("cljs.core.js");
89
- import "./cljs-runtime/shadow.esm.esm_import$node_fs.js";
90
- SHADOW_ENV.setLoaded("shadow.esm.esm_import$node_fs.js");
91
- import "./cljs-runtime/shadow.esm.esm_import$node_path.js";
92
- SHADOW_ENV.setLoaded("shadow.esm.esm_import$node_path.js");
93
- import "./cljs-runtime/clojure.string.js";
94
- SHADOW_ENV.setLoaded("clojure.string.js");
95
- import "./cljs-runtime/goog.string.stringformat.js";
96
- SHADOW_ENV.setLoaded("goog.string.stringformat.js");
97
- import "./cljs-runtime/clojure.tools.cli.js";
98
- SHADOW_ENV.setLoaded("clojure.tools.cli.js");
99
- import "./cljs-runtime/shadow.esm.esm_import$mdast_util_from_markdown.js";
100
- SHADOW_ENV.setLoaded("shadow.esm.esm_import$mdast_util_from_markdown.js");
101
- import "./cljs-runtime/shadow.esm.esm_import$mdast_util_to_markdown.js";
102
- SHADOW_ENV.setLoaded("shadow.esm.esm_import$mdast_util_to_markdown.js");
103
- import "./cljs-runtime/shadow.esm.esm_import$rehype_parse.js";
104
- SHADOW_ENV.setLoaded("shadow.esm.esm_import$rehype_parse.js");
105
- import "./cljs-runtime/shadow.esm.esm_import$rehype_remark.js";
106
- SHADOW_ENV.setLoaded("shadow.esm.esm_import$rehype_remark.js");
107
- import "./cljs-runtime/shadow.esm.esm_import$remark_parse.js";
108
- SHADOW_ENV.setLoaded("shadow.esm.esm_import$remark_parse.js");
109
- import "./cljs-runtime/shadow.esm.esm_import$remark_stringify.js";
110
- SHADOW_ENV.setLoaded("shadow.esm.esm_import$remark_stringify.js");
111
- import "./cljs-runtime/shadow.esm.esm_import$unified.js";
112
- SHADOW_ENV.setLoaded("shadow.esm.esm_import$unified.js");
113
- import "./cljs-runtime/clojure.walk.js";
114
- SHADOW_ENV.setLoaded("clojure.walk.js");
115
- import "./cljs-runtime/longdown.lib.js";
116
- SHADOW_ENV.setLoaded("longdown.lib.js");
117
- import "./cljs-runtime/longdown.cli.js";
118
- SHADOW_ENV.setLoaded("longdown.cli.js");
119
- import "./cljs-runtime/shadow.module.cli.append.js";
120
- SHADOW_ENV.setLoaded("shadow.module.cli.append.js");
121
- export let main = longdown.cli._main;
122
-