@imontene/mdrender 2.5.0 → 2.6.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Cambios
2
2
 
3
+ ## 2.6.0 — 2026-10-22
4
+
5
+ - **Marcas de agua** con el degradado Anti-Gravity, solo en el PDF y desactivadas por defecto:
6
+ - `--watermark <texto>` (o `watermark:`): texto en diagonal en cada página, ajustado al
7
+ tamaño y la orientación de la hoja;
8
+ - `--watermark-field` (o `watermarkField: true`): campo de luz en la esquina de cada página.
9
+
10
+ Van detrás del contenido y funcionan con cualquier tema.
11
+
3
12
  ## 2.5.0 — 2026-10-22
4
13
 
5
14
  - **Nuevo estilo por defecto: Anti-Gravity**, tomado del design system del mismo nombre y
package/README.md CHANGED
@@ -156,6 +156,8 @@ equipo); `--port` fija el puerto y `--no-open` no abre el navegador.
156
156
  | `--no-page-numbers` | Sin el pie con números de página | — |
157
157
  | `--font <manrope\|inter>` | Tipografía del texto (ver abajo) | `manrope` |
158
158
  | `--no-justify` | Párrafos alineados a la izquierda en el PDF (ver abajo) | justificado |
159
+ | `--watermark <texto>` | Marca de agua en diagonal en cada página del PDF, con el degradado Anti-Gravity | — |
160
+ | `--watermark-field` | Campo de luz con el degradado en la esquina de cada página del PDF | — |
159
161
  | `--density <densidad>` | `normal` o `compact` (menos espacio entre líneas y bloques) | `normal` |
160
162
  | `--font-size <tamaño>` | Tamaño del texto en `pt` o `px`, de 6 a 24 pt; p. ej. `10pt` | `10.5pt` |
161
163
  | `--theme <tema\|css>` | `antigravity`, `antigravity-dark`, `light`, `dark` o un `.css` que reemplaza el tema (ver abajo) | `antigravity` |
@@ -195,6 +197,20 @@ del mismo nombre y llevado de diapositivas a páginas:
195
197
  versiones anteriores y `--theme dark` su variante oscura. El design system pide texto alineado
196
198
  a la izquierda: con este tema, usa `--no-justify` si quieres seguirlo al pie de la letra.
197
199
 
