@bendyline/squisq-formats 2.6.18 → 2.6.20

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/NOTICE.md CHANGED
@@ -11,7 +11,7 @@ Third-party components remain under their respective license terms.
11
11
  | @pdf-lib/fontkit | 1.1.1 | MIT | https://github.com/Hopding/fontkit |
12
12
  | @pdf-lib/upng | 1.0.1 | MIT | https://github.com/Hopding/upng |
13
13
  | @xmldom/xmldom | 0.9.12 | MIT | https://github.com/xmldom/xmldom |
14
- | jszip | 3.10.1 | MIT OR GPL-3.0-or-later | https://github.com/Stuk/jszip |
14
+ | jszip | 3.10.2 | MIT OR GPL-3.0-or-later | https://github.com/Stuk/jszip |
15
15
  | pdf-lib | 1.17.1 | MIT | https://pdf-lib.js.org |
16
16
  | pdfjs-dist | 4.10.38 | Apache-2.0 | https://mozilla.github.io/pdf.js |
17
17
  | hyparquet _(peer)_ | ^1.29.1 | MIT | https://github.com/hyparam/hyparquet |
package/README.md CHANGED
@@ -87,7 +87,7 @@ const imported = await pdfToMarkdownDoc(pdfBuffer);
87
87
  const container = await pdfToContainer(pdfBuffer);
88
88
  ```
89
89
 
90
- **Fidelity:** export uses pdf-lib's standard 14 fonts (`themeId` affects colors only). Pass `images` (keyed by the markdown URL, as for DOCX) to draw PNG and JPEG images that stand alone in a paragraph; other images print as an `[Image: alt]` note. PDF has no semantic structure, so import is heuristic and best-effort: headings are detected by font size, and tables / code blocks / blockquotes / links via the `detectTables` / `detectCodeBlocks` / `detectBlockquotes` / `detectLinks` options (all default true). `pdfToMarkdownDoc` is text-only; `pdfToContainer` also extracts embedded XObject and inline raster images in browsers and Node, placed **by page** — each image is inserted after the last content block from its page (image-only pages fall back to the nearest preceding page with content, else the document end). Placement is page-level only; masks, vector artwork, and images that PDF.js cannot expose as decoded pixels are not emitted.
90
+ **Fidelity:** export uses pdf-lib's standard 14 fonts (`themeId` affects colors only). Pages stay white for printing. Theme text, heading, and link colors are retained when they meet 4.5:1 contrast against both white paper and the shaded table header; otherwise the exporter uses its default dark ink for that role. This also applies to inherited and custom themes. Pass `images` (keyed by the markdown URL, as for DOCX) to draw PNG and JPEG images that stand alone in a paragraph; other images print as an `[Image: alt]` note. PDF has no semantic structure, so import is heuristic and best-effort: headings are detected by font size, and tables / code blocks / blockquotes / links via the `detectTables` / `detectCodeBlocks` / `detectBlockquotes` / `detectLinks` options (all default true). `pdfToMarkdownDoc` is text-only; `pdfToContainer` also extracts embedded XObject and inline raster images in browsers and Node, placed **by page** — each image is inserted after the last content block from its page (image-only pages fall back to the nearest preceding page with content, else the document end). Placement is page-level only; masks, vector artwork, and images that PDF.js cannot expose as decoded pixels are not emitted.
91
91
 
92
92
  ### Diagrams as pictures
93
93
 
@@ -5,10 +5,10 @@ and notice files are reproduced verbatim. When an npm tarball omits its
5
5
  repository license, the pinned upstream copy is vendored and identified below.
6
6
 
7
7
  COMPONENTS
8
- - @fortawesome/fontawesome-free@7.2.0 ((CC-BY-4.0 AND OFL-1.1 AND MIT)); files: LICENSE.txt
8
+ - @fortawesome/fontawesome-free@7.3.1 ((CC-BY-4.0 AND OFL-1.1 AND MIT)); files: LICENSE.txt
9
9
 
10
10
  ==============================================================================
11
- @fortawesome/fontawesome-free@7.2.0 - LICENSE.txt
11
+ @fortawesome/fontawesome-free@7.3.1 - LICENSE.txt
12
12
  ==============================================================================
13
13
  Fonticons, Inc. (https://fontawesome.com)
14
14
 
@@ -342,7 +342,7 @@ ${body}
342
342
  function escapeStyleText(css) {
343
343
  return css.replace(/</g, "\\3c ");
344
344
  }
345
- var FONT_AWESOME_LINK = `<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.2.0/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer">
345
+ var FONT_AWESOME_LINK = `<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/7.3.1/css/all.min.css" crossorigin="anonymous" referrerpolicy="no-referrer">
346
346
  `;
