docrev 0.8.1 → 0.8.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 (306) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/PLAN-tables-and-postprocess.md +850 -0
  3. package/README.md +33 -0
  4. package/bin/rev.js +12 -131
  5. package/bin/rev.ts +145 -0
  6. package/dist/bin/rev.d.ts +9 -0
  7. package/dist/bin/rev.d.ts.map +1 -0
  8. package/dist/bin/rev.js +118 -0
  9. package/dist/bin/rev.js.map +1 -0
  10. package/dist/lib/annotations.d.ts +91 -0
  11. package/dist/lib/annotations.d.ts.map +1 -0
  12. package/dist/lib/annotations.js +554 -0
  13. package/dist/lib/annotations.js.map +1 -0
  14. package/dist/lib/build.d.ts +171 -0
  15. package/dist/lib/build.d.ts.map +1 -0
  16. package/dist/lib/build.js +755 -0
  17. package/dist/lib/build.js.map +1 -0
  18. package/dist/lib/citations.d.ts +34 -0
  19. package/dist/lib/citations.d.ts.map +1 -0
  20. package/dist/lib/citations.js +140 -0
  21. package/dist/lib/citations.js.map +1 -0
  22. package/dist/lib/commands/build.d.ts +13 -0
  23. package/dist/lib/commands/build.d.ts.map +1 -0
  24. package/dist/lib/commands/build.js +678 -0
  25. package/dist/lib/commands/build.js.map +1 -0
  26. package/dist/lib/commands/citations.d.ts +11 -0
  27. package/dist/lib/commands/citations.d.ts.map +1 -0
  28. package/dist/lib/commands/citations.js +428 -0
  29. package/dist/lib/commands/citations.js.map +1 -0
  30. package/dist/lib/commands/comments.d.ts +11 -0
  31. package/dist/lib/commands/comments.d.ts.map +1 -0
  32. package/dist/lib/commands/comments.js +883 -0
  33. package/dist/lib/commands/comments.js.map +1 -0
  34. package/dist/lib/commands/context.d.ts +35 -0
  35. package/dist/lib/commands/context.d.ts.map +1 -0
  36. package/dist/lib/commands/context.js +59 -0
  37. package/dist/lib/commands/context.js.map +1 -0
  38. package/dist/lib/commands/core.d.ts +11 -0
  39. package/dist/lib/commands/core.d.ts.map +1 -0
  40. package/dist/lib/commands/core.js +246 -0
  41. package/dist/lib/commands/core.js.map +1 -0
  42. package/dist/lib/commands/doi.d.ts +11 -0
  43. package/dist/lib/commands/doi.d.ts.map +1 -0
  44. package/dist/lib/commands/doi.js +373 -0
  45. package/dist/lib/commands/doi.js.map +1 -0
  46. package/dist/lib/commands/history.d.ts +11 -0
  47. package/dist/lib/commands/history.d.ts.map +1 -0
  48. package/dist/lib/commands/history.js +245 -0
  49. package/dist/lib/commands/history.js.map +1 -0
  50. package/dist/lib/commands/index.d.ts +28 -0
  51. package/dist/lib/commands/index.d.ts.map +1 -0
  52. package/dist/lib/commands/index.js +35 -0
  53. package/dist/lib/commands/index.js.map +1 -0
  54. package/dist/lib/commands/init.d.ts +11 -0
  55. package/dist/lib/commands/init.d.ts.map +1 -0
  56. package/dist/lib/commands/init.js +209 -0
  57. package/dist/lib/commands/init.js.map +1 -0
  58. package/dist/lib/commands/response.d.ts +11 -0
  59. package/dist/lib/commands/response.d.ts.map +1 -0
  60. package/dist/lib/commands/response.js +317 -0
  61. package/dist/lib/commands/response.js.map +1 -0
  62. package/dist/lib/commands/sections.d.ts +11 -0
  63. package/dist/lib/commands/sections.d.ts.map +1 -0
  64. package/dist/lib/commands/sections.js +1071 -0
  65. package/dist/lib/commands/sections.js.map +1 -0
  66. package/dist/lib/commands/utilities.d.ts +19 -0
  67. package/dist/lib/commands/utilities.d.ts.map +1 -0
  68. package/dist/lib/commands/utilities.js +2009 -0
  69. package/dist/lib/commands/utilities.js.map +1 -0
  70. package/dist/lib/comment-realign.d.ts +50 -0
  71. package/dist/lib/comment-realign.d.ts.map +1 -0
  72. package/dist/lib/comment-realign.js +372 -0
  73. package/dist/lib/comment-realign.js.map +1 -0
  74. package/dist/lib/config.d.ts +41 -0
  75. package/dist/lib/config.d.ts.map +1 -0
  76. package/dist/lib/config.js +76 -0
  77. package/dist/lib/config.js.map +1 -0
  78. package/dist/lib/crossref.d.ts +108 -0
  79. package/dist/lib/crossref.d.ts.map +1 -0
  80. package/dist/lib/crossref.js +597 -0
  81. package/dist/lib/crossref.js.map +1 -0
  82. package/dist/lib/dependencies.d.ts +30 -0
  83. package/dist/lib/dependencies.d.ts.map +1 -0
  84. package/dist/lib/dependencies.js +95 -0
  85. package/dist/lib/dependencies.js.map +1 -0
  86. package/dist/lib/doi-cache.d.ts +29 -0
  87. package/dist/lib/doi-cache.d.ts.map +1 -0
  88. package/dist/lib/doi-cache.js +104 -0
  89. package/dist/lib/doi-cache.js.map +1 -0
  90. package/dist/lib/doi.d.ts +65 -0
  91. package/dist/lib/doi.d.ts.map +1 -0
  92. package/dist/lib/doi.js +710 -0
  93. package/dist/lib/doi.js.map +1 -0
  94. package/dist/lib/equations.d.ts +61 -0
  95. package/dist/lib/equations.d.ts.map +1 -0
  96. package/dist/lib/equations.js +445 -0
  97. package/dist/lib/equations.js.map +1 -0
  98. package/dist/lib/errors.d.ts +60 -0
  99. package/dist/lib/errors.d.ts.map +1 -0
  100. package/dist/lib/errors.js +303 -0
  101. package/dist/lib/errors.js.map +1 -0
  102. package/dist/lib/format.d.ts +104 -0
  103. package/dist/lib/format.d.ts.map +1 -0
  104. package/dist/lib/format.js +416 -0
  105. package/dist/lib/format.js.map +1 -0
  106. package/dist/lib/git.d.ts +88 -0
  107. package/dist/lib/git.d.ts.map +1 -0
  108. package/dist/lib/git.js +304 -0
  109. package/dist/lib/git.js.map +1 -0
  110. package/dist/lib/grammar.d.ts +62 -0
  111. package/dist/lib/grammar.d.ts.map +1 -0
  112. package/dist/lib/grammar.js +244 -0
  113. package/dist/lib/grammar.js.map +1 -0
  114. package/dist/lib/image-registry.d.ts +68 -0
  115. package/dist/lib/image-registry.d.ts.map +1 -0
  116. package/dist/lib/image-registry.js +112 -0
  117. package/dist/lib/image-registry.js.map +1 -0
  118. package/dist/lib/import.d.ts +184 -0
  119. package/dist/lib/import.d.ts.map +1 -0
  120. package/dist/lib/import.js +1581 -0
  121. package/dist/lib/import.js.map +1 -0
  122. package/dist/lib/journals.d.ts +55 -0
  123. package/dist/lib/journals.d.ts.map +1 -0
  124. package/dist/lib/journals.js +417 -0
  125. package/dist/lib/journals.js.map +1 -0
  126. package/dist/lib/merge.d.ts +138 -0
  127. package/dist/lib/merge.d.ts.map +1 -0
  128. package/dist/lib/merge.js +603 -0
  129. package/dist/lib/merge.js.map +1 -0
  130. package/dist/lib/orcid.d.ts +36 -0
  131. package/dist/lib/orcid.d.ts.map +1 -0
  132. package/dist/lib/orcid.js +117 -0
  133. package/dist/lib/orcid.js.map +1 -0
  134. package/dist/lib/pdf-comments.d.ts +95 -0
  135. package/dist/lib/pdf-comments.d.ts.map +1 -0
  136. package/dist/lib/pdf-comments.js +192 -0
  137. package/dist/lib/pdf-comments.js.map +1 -0
  138. package/dist/lib/pdf-import.d.ts +118 -0
  139. package/dist/lib/pdf-import.d.ts.map +1 -0
  140. package/dist/lib/pdf-import.js +397 -0
  141. package/dist/lib/pdf-import.js.map +1 -0
  142. package/dist/lib/plugins.d.ts +76 -0
  143. package/dist/lib/plugins.d.ts.map +1 -0
  144. package/dist/lib/plugins.js +235 -0
  145. package/dist/lib/plugins.js.map +1 -0
  146. package/dist/lib/postprocess.d.ts +42 -0
  147. package/dist/lib/postprocess.d.ts.map +1 -0
  148. package/dist/lib/postprocess.js +138 -0
  149. package/dist/lib/postprocess.js.map +1 -0
  150. package/dist/lib/pptx-template.d.ts +59 -0
  151. package/dist/lib/pptx-template.d.ts.map +1 -0
  152. package/dist/lib/pptx-template.js +613 -0
  153. package/dist/lib/pptx-template.js.map +1 -0
  154. package/dist/lib/pptx-themes.d.ts +80 -0
  155. package/dist/lib/pptx-themes.d.ts.map +1 -0
  156. package/dist/lib/pptx-themes.js +818 -0
  157. package/dist/lib/pptx-themes.js.map +1 -0
  158. package/dist/lib/protect-restore.d.ts +137 -0
  159. package/dist/lib/protect-restore.d.ts.map +1 -0
  160. package/dist/lib/protect-restore.js +394 -0
  161. package/dist/lib/protect-restore.js.map +1 -0
  162. package/dist/lib/rate-limiter.d.ts +27 -0
  163. package/dist/lib/rate-limiter.d.ts.map +1 -0
  164. package/dist/lib/rate-limiter.js +79 -0
  165. package/dist/lib/rate-limiter.js.map +1 -0
  166. package/dist/lib/response.d.ts +41 -0
  167. package/dist/lib/response.d.ts.map +1 -0
  168. package/dist/lib/response.js +150 -0
  169. package/dist/lib/response.js.map +1 -0
  170. package/dist/lib/review.d.ts +35 -0
  171. package/dist/lib/review.d.ts.map +1 -0
  172. package/dist/lib/review.js +263 -0
  173. package/dist/lib/review.js.map +1 -0
  174. package/dist/lib/schema.d.ts +66 -0
  175. package/dist/lib/schema.d.ts.map +1 -0
  176. package/dist/lib/schema.js +339 -0
  177. package/dist/lib/schema.js.map +1 -0
  178. package/dist/lib/scientific-words.d.ts +6 -0
  179. package/dist/lib/scientific-words.d.ts.map +1 -0
  180. package/dist/lib/scientific-words.js +66 -0
  181. package/dist/lib/scientific-words.js.map +1 -0
  182. package/dist/lib/sections.d.ts +40 -0
  183. package/dist/lib/sections.d.ts.map +1 -0
  184. package/dist/lib/sections.js +288 -0
  185. package/dist/lib/sections.js.map +1 -0
  186. package/dist/lib/slides.d.ts +86 -0
  187. package/dist/lib/slides.d.ts.map +1 -0
  188. package/dist/lib/slides.js +676 -0
  189. package/dist/lib/slides.js.map +1 -0
  190. package/dist/lib/spelling.d.ts +76 -0
  191. package/dist/lib/spelling.d.ts.map +1 -0
  192. package/dist/lib/spelling.js +272 -0
  193. package/dist/lib/spelling.js.map +1 -0
  194. package/dist/lib/templates.d.ts +30 -0
  195. package/dist/lib/templates.d.ts.map +1 -0
  196. package/dist/lib/templates.js +504 -0
  197. package/dist/lib/templates.js.map +1 -0
  198. package/dist/lib/themes.d.ts +85 -0
  199. package/dist/lib/themes.d.ts.map +1 -0
  200. package/dist/lib/themes.js +652 -0
  201. package/dist/lib/themes.js.map +1 -0
  202. package/dist/lib/trackchanges.d.ts +51 -0
  203. package/dist/lib/trackchanges.d.ts.map +1 -0
  204. package/dist/lib/trackchanges.js +202 -0
  205. package/dist/lib/trackchanges.js.map +1 -0
  206. package/dist/lib/tui.d.ts +76 -0
  207. package/dist/lib/tui.d.ts.map +1 -0
  208. package/dist/lib/tui.js +377 -0
  209. package/dist/lib/tui.js.map +1 -0
  210. package/dist/lib/types.d.ts +447 -0
  211. package/dist/lib/types.d.ts.map +1 -0
  212. package/dist/lib/types.js +6 -0
  213. package/dist/lib/types.js.map +1 -0
  214. package/dist/lib/undo.d.ts +57 -0
  215. package/dist/lib/undo.d.ts.map +1 -0
  216. package/dist/lib/undo.js +185 -0
  217. package/dist/lib/undo.js.map +1 -0
  218. package/dist/lib/utils.d.ts +16 -0
  219. package/dist/lib/utils.d.ts.map +1 -0
  220. package/dist/lib/utils.js +40 -0
  221. package/dist/lib/utils.js.map +1 -0
  222. package/dist/lib/variables.d.ts +42 -0
  223. package/dist/lib/variables.d.ts.map +1 -0
  224. package/dist/lib/variables.js +141 -0
  225. package/dist/lib/variables.js.map +1 -0
  226. package/dist/lib/word.d.ts +80 -0
  227. package/dist/lib/word.d.ts.map +1 -0
  228. package/dist/lib/word.js +360 -0
  229. package/dist/lib/word.js.map +1 -0
  230. package/dist/lib/wordcomments.d.ts +51 -0
  231. package/dist/lib/wordcomments.d.ts.map +1 -0
  232. package/dist/lib/wordcomments.js +587 -0
  233. package/dist/lib/wordcomments.js.map +1 -0
  234. package/eslint.config.js +27 -0
  235. package/lib/annotations.ts +622 -0
  236. package/lib/apply-buildup-colors.py +88 -0
  237. package/lib/build.ts +1013 -0
  238. package/lib/{citations.js → citations.ts} +38 -27
  239. package/lib/commands/{build.js → build.ts} +80 -27
  240. package/lib/commands/{citations.js → citations.ts} +36 -18
  241. package/lib/commands/{comments.js → comments.ts} +187 -54
  242. package/lib/commands/{context.js → context.ts} +18 -8
  243. package/lib/commands/{core.js → core.ts} +34 -20
  244. package/lib/commands/{doi.js → doi.ts} +32 -16
  245. package/lib/commands/{history.js → history.ts} +25 -12
  246. package/lib/commands/{index.js → index.ts} +9 -5
  247. package/lib/commands/{init.js → init.ts} +20 -8
  248. package/lib/commands/{response.js → response.ts} +47 -20
  249. package/lib/commands/{sections.js → sections.ts} +273 -68
  250. package/lib/commands/{utilities.js → utilities.ts} +338 -158
  251. package/lib/{comment-realign.js → comment-realign.ts} +117 -45
  252. package/lib/config.ts +84 -0
  253. package/lib/{crossref.js → crossref.ts} +213 -138
  254. package/lib/dependencies.ts +106 -0
  255. package/lib/doi-cache.ts +115 -0
  256. package/lib/{doi.js → doi.ts} +115 -281
  257. package/lib/{equations.js → equations.ts} +60 -64
  258. package/lib/{errors.js → errors.ts} +56 -48
  259. package/lib/{format.js → format.ts} +137 -63
  260. package/lib/{git.js → git.ts} +66 -63
  261. package/lib/{grammar.js → grammar.ts} +45 -32
  262. package/lib/image-registry.ts +180 -0
  263. package/lib/import.ts +2060 -0
  264. package/lib/journals.ts +505 -0
  265. package/lib/{merge.js → merge.ts} +185 -135
  266. package/lib/{orcid.js → orcid.ts} +17 -22
  267. package/lib/{pdf-comments.js → pdf-comments.ts} +76 -18
  268. package/lib/{pdf-import.js → pdf-import.ts} +148 -70
  269. package/lib/{plugins.js → plugins.ts} +82 -39
  270. package/lib/postprocess.ts +188 -0
  271. package/lib/pptx-color-filter.lua +37 -0
  272. package/lib/pptx-template.ts +625 -0
  273. package/lib/pptx-themes/academic.pptx +0 -0
  274. package/lib/pptx-themes/corporate.pptx +0 -0
  275. package/lib/pptx-themes/dark.pptx +0 -0
  276. package/lib/pptx-themes/default.pptx +0 -0
  277. package/lib/pptx-themes/minimal.pptx +0 -0
  278. package/lib/pptx-themes/plant.pptx +0 -0
  279. package/lib/pptx-themes.ts +896 -0
  280. package/lib/protect-restore.ts +516 -0
  281. package/lib/rate-limiter.ts +94 -0
  282. package/lib/{response.js → response.ts} +36 -21
  283. package/lib/{review.js → review.ts} +53 -43
  284. package/lib/{schema.js → schema.ts} +70 -25
  285. package/lib/{sections.js → sections.ts} +71 -76
  286. package/lib/slides.ts +793 -0
  287. package/lib/{spelling.js → spelling.ts} +43 -59
  288. package/lib/{templates.js → templates.ts} +20 -17
  289. package/lib/themes.ts +742 -0
  290. package/lib/{trackchanges.js → trackchanges.ts} +52 -23
  291. package/lib/types.ts +509 -0
  292. package/lib/{undo.js → undo.ts} +75 -52
  293. package/lib/utils.ts +41 -0
  294. package/lib/{variables.js → variables.ts} +60 -54
  295. package/lib/word.ts +428 -0
  296. package/lib/{wordcomments.js → wordcomments.ts} +94 -40
  297. package/package.json +15 -5
  298. package/skill/REFERENCE.md +67 -0
  299. package/tsconfig.json +26 -0
  300. package/lib/annotations.js +0 -414
  301. package/lib/build.js +0 -639
  302. package/lib/config.js +0 -79
  303. package/lib/import.js +0 -1145
  304. package/lib/journals.js +0 -629
  305. package/lib/word.js +0 -225
  306. /package/lib/{scientific-words.js → scientific-words.ts} +0 -0