200
+ **Marca de agua**: dos marcas con el degradado azul → cian → violeta del design system
201
+ Anti-Gravity, cada una por separado y solo en el PDF:
202
+
203
+ ```bash
204
+ mdrender informe.md --watermark "Borrador" # texto en diagonal en cada página
205
+ mdrender informe.md --watermark-field # campo de luz en la esquina de cada página
206
+ ```
207
+
208
+ También como `watermark: Borrador` y `watermarkField: true` en el front matter o en
209
+ `mdrender.config.json`. Van muy tenues y detrás del contenido: no tapan el texto, y las
210
+ imágenes, tablas y tarjetas quedan por encima. Según la versión de Chrome, el texto de la marca
211
+ puede formar parte del texto del PDF (aparecer al copiar o buscar). Funcionan con cualquier tema
212
+ y son algo más intensas en los oscuros.
213
+
198
214
  **Tipografía**: el texto usa [Manrope](https://fonts.google.com/specimen/Manrope);
199
215
  `--font inter` (o `font: inter` en el front matter o en `mdrender.config.json`) vuelve a
200
216
  [Inter](https://fonts.google.com/specimen/Inter), la tipografía de las versiones anteriores.
package/dist/cli.js CHANGED
@@ -27,6 +27,8 @@ const DOCUMENT_FLAGS = [
27
27
  "pageNumbers",
28
28
  "font",
29
29
  "justify",
30
+ "watermark",
31
+ "watermarkField",
30
32
  "density",
31
33
  "fontSize",
32
34
  "css",
@@ -63,6 +65,8 @@ function addDocumentOptions(command) {
63
65
  .option("--no-page-numbers", "no default page-number footer")
64
66
  .option("--font <font>", "text typeface: manrope or inter (default: manrope)")
65
67
  .option("--no-justify", "align paragraphs left in the PDF instead of justifying them")
68
+ .option("--watermark <text>", "text across every PDF page, in the Anti-Gravity gradient")
69
+ .option("--watermark-field", "a soft field of light in the corner of every PDF page")
66
70
  .option("--density <density>", "normal or compact (tighter spacing) (default: normal)")
67
71
  .option("--font-size <size>", "text size, e.g. 10pt or 11pt (default: 10.5pt)")
68
72
  .option("--theme <theme>", "antigravity, antigravity-dark, light, dark, or a .css file replacing the theme " +
package/dist/convert.js CHANGED
@@ -14,6 +14,7 @@ import { fillMermaid, renderMermaid } from "./render/mermaid.js";
14
14
  import { SMALL_SCALE } from "./render/mermaid-fit.js";
15
15
  import { headerFooterStyle, mermaidThemeVariables } from "./render/antigravity.js";
16
16
  import { FONT_FAMILIES, fontStack } from "./render/fonts.js";
17
+ import { WATERMARK_CSS, watermarkHtml } from "./render/watermark.js";
17
18
  import { contentHeightPx, contentWidthPx, lengthToPx, textWidthPx } from "./render/page.js";
18
19
  import { buildHtmlDocument, builtinThemeCss, densityCss } from "./render/template.js";
19
20
  import { writeFileAtomic } from "./write.js";
@@ -113,6 +114,17 @@ function layoutCss(options, margin) {
113
114
  rules.push(`html { font-size: ${options.fontSize}; }`);
114
115
  return rules.join("\n");
115
116
  }
117
+ /** The watermarks asked for (PDF only), sized to the page's text area. */
118
+ function watermarks(options, margin) {
119
+ const landscape = options.orientation === "landscape";
120
+ return watermarkHtml({
121
+ text: options.watermark,
122
+ field: options.watermarkField,
123
+ widthPx: textWidthPx(options.pageSize, landscape, margin),
124
+ heightPx: contentHeightPx(options.pageSize, landscape, margin),
125
+ dark: isDarkTheme(options.theme),
126
+ });
127
+ }
116
128
  const fixed2 = (n) => n.toFixed(2);
117
129
  /** "Mermaid autofit: wrap 300, turned LR→TB, scale 0.33 → 1.00, height 81 → 903 px". */
118
130
  export function describeLayout(layout) {
@@ -215,6 +227,7 @@ paged = false) {
215
227
  }
216
228
  });
217
229
  }
230
+ const watermark = paged ? watermarks(options, margin) : "";
218
231
  const html = buildHtmlDocument({
219
232
  title,
220
233
  body,
@@ -226,7 +239,12 @@ paged = false) {
226
239
  showTitle: options.title !== undefined,
227
240
  themeCss,
228
241
  font: options.font,
229
- layoutCss: [...densityCss(options.density), layoutCss(options, margin)],
242
+ beforeBody: watermark || undefined,
243
+ layoutCss: [
244
+ ...densityCss(options.density),
245
+ layoutCss(options, margin),
246
+ ...(watermark ? [WATERMARK_CSS] : []),
247
+ ],
230
248
  extraCss,
231
249
  });
232
250
  diagnostics.sort((a, b) => (a.line ?? 0) - (b.line ?? 0));
package/dist/doctor.js CHANGED
@@ -138,6 +138,8 @@ function settingsCheck(options) {
138
138
  `${m.left} (top right bottom left), ${options.font} ` +
139
139
  `${options.fontSize ?? DEFAULT_FONT_SIZE}, ${options.density} density, ` +
140
140
  `${options.justify ? "justified" : "ragged"} paragraphs, ` +
141
+ (options.watermark?.trim() ? `watermark "${options.watermark.trim()}", ` : "") +
142
+ (options.watermarkField ? "watermark field, " : "") +
141
143
  `language ${options.lang}, theme ` +
142
144
  path.basename(options.theme),
143
145
  };
package/dist/options.d.ts CHANGED
@@ -49,6 +49,10 @@ export interface DocumentOptions {
49
49
  mermaidAutofit: boolean;
50
50
  /** Whether autofit may turn a flowchart to the other axis (LR ↔ TB) when it reads far better. */
51
51
  mermaidFlip: MermaidFlip;
52
+ /** Text set diagonally across every page of the PDF, in the Anti-Gravity gradient. */
53
+ watermark?: string;
54
+ /** A soft field of light (the Anti-Gravity gradient) in the corner of every PDF page. */
55
+ watermarkField: boolean;
52
56
  /** Justify paragraphs in the PDF (body, quotes, alerts), breaking long words with hyphens. */
53
57
  justify: boolean;
54
58
  /** Typeface of the text: Manrope or Inter (code is always JetBrains Mono). */
package/dist/options.js CHANGED
@@ -22,6 +22,7 @@ export const DEFAULT_OPTIONS = {
22
22
  mermaidFlip: "auto",
23
23
  font: "manrope",
24
24
  justify: true,
25
+ watermarkField: false,
25
26
  density: "normal",
26
27
  theme: "antigravity",
27
28
  css: [],
@@ -122,6 +123,8 @@ const VALIDATORS = {
122
123
  mermaidFlip: oneOf(MERMAID_FLIPS),
123
124
  font: oneOf(TEXT_FONTS),
124
125
  justify: bool,
126
+ watermark: text,
127
+ watermarkField: bool,
125
128
  density: oneOf(DENSITIES),
126
129
  fontSize,
127
130
  theme: (value, describe, baseDir) => {
@@ -20,6 +20,8 @@ export interface DocumentParts {
20
20
  themeCss?: string[];
21
21
  /** Text font to embed. Defaults to Manrope. */
22
22
  font?: TextFont;
23
+ /** HTML placed before the document body (the watermarks). */
24
+ beforeBody?: string;
23
25
  /** Layout stylesheets (density, font size, page height), applied after the theme. */
24
26
  layoutCss?: string[];
25
27
  /** Extra stylesheet contents, applied after the theme and layout. */
@@ -61,7 +61,7 @@ ${author ? `<meta name="author" content="${escapeHtml(author)}">\n` : ""}<title>
61
61
  ${styles.map((css) => `<style>\n${css}\n</style>`).join("\n")}
62
62
  </head>
63
63
  <body>
64
- <main class="markdown-body">
64
+ ${parts.beforeBody ? parts.beforeBody + "\n" : ""}<main class="markdown-body">
65
65
  ${parts.showTitle ? titleBlock(parts) + "\n" : ""}${body}
66
66
  </main>
67
67
  </body>
@@ -0,0 +1,24 @@
1
+ export interface WatermarkOptions {
2
+ /** Text set across every page; undefined or blank for none. */
3
+ text?: string;
4
+ /** A field of light in the corner of every page. */
5
+ field: boolean;
6
+ /** Size of the text area in CSS px (the text runs along its diagonal). */
7
+ widthPx: number;
8
+ heightPx: number;
9
+ /** Dark page: the marks are a little stronger, as the design system's dark stage. */
10
+ dark: boolean;
11
+ }
12
+ /** Angle (degrees, counter-clockwise) and font size (px) that fit `text` on the diagonal. */
13
+ export declare function diagonalText(text: string, widthPx: number, heightPx: number): {
14
+ angle: number;
15
+ fontSize: number;
16
+ };
17
+ /** HTML of the requested marks, to go before the document body; "" when none is requested. */
18
+ export declare function watermarkHtml(options: WatermarkOptions): string;
19
+ /**
20
+ * Print-only placement: fixed over the text area of every page, under the content (the body
21
+ * becomes a stacking layer above it). Hidden on screen. With the field on every page, the title
22
+ * block's own field (Anti-Gravity) is dropped so the first page does not get two.
23
+ */
24
+ export declare const WATERMARK_CSS: string;
@@ -0,0 +1,86 @@
1
+ import { escapeHtml } from "../html.js";
2
+ /**
3
+ * Watermarks in the Anti-Gravity gradient (field-blue → field-cyan → field-violet), PDF only:
4
+ * a text set diagonally across every page, and a soft field of light in the top-right corner of
5
+ * every page. Both sit behind the content. Chrome repeats a `position: fixed` element on every
6
+ * printed page, at the same place in the text area, so pagination is left alone.
7
+ */
8
+ const FIELD = { blue: "#4f7cff", cyan: "#22c3e6", violet: "#8c6cf0" };
9
+ /** Angle (degrees, counter-clockwise) and font size (px) that fit `text` on the diagonal. */
10
+ export function diagonalText(text, widthPx, heightPx) {
11
+ const angle = (Math.atan2(heightPx, widthPx) * 180) / Math.PI;
12
+ const diagonal = Math.hypot(widthPx, heightPx);
13
+ // Manrope 600 capitals average about 0.68 em; the text takes ~70% of the diagonal.
14
+ const chars = Math.max(1, [...text].length);
15
+ const fontSize = Math.min(heightPx * 0.2, (diagonal * 0.7) / (chars * 0.68));
16
+ return { angle, fontSize: Math.round(fontSize) };
17
+ }
18
+ function textMark(text, widthPx, heightPx, dark) {
19
+ const { angle, fontSize } = diagonalText(text, widthPx, heightPx);
20
+ // HTML rather than SVG text: Chrome paints the SVG text of a fixed element on the first page
21
+ // only, while HTML is repeated on every page like the rest of the element.
22
+ return `<div class="mdr-watermark-text" style="opacity: ${dark ? 0.14 : 0.1}"><span style="font-size: ${fontSize}px; transform: rotate(${(-angle).toFixed(2)}deg)">${escapeHtml(text.toUpperCase())}</span></div>`;
23
+ }
24
+ function fieldMark(dark) {
25
+ // The same three lights as the title block's field (theme-antigravity.css), each fading out
26
+ // inside the box so no edge shows.
27
+ return `<div class="mdr-watermark-field" style="opacity: ${dark ? 0.22 : 0.16}"></div>`;
28
+ }
29
+ /** HTML of the requested marks, to go before the document body; "" when none is requested. */
30
+ export function watermarkHtml(options) {
31
+ const text = options.text?.trim();
32
+ if (!text && !options.field)
33
+ return "";
34
+ const parts = [
35
+ options.field ? fieldMark(options.dark) : "",
36
+ text ? textMark(text, options.widthPx, options.heightPx, options.dark) : "",
37
+ ].filter(Boolean);
38
+ return `<div class="mdr-watermark" aria-hidden="true">\n${parts.join("\n")}\n</div>`;
39
+ }
40
+ /**
41
+ * Print-only placement: fixed over the text area of every page, under the content (the body
42
+ * becomes a stacking layer above it). Hidden on screen. With the field on every page, the title
43
+ * block's own field (Anti-Gravity) is dropped so the first page does not get two.
44
+ */
45
+ export const WATERMARK_CSS = `.mdr-watermark { display: none; }
46
+ @media print {
47
+ .mdr-watermark {
48
+ display: block;
49
+ position: fixed;
50
+ inset: 0;
51
+ z-index: 0;
52
+ pointer-events: none;
53
+ }
54
+ .markdown-body { position: relative; z-index: 1; }
55
+ .mdr-watermark-text {
56
+ position: absolute;
57
+ inset: 0;
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: center;
61
+ }
62
+ .mdr-watermark-text span {
63
+ font-family: var(--font-text);
64
+ font-weight: 600;
65
+ letter-spacing: 0.02em;
66
+ line-height: 1;
67
+ white-space: nowrap;
68
+ color: transparent;
69
+ background: linear-gradient(90deg, ${FIELD.blue}, ${FIELD.cyan}, ${FIELD.violet});
70
+ -webkit-background-clip: text;
71
+ background-clip: text;
72
+ }
73
+ .mdr-watermark-field {
74
+ position: absolute;
75
+ top: 0;
76
+ right: 0;
77
+ width: 40%;
78
+ height: 230px;
79
+ background:
80
+ radial-gradient(28% 38% at 58% 45%, ${FIELD.blue}, transparent),
81
+ radial-gradient(16% 26% at 78% 58%, ${FIELD.cyan}, transparent),
82
+ radial-gradient(25% 30% at 40% 32%, ${FIELD.violet}, transparent);
83
+ }
84
+ .mdr-watermark:has(.mdr-watermark-field) ~ .markdown-body .doc-header::before { display: none; }
85
+ }`;
86
+ //# sourceMappingURL=watermark.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@imontene/mdrender",
3
- "version": "2.5.0",
3
+ "version": "2.6.0",
4
4
  "description": "Command-line app for Windows and Linux that renders Markdown — with LaTeX equations and Mermaid diagrams — to PDF and HTML set in Manrope or Inter",
5
5
  "keywords": [
6
6
  "markdown",