347
347
  function docUsesIcons(doc) {
348
348
  function visit(node) {
@@ -11,7 +11,7 @@ import {
11
11
  collectInlineIconFamilies,
12
12
  fontAwesomeFaces,
13
13
  fontAwesomeGlyph
14
- } from "./chunk-USU6HTKB.js";
14
+ } from "./chunk-LBXBRFBZ.js";
15
15
  import {
16
16
  fitWithin,
17
17
  readImageDimensions
@@ -20,6 +20,7 @@ import {
20
20
  // src/pdf/export.ts
21
21
  import { PDFDocument, StandardFonts, rgb, PDFString } from "pdf-lib";
22
22
  import fontkit from "@pdf-lib/fontkit";
23
+ import { contrastRatio } from "@bendyline/squisq/schemas";
23
24
  import { docToMarkdown, resolveThemeForDoc } from "@bendyline/squisq/doc";
24
25
  import { readFrontmatterThemeId, sanitizeUrl } from "@bendyline/squisq/markdown";
25
26
 
@@ -477,9 +478,9 @@ async function createExportContext(pdfDoc, options, doc) {
477
478
  if (themeId) {
478
479
  const theme = resolveThemeForDoc(doc, themeId, options.themeRegistry);
479
480
  if (theme.colors) {
480
- colorText = hexToRgb(theme.colors.text) ?? COLOR_TEXT;
481
- colorHeading = hexToRgb(theme.colors.primary) ?? COLOR_HEADING;
482
- colorLink = hexToRgb(theme.colors.highlight || theme.colors.secondary) ?? COLOR_LINK;
481
+ colorText = paperInk(theme.colors.text, COLOR_TEXT);
482
+ colorHeading = paperInk(theme.colors.primary, COLOR_HEADING);
483
+ colorLink = paperInk(theme.colors.highlight || theme.colors.secondary, COLOR_LINK);
483
484
  }
484
485
  }
485
486
  return {
@@ -1172,6 +1173,14 @@ function renderFallbackBlock(node, ctx, extraIndent) {
1172
1173
  ctx.y -= lineH + PARAGRAPH_SPACING;
1173
1174
  }
1174
1175
  }
1176
+ function paperInk(hex, fallback) {
1177
+ const color = hexToRgb(hex);
1178
+ if (!color) return fallback;
1179
+ const tableHeader = "#" + [COLOR_TABLE_HEADER_BG.r, COLOR_TABLE_HEADER_BG.g, COLOR_TABLE_HEADER_BG.b].map(
1180
+ (channel) => Math.round(channel * 255).toString(16).padStart(2, "0")
1181
+ ).join("");
1182
+ return contrastRatio(hex, "#ffffff") >= 4.5 && contrastRatio(hex, tableHeader) >= 4.5 ? color : fallback;
1183
+ }
1175
1184
  function hexToRgb(hex) {
1176
1185
  const h = hex.startsWith("#") ? hex.slice(1) : hex;
1177
1186
  if (h.length !== 6) return void 0;
@@ -58,7 +58,7 @@ import {
58
58
  fontAwesomeFaces,
59
59
  fontAwesomeGlyph,
60
60
  obfuscateDocxFont
61
- } from "./chunk-USU6HTKB.js";
61
+ } from "./chunk-LBXBRFBZ.js";
62
62
  import {
63
63
  extToMime,
64
64
  fitWithin,
@@ -55,7 +55,7 @@ import {
55
55
  fontAwesomeFace,
56
56
  fontAwesomeFaces,
57
57
  fontAwesomeGlyph
58
- } from "./chunk-USU6HTKB.js";
58
+ } from "./chunk-LBXBRFBZ.js";
59
59
  import {
60
60
  extToMime
61
61
  } from "./chunk-RSU3V5IQ.js";
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  convert,
3
3
  defaultRegistry
4
- } from "./chunk-SZDCCL6O.js";
4
+ } from "./chunk-YEV3P7PN.js";
5
5
  import {
6
6
  ConversionError
7
7
  } from "./chunk-KXOZMWBS.js";