@@ -0,0 +1,676 @@
1
+ /**
2
+ * Slide processing for Beamer and PPTX output
3
+ *
4
+ * Handles:
5
+ * - ::: step blocks for incremental reveals
6
+ * - ::: buildup blocks for progressive bullet reveals with greying
7
+ * - ::: notes blocks for speaker notes
8
+ * - Slide boundaries (---)
9
+ * - Slide styles: {.dark}, {.light}, {.accent}, {.inverse}
10
+ * - Special slides: {.cover}, {.thanks}, {.section}, {.plain}
11
+ *
12
+ * Syntax examples:
13
+ * ## Title {.dark} - Dark background slide
14
+ * ## Welcome {.cover} - Cover slide (no numbering, centered)
15
+ * ## Thank You {.thanks} - Thanks slide (no numbering)
16
+ * # Part 1 {.section} - Section divider slide
17
+ * ## Image {.plain} - No header/footer, full content
18
+ * ## Highlight {.accent .nonumber} - Accent color, no slide number
19
+ *
20
+ * Buildup syntax:
21
+ * ::: buildup
22
+ * - First point
23
+ * - Sub A
24
+ * - Sub B
25
+ * - Second point
26
+ * :::
27
+ *
28
+ * Generates slides where current point is colored, previous are greyed out.
29
+ * Subpoints appear sequentially within their parent.
30
+ */
31
+ /**
32
+ * Grey color for "completed" buildup items
33
+ */
34
+ const GREY_COLOR = '#888888';
35
+ /**
36
+ * Background styles mapped to Beamer options
37
+ */
38
+ const BEAMER_BACKGROUNDS = {
39
+ dark: '\\setbeamercolor{background canvas}{bg=black}\\setbeamercolor{normal text}{fg=white}\\usebeamercolor[fg]{normal text}',
40
+ light: '\\setbeamercolor{background canvas}{bg=white}\\setbeamercolor{normal text}{fg=black}\\usebeamercolor[fg]{normal text}',
41
+ accent: '\\setbeamercolor{background canvas}{bg=structure.fg}\\setbeamercolor{normal text}{fg=white}\\usebeamercolor[fg]{normal text}',
42
+ inverse: '\\setbeamercolor{background canvas}{bg=structure.fg!90!black}\\setbeamercolor{normal text}{fg=white}\\usebeamercolor[fg]{normal text}',
43
+ };
44
+ /**
45
+ * Special slide types mapped to Beamer frame options
46
+ */
47
+ const BEAMER_FRAME_OPTIONS = {
48
+ cover: 'plain,noframenumbering,c',
49
+ thanks: 'plain,noframenumbering,c',
50
+ section: 'plain,noframenumbering,c',
51
+ plain: 'plain',
52
+ };
53
+ /**
54
+ * Parse a bullet list into a tree structure
55
+ */
56
+ function parseBulletList(content) {
57
+ const lines = content.split('\n');
58
+ const items = [];
59
+ const stack = [{ children: items, indent: -1 }];
60
+ for (const line of lines) {
61
+ // Match bullet lines: "- text" or " - text" etc.
62
+ const match = line.match(/^(\s*)[-*]\s+(.+)$/);
63
+ if (!match)
64
+ continue;
65
+ const indent = (match[1] || '').length;
66
+ const text = (match[2] || '').trim();
67
+ const item = { text, indent, children: [] };
68
+ // Find parent based on indentation
69
+ while (stack.length > 1) {
70
+ const top = stack[stack.length - 1];
71
+ if (!top || top.indent < indent)
72
+ break;
73
+ stack.pop();
74
+ }
75
+ const parent = stack[stack.length - 1];
76
+ if (parent) {
77
+ parent.children.push(item);
78
+ }
79
+ stack.push(item);
80
+ }
81
+ return items;
82
+ }
83
+ /**
84
+ * Flatten bullet tree into sequential reveal steps
85
+ * Each step is: { itemIndex, subIndex, isSubItem }
86
+ */
87
+ function flattenBuildupSteps(items) {
88
+ const steps = [];
89
+ for (let i = 0; i < items.length; i++) {
90
+ const item = items[i];
91
+ if (!item)
92
+ continue;
93
+ if (item.children.length === 0) {
94
+ // No children - single step for this item
95
+ steps.push({ itemIndex: i, subIndex: null });
96
+ }
97
+ else {
98
+ // Has children - first show parent, then each child
99
+ steps.push({ itemIndex: i, subIndex: -1 }); // Parent only
100
+ for (let j = 0; j < item.children.length; j++) {
101
+ steps.push({ itemIndex: i, subIndex: j });
102
+ }
103
+ }
104
+ }
105
+ return steps;
106
+ }
107
+ /**
108
+ * Render a bullet item with optional color
109
+ */
110
+ function renderBulletItem(item, color, indentLevel = 0, showChildrenUpTo = null) {
111
+ const indent = ' '.repeat(indentLevel);
112
+ const lines = [];
113
+ // Render the main item
114
+ const text = color ? `[${item.text}]{color=${color}}` : item.text;
115
+ lines.push(`${indent}- ${text}`);
116
+ // Render children if any should be shown
117
+ if (showChildrenUpTo !== null && showChildrenUpTo >= 0 && item.children) {
118
+ for (let i = 0; i <= showChildrenUpTo && i < item.children.length; i++) {
119
+ const child = item.children[i];
120
+ if (!child)
121
+ continue;
122
+ const childColor = color; // Children inherit parent's color state
123
+ const childText = childColor ? `[${child.text}]{color=${childColor}}` : child.text;
124
+ lines.push(`${indent} - ${childText}`);
125
+ }
126
+ }
127
+ return lines.join('\n');
128
+ }
129
+ /**
130
+ * Generate buildup slides from a bullet list
131
+ */
132
+ function expandBuildup(content, format) {
133
+ const items = parseBulletList(content);
134
+ if (items.length === 0)
135
+ return [content];
136
+ const steps = flattenBuildupSteps(items);
137
+ const slideContents = [];
138
+ for (const step of steps) {
139
+ const lines = [];
140
+ for (let i = 0; i < items.length; i++) {
141
+ const item = items[i];
142
+ if (!item)
143
+ continue;
144
+ if (i < step.itemIndex) {
145
+ // Previous top-level item - greyed out with all children
146
+ const allChildrenIndex = item.children.length > 0 ? item.children.length - 1 : null;
147
+ lines.push(renderBulletItem(item, GREY_COLOR, 0, allChildrenIndex));
148
+ }
149
+ else if (i === step.itemIndex) {
150
+ // Current top-level item - colored
151
+ if (step.subIndex === null) {
152
+ // No children case - just show item
153
+ lines.push(renderBulletItem(item, null, 0, null));
154
+ }
155
+ else if (step.subIndex === -1) {
156
+ // Has children but showing parent only first
157
+ lines.push(renderBulletItem(item, null, 0, null));
158
+ }
159
+ else {
160
+ // Showing parent + children up to subIndex
161
+ lines.push(renderBulletItem(item, null, 0, step.subIndex));
162
+ }
163
+ }
164
+ // Future items (i > step.itemIndex) - not shown yet
165
+ }
166
+ slideContents.push(lines.join('\n'));
167
+ }
168
+ return slideContents;
169
+ }
170
+ /**
171
+ * Process ::: buildup blocks in content and expand to steps
172
+ */
173
+ function processBuildupBlocks(content, format) {
174
+ const buildupMatch = content.match(/^:::\s*buildup\s*\n([\s\S]*?)\n:::\s*$/m);
175
+ if (!buildupMatch || buildupMatch.index === undefined) {
176
+ return { content, buildupSteps: null };
177
+ }
178
+ const buildupContent = buildupMatch[1] || '';
179
+ const buildupSteps = expandBuildup(buildupContent, format);
180
+ // Remove the buildup block from content (will be replaced by steps)
181
+ const beforeBuildup = content.slice(0, buildupMatch.index).trim();
182
+ const afterBuildup = content.slice(buildupMatch.index + buildupMatch[0].length).trim();
183
+ return {
184
+ content: beforeBuildup,
185
+ afterContent: afterBuildup,
186
+ buildupSteps,
187
+ };
188
+ }
189
+ /**
190
+ * Parse slide style attributes from heading
191
+ */
192
+ function parseSlideStyle(heading) {
193
+ const style = {
194
+ background: null,
195
+ type: null,
196
+ nonumber: false,
197
+ center: false,
198
+ classes: [],
199
+ };
200
+ // Match {.class1 .class2} at end of heading
201
+ const attrMatch = heading.match(/\s*\{([^}]+)\}\s*$/);
202
+ if (!attrMatch || attrMatch.index === undefined) {
203
+ return { title: heading.trim(), style };
204
+ }
205
+ const title = heading.slice(0, attrMatch.index).trim();
206
+ const attrs = attrMatch[1] || '';
207
+ // Parse each .class
208
+ const classMatches = attrs.matchAll(/\.(\w+)/g);
209
+ for (const match of classMatches) {
210
+ if (!match[1])
211
+ continue;
212
+ const cls = match[1].toLowerCase();
213
+ style.classes.push(cls);
214
+ // Background styles
215
+ if (['dark', 'light', 'accent', 'inverse'].includes(cls)) {
216
+ style.background = cls;
217
+ }
218
+ // Special slide types
219
+ else if (['cover', 'thanks', 'section', 'plain'].includes(cls)) {
220
+ style.type = cls;
221
+ // Cover, thanks, section slides default to no numbering
222
+ if (['cover', 'thanks', 'section'].includes(cls)) {
223
+ style.nonumber = true;
224
+ style.center = true;
225
+ }
226
+ }
227
+ // Explicit options
228
+ else if (cls === 'nonumber' || cls === 'unnumbered') {
229
+ style.nonumber = true;
230
+ }
231
+ else if (cls === 'center' || cls === 'centered') {
232
+ style.center = true;
233
+ }
234
+ }
235
+ return { title, style };
236
+ }
237
+ /**
238
+ * Parse a single slide's content into steps and notes
239
+ */
240
+ export function parseSlide(slideContent) {
241
+ const lines = slideContent.split('\n');
242
+ // Extract title (first heading)
243
+ let title = '';
244
+ let titleLevel = 2;
245
+ let titleLineIndex = -1;
246
+ let style = {
247
+ background: null,
248
+ type: null,
249
+ nonumber: false,
250
+ center: false,
251
+ classes: [],
252
+ };
253
+ for (let i = 0; i < lines.length; i++) {
254
+ const line = lines[i];
255
+ if (!line)
256
+ continue;
257
+ const match = line.match(/^(#{1,6})\s+(.+)$/);
258
+ if (match && match[1] && match[2]) {
259
+ titleLevel = match[1].length;
260
+ // Parse style from heading
261
+ const parsed = parseSlideStyle(match[2]);
262
+ title = parsed.title;
263
+ style = parsed.style;
264
+ titleLineIndex = i;
265
+ break;
266
+ }
267
+ }
268
+ // Content after title
269
+ const contentStart = titleLineIndex >= 0 ? titleLineIndex + 1 : 0;
270
+ const bodyContent = lines.slice(contentStart).join('\n');
271
+ // Parse ::: step and ::: notes blocks
272
+ const steps = [];
273
+ let notes = null;
274
+ let preamble = '';
275
+ // Regex to match fenced div blocks
276
+ const bodyLines = bodyContent.split('\n');
277
+ let inBlock = false;
278
+ let blockType = null;
279
+ let currentBlockContent = [];
280
+ let beforeFirstStep = [];
281
+ let foundFirstStep = false;
282
+ for (let i = 0; i < bodyLines.length; i++) {
283
+ const line = bodyLines[i];
284
+ if (!line && line !== '')
285
+ continue;
286
+ if (!inBlock) {
287
+ // Check for block start
288
+ const stepMatch = line.match(/^:::\s*step\s*$/);
289
+ const notesMatch = line.match(/^:::\s*notes\s*$/);
290
+ if (stepMatch) {
291
+ inBlock = true;
292
+ blockType = 'step';
293
+ currentBlockContent = [];
294
+ foundFirstStep = true;
295
+ }
296
+ else if (notesMatch) {
297
+ inBlock = true;
298
+ blockType = 'notes';
299
+ currentBlockContent = [];
300
+ }
301
+ else if (!foundFirstStep) {
302
+ beforeFirstStep.push(line);
303
+ }
304
+ }
305
+ else {
306
+ // Check for block end
307
+ if (line.match(/^:::\s*$/)) {
308
+ // End of block
309
+ if (blockType === 'step') {
310
+ steps.push({
311
+ index: steps.length + 1,
312
+ content: currentBlockContent.join('\n').trim(),
313
+ });
314
+ }
315
+ else if (blockType === 'notes') {
316
+ notes = currentBlockContent.join('\n').trim();
317
+ }
318
+ inBlock = false;
319
+ blockType = null;
320
+ currentBlockContent = [];
321
+ }
322
+ else {
323
+ currentBlockContent.push(line);
324
+ }
325
+ }
326
+ }
327
+ // Handle content before first step as preamble
328
+ preamble = beforeFirstStep.join('\n').trim();
329
+ // If no explicit steps, treat entire body as single step
330
+ if (steps.length === 0) {
331
+ // Remove notes from body if present
332
+ let bodyWithoutNotes = bodyContent;
333
+ const notesBlockMatch = bodyContent.match(/^:::\s*notes\s*$[\s\S]*?^:::\s*$/m);
334
+ if (notesBlockMatch) {
335
+ bodyWithoutNotes = bodyContent.replace(notesBlockMatch[0], '').trim();
336
+ }
337
+ steps.push({
338
+ index: 1,
339
+ content: bodyWithoutNotes.trim(),
340
+ });
341
+ preamble = '';
342
+ }
343
+ return {
344
+ title,
345
+ titleLevel,
346
+ steps,
347
+ notes,
348
+ preamble,
349
+ style,
350
+ };
351
+ }
352
+ /**
353
+ * Parse markdown document into slides
354
+ */
355
+ export function parseSlides(markdown) {
356
+ // Normalize line endings to \n
357
+ const normalized = markdown.replace(/\r\n/g, '\n');
358
+ // Split by --- (horizontal rule / slide delimiter)
359
+ // Handle YAML frontmatter by checking for --- at start
360
+ let content = normalized;
361
+ let frontmatter = null;
362
+ // Extract YAML frontmatter if present
363
+ if (normalized.startsWith('---')) {
364
+ const endMatch = normalized.slice(3).indexOf('\n---');
365
+ if (endMatch !== -1) {
366
+ frontmatter = normalized.slice(0, endMatch + 7); // Include both ---
367
+ content = normalized.slice(endMatch + 7).trim();
368
+ }
369
+ }
370
+ // Split remaining content by ---
371
+ const parts = content.split(/\n---\n/);
372
+ const slides = [];
373
+ for (const part of parts) {
374
+ if (!part)
375
+ continue;
376
+ const trimmed = part.trim();
377
+ if (trimmed) {
378
+ slides.push(parseSlide(trimmed));
379
+ }
380
+ }
381
+ // Attach frontmatter to first slide's preamble if exists
382
+ if (frontmatter && slides.length > 0 && slides[0]) {
383
+ slides[0]._frontmatter = frontmatter;
384
+ }
385
+ return slides;
386
+ }
387
+ /**
388
+ * Build Beamer frame options string
389
+ */
390
+ function buildBeamerFrameOptions(style) {
391
+ if (!style)
392
+ return '';
393
+ const options = [];
394
+ // Special slide type options
395
+ if (style.type && BEAMER_FRAME_OPTIONS[style.type]) {
396
+ const opts = BEAMER_FRAME_OPTIONS[style.type];
397
+ if (opts)
398
+ options.push(...opts.split(','));
399
+ }
400
+ else {
401
+ // Individual options
402
+ if (style.nonumber) {
403
+ options.push('noframenumbering');
404
+ }
405
+ if (style.center) {
406
+ options.push('c');
407
+ }
408
+ }
409
+ // Deduplicate
410
+ const unique = [...new Set(options)];
411
+ return unique.length > 0 ? `[${unique.join(',')}]` : '';
412
+ }
413
+ /**
414
+ * Generate Beamer markdown using pandoc's native slide structure
415
+ * Works WITH pandoc, not against it - pandoc creates frames, we add overlays
416
+ */
417
+ export function generateBeamerMarkdown(slides) {
418
+ const output = [];
419
+ // Check if first slide is a cover slide - if so, skip pandoc's auto title page
420
+ const hasExplicitCover = slides.length > 0 && slides[0] && slides[0].style && slides[0].style.type === 'cover';
421
+ for (const slide of slides) {
422
+ // Include frontmatter if present
423
+ if (slide._frontmatter) {
424
+ let frontmatter = slide._frontmatter;
425
+ // If we have an explicit cover slide, remove title/author/date to prevent
426
+ // pandoc from generating a duplicate title frame
427
+ if (hasExplicitCover) {
428
+ // Remove title, author, date lines but keep other frontmatter
429
+ frontmatter = frontmatter
430
+ .replace(/^title:.*\n?/m, '')
431
+ .replace(/^author:.*\n?/m, '')
432
+ .replace(/^date:.*\n?/m, '')
433
+ .replace(/\n{2,}/g, '\n'); // Clean up extra blank lines
434
+ // Check if frontmatter is now empty (just --- and ---)
435
+ const content = frontmatter.replace(/---/g, '').trim();
436
+ if (!content) {
437
+ // Skip empty frontmatter entirely - don't output anything
438
+ // The slide content will follow directly
439
+ }
440
+ else {
441
+ output.push(frontmatter);
442
+ output.push('');
443
+ }
444
+ }
445
+ else {
446
+ output.push(frontmatter);
447
+ output.push('');
448
+ }
449
+ }
450
+ // Build pandoc heading with beamer attributes
451
+ let headingAttrs = '';
452
+ const attrList = [];
453
+ if (slide.style) {
454
+ if (slide.style.type === 'cover' || slide.style.type === 'thanks' || slide.style.type === 'section') {
455
+ attrList.push('.plain');
456
+ attrList.push('.noframenumbering');
457
+ attrList.push('.c');
458
+ }
459
+ else if (slide.style.type === 'plain') {
460
+ attrList.push('.plain');
461
+ }
462
+ if (slide.style.nonumber && !attrList.includes('.noframenumbering')) {
463
+ attrList.push('.noframenumbering');
464
+ }
465
+ if (slide.style.center && !attrList.includes('.c')) {
466
+ attrList.push('.c');
467
+ }
468
+ }
469
+ if (attrList.length > 0) {
470
+ headingAttrs = ' {' + attrList.join(' ') + '}';
471
+ }
472
+ // Frame heading - pandoc creates the frame from this
473
+ const heading = '#'.repeat(slide.titleLevel) + ' ' + slide.title + headingAttrs;
474
+ output.push(heading);
475
+ output.push('');
476
+ // Note: Per-frame background colors (.dark, .accent) are not yet supported
477
+ // in the pandoc-based beamer output. The classes are preserved for PPTX.
478
+ // Add preamble if present (visible on all overlays)
479
+ if (slide.preamble) {
480
+ output.push(slide.preamble);
481
+ output.push('');
482
+ }
483
+ // Generate content
484
+ if (slide.steps.length === 1 && slide.steps[0]) {
485
+ // Single step - just output content, no overlays needed
486
+ output.push(slide.steps[0].content);
487
+ }
488
+ else {
489
+ // Multiple steps - use \pause between steps
490
+ // This is the pandoc-friendly way to do incremental reveals
491
+ for (let i = 0; i < slide.steps.length; i++) {
492
+ const step = slide.steps[i];
493
+ if (!step)
494
+ continue;
495
+ output.push(step.content);
496
+ output.push('');
497
+ // Add pause after each step except the last
498
+ if (i < slide.steps.length - 1) {
499
+ output.push('. . .');
500
+ output.push('');
501
+ }
502
+ }
503
+ }
504
+ // Add speaker notes as LaTeX \note{} command
505
+ if (slide.notes) {
506
+ output.push('');
507
+ // Escape special LaTeX characters in notes
508
+ const notes = slide.notes || '';
509
+ const escapedNotes = notes
510
+ .replace(/\\/g, '\\textbackslash{}')
511
+ .replace(/[&%$#_{}]/g, '\\$&')
512
+ .replace(/\n/g, '\\\\');
513
+ output.push('\\note{' + escapedNotes + '}');
514
+ }
515
+ output.push('');
516
+ output.push('---');
517
+ output.push('');
518
+ }
519
+ // Remove trailing ---
520
+ while (output.length > 0) {
521
+ const last = output[output.length - 1];
522
+ if (!last || last.trim() !== '')
523
+ break;
524
+ output.pop();
525
+ }
526
+ if (output.length > 0 && output[output.length - 1] === '---') {
527
+ output.pop();
528
+ }
529
+ return output.join('\n');
530
+ }
531
+ /**
532
+ * Build PPTX slide class attribute string
533
+ */
534
+ function buildPptxSlideClasses(style) {
535
+ if (!style || !style.classes || style.classes.length === 0) {
536
+ return '';
537
+ }
538
+ return ' {.' + style.classes.join(' .') + '}';
539
+ }
540
+ /**
541
+ * Generate PPTX markdown with duplicated slides for steps
542
+ * Each step becomes a separate physical slide
543
+ * Handles ::: buildup blocks by expanding them into multiple slides
544
+ */
545
+ export function generatePptxMarkdown(slides) {
546
+ const output = [];
547
+ for (const slide of slides) {
548
+ // Include frontmatter if present (only on first slide)
549
+ if (slide._frontmatter) {
550
+ output.push(slide._frontmatter);
551
+ output.push('');
552
+ }
553
+ // Check if any step contains a buildup block
554
+ const stepsWithBuildup = slide.steps.map((step) => {
555
+ const result = processBuildupBlocks(step.content, 'pptx');
556
+ return {
557
+ ...step,
558
+ beforeBuildup: result.content,
559
+ afterBuildup: result.afterContent || '',
560
+ buildupSteps: result.buildupSteps,
561
+ };
562
+ });
563
+ // Generate slides - handle buildup expansion
564
+ for (let i = 0; i < stepsWithBuildup.length; i++) {
565
+ const step = stepsWithBuildup[i];
566
+ if (!step)
567
+ continue;
568
+ if (step.buildupSteps && step.buildupSteps.length > 0) {
569
+ // This step has a buildup block - generate one slide per buildup step
570
+ for (const buildupContent of step.buildupSteps) {
571
+ const classes = buildPptxSlideClasses(slide.style);
572
+ const heading = '#'.repeat(slide.titleLevel) + ' ' + slide.title + classes;
573
+ output.push(heading);
574
+ output.push('');
575
+ // Add preamble if present
576
+ if (slide.preamble) {
577
+ output.push(slide.preamble);
578
+ output.push('');
579
+ }
580
+ // Add content before buildup block
581
+ if (step.beforeBuildup) {
582
+ output.push(step.beforeBuildup);
583
+ output.push('');
584
+ }
585
+ // Add this buildup step content
586
+ output.push(buildupContent);
587
+ output.push('');
588
+ // Add content after buildup block
589
+ if (step.afterBuildup) {
590
+ output.push(step.afterBuildup);
591
+ output.push('');
592
+ }
593
+ // Add speaker notes
594
+ if (slide.notes) {
595
+ output.push('::: notes');
596
+ output.push(slide.notes);
597
+ output.push(':::');
598
+ }
599
+ output.push('');
600
+ output.push('---');
601
+ output.push('');
602
+ }
603
+ }
604
+ else {
605
+ // Regular step - no buildup
606
+ const classes = buildPptxSlideClasses(slide.style);
607
+ const heading = '#'.repeat(slide.titleLevel) + ' ' + slide.title + classes;
608
+ output.push(heading);
609
+ output.push('');
610
+ // Add preamble if present
611
+ if (slide.preamble) {
612
+ output.push(slide.preamble);
613
+ output.push('');
614
+ }
615
+ // Add cumulative steps up to current
616
+ for (let j = 0; j <= i; j++) {
617
+ const s = stepsWithBuildup[j];
618
+ if (s) {
619
+ output.push(s.content);
620
+ output.push('');
621
+ }
622
+ }
623
+ // Add speaker notes
624
+ if (slide.notes) {
625
+ output.push('::: notes');
626
+ output.push(slide.notes);
627
+ output.push(':::');
628
+ }
629
+ output.push('');
630
+ output.push('---');
631
+ output.push('');
632
+ }
633
+ }
634
+ }
635
+ // Remove trailing ---
636
+ while (output.length > 0) {
637
+ const last = output[output.length - 1];
638
+ if (!last || last.trim() !== '')
639
+ break;
640
+ output.pop();
641
+ }
642
+ if (output.length > 0 && output[output.length - 1] === '---') {
643
+ output.pop();
644
+ }
645
+ return output.join('\n');
646
+ }
647
+ /**
648
+ * Process markdown for slide output format
649
+ */
650
+ export function processSlideMarkdown(markdown, format) {
651
+ const slides = parseSlides(markdown);
652
+ if (format === 'beamer') {
653
+ return generateBeamerMarkdown(slides);
654
+ }
655
+ else if (format === 'pptx') {
656
+ return generatePptxMarkdown(slides);
657
+ }
658
+ return markdown;
659
+ }
660
+ /**
661
+ * Check if markdown contains slide syntax (steps, notes, buildup, or slide styles)
662
+ */
663
+ export function hasSlideSyntax(markdown) {
664
+ // Check for ::: step, ::: notes, or ::: buildup
665
+ if (/^:::\s*(step|notes|buildup)\s*$/m.test(markdown)) {
666
+ return true;
667
+ }
668
+ // Check for slide style attributes on headings: ## Title {.dark}
669
+ if (/^#{1,6}\s+.+\{[^}]*\.(dark|light|accent|inverse|cover|thanks|section|plain|nonumber|center)/m.test(markdown)) {
670
+ return true;
671
+ }
672
+ return false;
673
+ }
674
+ // Export style parser for testing
675
+ export { parseSlideStyle };
676
+ //# sourceMappingURL=slides.js.map