yumiamd 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/bin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runCli
4
- } from "./chunk-FHM6V4JH.js";
4
+ } from "./chunk-GMIVPFBA.js";
5
5
 
6
6
  // src/bin.ts
7
7
  var result = await runCli(process.argv);
@@ -574,7 +574,7 @@ var VIEWPORT_PRESETS = {
574
574
  var DefaultLayoutEngine = class {
575
575
  computeSlide(slide, viewport = DEFAULT_VIEWPORT, options = {}) {
576
576
  const padding = options.padding ?? 64;
577
- const gap = options.gap ?? 24;
577
+ const gap = options.gap ?? 32;
578
578
  const availableWidth = Math.max(100, viewport.width - padding * 2);
579
579
  const availableHeight = Math.max(100, viewport.height - padding * 2);
580
580
  if (slide.elements.length === 0) {
@@ -626,7 +626,7 @@ var DefaultLayoutEngine = class {
626
626
  return { element, bounds: { x, y, width, height } };
627
627
  }
628
628
  case "list": {
629
- const height = this.estimateListHeight(element);
629
+ const height = this.estimateListHeight(element, width);
630
630
  return { element, bounds: { x, y, width, height } };
631
631
  }
632
632
  case "code": {
@@ -658,13 +658,13 @@ var DefaultLayoutEngine = class {
658
658
  }
659
659
  }
660
660
  layoutCard(element, x, y, width, gap) {
661
- const cardPadding = 28;
661
+ const cardPadding = 32;
662
662
  const innerWidth = Math.max(10, width - cardPadding * 2);
663
- const titleHeight = element.title ? 56 : 0;
663
+ const titleHeight = element.title ? 60 : 0;
664
664
  const innerStartY = y + cardPadding + titleHeight;
665
- const { nodes: children, totalHeight: innerHeight } = this.layoutElementList(element.elements, x + cardPadding, innerStartY, innerWidth, gap / 1.5);
666
- const cardHeight = titleHeight + innerHeight + cardPadding * 2;
667
- const bounds = { x, y, width, height: Math.max(100, cardHeight) };
665
+ const { nodes: children, totalHeight: innerHeight } = this.layoutElementList(element.elements, x + cardPadding, innerStartY, innerWidth, gap);
666
+ const cardHeight = titleHeight + innerHeight + cardPadding * 2 + 12;
667
+ const bounds = { x, y, width, height: Math.max(120, cardHeight) };
668
668
  return {
669
669
  element,
670
670
  bounds,
@@ -727,24 +727,31 @@ var DefaultLayoutEngine = class {
727
727
  estimateParagraphHeight(paragraph, width) {
728
728
  const charsPerLine = Math.max(20, Math.floor(width / 14));
729
729
  const lines = Math.ceil(paragraph.text.length / charsPerLine) || 1;
730
- return Math.max(40, lines * 32);
730
+ return Math.max(40, lines * 36);
731
731
  }
732
- estimateListHeight(list) {
733
- return Math.max(40, list.items.length * 40);
732
+ estimateListHeight(list, width = 800) {
733
+ const charsPerLine = Math.max(15, Math.floor(width / 13));
734
+ let totalHeight = 0;
735
+ for (const item of list.items) {
736
+ const cleanLen = item.text.replace(/\*\*/g, "").replace(/\*/g, "").length;
737
+ const lines = Math.ceil(cleanLen / charsPerLine) || 1;
738
+ totalHeight += lines * 34 + 18;
739
+ }
740
+ return Math.max(40, totalHeight);
734
741
  }
735
742
  estimateCodeHeight(code) {
736
743
  const lines = code.code.split("\n").length || 1;
737
- return lines * 26 + 32;
744
+ return lines * 28 + 48;
738
745
  }
739
746
  estimateQuoteHeight(quote, width) {
740
747
  const charsPerLine = Math.max(20, Math.floor(width / 14));
741
748
  const lines = Math.ceil(quote.text.length / charsPerLine) || 1;
742
- return lines * 32 + 24;
749
+ return lines * 34 + 32;
743
750
  }
744
751
  estimateTableHeight(table) {
745
- const headerHeight = table.headers && table.headers.length > 0 ? 50 : 0;
746
- const rowsHeight = (table.rows ? table.rows.length : 0) * 42;
747
- return Math.max(60, headerHeight + rowsHeight + 16);
752
+ const headerHeight = table.headers && table.headers.length > 0 ? 56 : 0;
753
+ const rowsHeight = (table.rows ? table.rows.length : 0) * 44;
754
+ return Math.max(60, headerHeight + rowsHeight + 20);
748
755
  }
749
756
  estimateImageHeight(image) {
750
757
  if (typeof image.height === "number") {
@@ -944,6 +951,37 @@ var CSS_NAMED_COLORS = {
944
951
  slate: "0f172a",
945
952
  transparent: "ffffff"
946
953
  };
954
+ function parseInlineMarkdown(rawText, baseOptions) {
955
+ const chunks = [];
956
+ const regex = /(\*\*.*?\*\*|\*.*?\*|`.*?`)/g;
957
+ const parts = rawText.split(regex);
958
+ for (const part of parts) {
959
+ if (!part)
960
+ continue;
961
+ if (part.startsWith("**") && part.endsWith("**") && part.length >= 4) {
962
+ chunks.push({
963
+ text: part.slice(2, -2),
964
+ options: { ...baseOptions, bold: true }
965
+ });
966
+ } else if (part.startsWith("*") && part.endsWith("*") && part.length >= 2) {
967
+ chunks.push({
968
+ text: part.slice(1, -1),
969
+ options: { ...baseOptions, italic: true }
970
+ });
971
+ } else if (part.startsWith("`") && part.endsWith("`") && part.length >= 2) {
972
+ chunks.push({
973
+ text: part.slice(1, -1),
974
+ options: { ...baseOptions, fontFace: "Courier New" }
975
+ });
976
+ } else {
977
+ chunks.push({
978
+ text: part,
979
+ options: { ...baseOptions }
980
+ });
981
+ }
982
+ }
983
+ return chunks.length > 0 ? chunks : [{ text: rawText, options: baseOptions }];
984
+ }
947
985
  var PptxRenderer = class {
948
986
  name = "PptxRenderer";
949
987
  targetFormat = "pptx";
@@ -1027,15 +1065,17 @@ var PptxRenderer = class {
1027
1065
  renderHeading(pptxSlide, heading, rect, theme) {
1028
1066
  const fontSize = this.getHeadingFontSize(heading.level, theme);
1029
1067
  const color = this.cleanHexColor(heading.level === 1 ? theme.colors.primary : theme.colors.text);
1030
- pptxSlide.addText(heading.text, {
1068
+ const chunks = parseInlineMarkdown(heading.text, {
1069
+ fontSize,
1070
+ bold: true,
1071
+ fontFace: theme.typography.headingFont.split(",")[0]?.trim() || "Arial",
1072
+ color
1073
+ });
1074
+ pptxSlide.addText(chunks, {
1031
1075
  x: rect.x,
1032
1076
  y: rect.y,
1033
1077
  w: rect.w,
1034
1078
  h: rect.h,
1035
- fontSize,
1036
- bold: true,
1037
- fontFace: theme.typography.headingFont.split(",")[0]?.trim() || "Arial",
1038
- color,
1039
1079
  align: heading.align || "left",
1040
1080
  valign: "middle",
1041
1081
  margin: 0
@@ -1044,14 +1084,16 @@ var PptxRenderer = class {
1044
1084
  renderParagraph(pptxSlide, paragraph, rect, theme) {
1045
1085
  const fontSize = theme.typography.sizes?.body || 18;
1046
1086
  const color = this.cleanHexColor(theme.colors.text);
1047
- pptxSlide.addText(paragraph.text, {
1087
+ const chunks = parseInlineMarkdown(paragraph.text, {
1088
+ fontSize,
1089
+ fontFace: theme.typography.bodyFont.split(",")[0]?.trim() || "Arial",
1090
+ color
1091
+ });
1092
+ pptxSlide.addText(chunks, {
1048
1093
  x: rect.x,
1049
1094
  y: rect.y,
1050
1095
  w: rect.w,
1051
1096
  h: rect.h,
1052
- fontSize,
1053
- fontFace: theme.typography.bodyFont.split(",")[0]?.trim() || "Arial",
1054
- color,
1055
1097
  align: paragraph.align || "left",
1056
1098
  valign: "top",
1057
1099
  margin: 0
@@ -1060,18 +1102,24 @@ var PptxRenderer = class {
1060
1102
  renderList(pptxSlide, list, rect, theme) {
1061
1103
  const fontSize = theme.typography.sizes?.body || 18;
1062
1104
  const color = this.cleanHexColor(theme.colors.text);
1063
- const textItems = list.items.map((item) => ({
1064
- text: item.text,
1065
- options: {
1066
- bullet: list.ordered ? { type: "number" } : true,
1105
+ const allChunks = [];
1106
+ list.items.forEach((item) => {
1107
+ const itemChunks = parseInlineMarkdown(item.text, {
1067
1108
  fontSize,
1068
1109
  color,
1069
1110
  fontFace: theme.typography.bodyFont.split(",")[0]?.trim() || "Arial",
1070
1111
  indentLevel: item.depth || 0,
1071
1112
  paraSpaceAfter: 8
1113
+ });
1114
+ if (itemChunks.length > 0) {
1115
+ itemChunks[0].options = {
1116
+ ...itemChunks[0].options,
1117
+ bullet: list.ordered ? { type: "number" } : true
1118
+ };
1072
1119
  }
1073
- }));
1074
- pptxSlide.addText(textItems, {
1120
+ allChunks.push(...itemChunks);
1121
+ });
1122
+ pptxSlide.addText(allChunks, {
1075
1123
  x: rect.x,
1076
1124
  y: rect.y,
1077
1125
  w: rect.w,
@@ -1086,7 +1134,7 @@ var PptxRenderer = class {
1086
1134
  const borderColor = this.cleanHexColor(theme.colors.border || "#cbd5e1");
1087
1135
  if (table.headers && table.headers.length > 0) {
1088
1136
  tableRows.push(table.headers.map((h) => ({
1089
- text: h,
1137
+ text: h.replace(/\*\*/g, ""),
1090
1138
  options: {
1091
1139
  bold: true,
1092
1140
  color: "ffffff",
@@ -1100,7 +1148,7 @@ var PptxRenderer = class {
1100
1148
  table.rows.forEach((row, rowIndex) => {
1101
1149
  const rowBg = rowIndex % 2 === 1 ? "f8fafc" : "ffffff";
1102
1150
  tableRows.push(row.map((cell) => ({
1103
- text: cell,
1151
+ text: cell.replace(/\*\*/g, ""),
1104
1152
  options: {
1105
1153
  color: this.cleanHexColor(theme.colors.text),
1106
1154
  fill: { color: rowBg },
@@ -1162,15 +1210,15 @@ var PptxRenderer = class {
1162
1210
  h: rect.h,
1163
1211
  fill: { color: fillColor },
1164
1212
  line: { color: borderColor, width: 1.5 },
1165
- rectRadius: 0.1
1213
+ rectRadius: 0.08
1166
1214
  });
1167
1215
  if (card.title) {
1168
1216
  pptxSlide.addText(card.title, {
1169
- x: rect.x + 28 * scaleX,
1170
- y: rect.y + 20 * scaleY,
1171
- w: rect.w - 56 * scaleX,
1172
- h: 40 * scaleY,
1173
- fontSize: 22,
1217
+ x: rect.x + 0.25,
1218
+ y: rect.y + 0.18,
1219
+ w: rect.w - 0.5,
1220
+ h: 0.35,
1221
+ fontSize: 20,
1174
1222
  bold: true,
1175
1223
  color: this.cleanHexColor(theme.colors.primary),
1176
1224
  fontFace: theme.typography.headingFont.split(",")[0]?.trim() || "Arial"
@@ -1225,12 +1273,13 @@ var PptxRenderer = class {
1225
1273
  h: rect.h,
1226
1274
  fill: { color: accentColor }
1227
1275
  });
1228
- pptxSlide.addText(`"${quote.text}"`, {
1276
+ const cleanText = quote.text.replace(/^["'“”«»]+|["'“”«»]+$/g, "").trim();
1277
+ pptxSlide.addText(`\u201C${cleanText}\u201D`, {
1229
1278
  x: rect.x + 0.2,
1230
1279
  y: rect.y,
1231
1280
  w: rect.w - 0.2,
1232
1281
  h: rect.h,
1233
- fontSize: 20,
1282
+ fontSize: 18,
1234
1283
  italic: true,
1235
1284
  color: this.cleanHexColor(theme.colors.muted || theme.colors.text),
1236
1285
  fontFace: theme.typography.bodyFont.split(",")[0]?.trim() || "Arial",
@@ -1282,7 +1331,7 @@ var PptxRenderer = class {
1282
1331
  // src/cli.ts
1283
1332
  import { mkdirSync, readFileSync, writeFileSync } from "fs";
1284
1333
  import { basename, dirname, extname, join, resolve } from "path";
1285
- var VERSION = "0.1.6";
1334
+ var VERSION = "0.1.7";
1286
1335
  function printHelp() {
1287
1336
  return `
1288
1337
  YumiaMD \u2014 Markdown-based presentation compiler (v${VERSION})
@@ -1629,6 +1678,7 @@ export {
1629
1678
  defaultTheme,
1630
1679
  createTheme,
1631
1680
  YumiaCompiler,
1681
+ parseInlineMarkdown,
1632
1682
  PptxRenderer,
1633
1683
  VERSION,
1634
1684
  printHelp,
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export * from '@yumiamd/layout';
6
6
  export * from '@yumiamd/renderer';
7
7
  export * from '@yumiamd/renderer-pptx';
8
8
 
9
- declare const VERSION = "0.1.6";
9
+ declare const VERSION = "0.1.7";
10
10
  declare function printHelp(): string;
11
11
  declare function runCli(argv: string[]): Promise<{
12
12
  exitCode: number;
package/dist/index.js CHANGED
@@ -22,10 +22,11 @@ import {
22
22
  createTable,
23
23
  createTheme,
24
24
  defaultTheme,
25
+ parseInlineMarkdown,
25
26
  parseYumia,
26
27
  printHelp,
27
28
  runCli
28
- } from "./chunk-FHM6V4JH.js";
29
+ } from "./chunk-GMIVPFBA.js";
29
30
  export {
30
31
  DEFAULT_VIEWPORT,
31
32
  DefaultLayoutEngine,
@@ -50,6 +51,7 @@ export {
50
51
  createTable,
51
52
  createTheme,
52
53
  defaultTheme,
54
+ parseInlineMarkdown,
53
55
  parseYumia,
54
56
  printHelp,
55
57
  runCli
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yumiamd",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Command line interface and compiler for YumiaMD presentations",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -20,13 +20,13 @@
20
20
  },
21
21
  "devDependencies": {
22
22
  "tsup": "^8.5.1",
23
- "@yumiamd/ast": "0.1.6",
24
- "@yumiamd/parser": "0.1.6",
25
- "@yumiamd/core": "0.1.6",
26
- "@yumiamd/layout": "0.1.6",
27
- "@yumiamd/renderer": "0.1.6",
28
- "@yumiamd/renderer-pptx": "0.1.6",
29
- "@yumiamd/theme": "0.1.6"
23
+ "@yumiamd/ast": "0.1.7",
24
+ "@yumiamd/parser": "0.1.7",
25
+ "@yumiamd/renderer": "0.1.7",
26
+ "@yumiamd/core": "0.1.7",
27
+ "@yumiamd/renderer-pptx": "0.1.7",
28
+ "@yumiamd/layout": "0.1.7",
29
+ "@yumiamd/theme": "0.1.7"
30
30
  },
31
31
  "keywords": [
32
32
  "yumia",