En poques paraules
Un quadern legislatiu breu. Mostra la redacció antiga d'uns articles amb les paraules suprimides ratllades i les noves subratllades, i després l'article sencer ja reformat en un requadre gris.
Què compondràs
Un quadern de text comparat com els que preparen els serveis de les Cambres: cinc pàgines amb les tres reformes de la Constitució Espanyola publicades al BOE, la de l'article 13.2 el 1992, la del 135 el 2011 i la del 49 el 2024. Cada llei de reforma copia l'article nou sencer i no diu què canvia; aquí la redacció de 1978 i la vigent van en un sol text, amb el que se suprimeix ratllat i el que s'afegeix subratllat, sota una clau que explica la convenció. Al final, l'article 135 vigent es llegeix en un requadre tintat, cada número d'apartat a la vora i el seu text penjat. L'edició anglesa fa el mateix amb la llei nord-americana de 1998 que va allargar vint anys els terminis del dret d'autor.
Aquesta recepta respon a
- Com mostro una modificació amb les paraules suprimides ratllades i les afegides subratllades?
La resposta curta
// In the text, ~~fifty~~ strikes a deleted word and :underline[70] underlines the new one.
// Both lines are painted from the face's own metrics and take no room, so the struck and
// the inserted words justify and hyphenate like any others. The amended text then sits in
// a box whose paragraphs hang: '(a)', a tab, and every turnover line under the text.
const label = { fontFamily: SANS, fontSize: pt(7.5), fontWeight: 700, letterSpacing: pt(1.1),
textTransform: 'uppercase', color: col('accent') };
const clauses = { fontFamily: SERIF, fontSize: pt(9.5), lineHeight: pt(13), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), textAlign: 'left', // a box's measure is short
hangingIndent: HANG, // every line but the first starts 7 mm in (postext ≥ 1.71)
tabStops: [{ position: HANG }] }; // and the tab after the marker takes the text there
const pad = (v, h) => ({ top: mm(v), right: mm(h), bottom: mm(v), left: mm(h) });
const calloutStyles = [
// The coding legend: a red rule down its side, the label face.
{ id: 'legend', backgroundEnabled: false,
stripe: { enabled: true, side: 'left', width: pt(2.5), color: col('accent') },
padding: pad(1.5, 3.5), body: { fontFamily: SANS, fontSize: pt(9), lineHeight: pt(12.5),
color: col('ink'), boldColor: col('accent'), firstLineIndent: pt(0), textAlign: 'left' } },
// The bill's own words: a red rule on top, clauses hung, no tint.
{ id: 'bill', backgroundEnabled: false,
stripe: { enabled: true, side: 'top', width: pt(2.5), color: col('accent') },
padding: pad(2.5, 0), body: clauses, keepTogether: false, // it may run on to the next page
// its title keeps its case: "(b)" stays "(b)"
titleStyle: { ...label, textTransform: 'none', letterSpacing: pt(0.2), fontSize: pt(8.5),
color: col('ink') } },
// The text as amended: a tint, the clauses hung the same way.
{ id: 'amended', background: col('tint'), padding: pad(3.5, 4.5), titleStyle: label,
body: clauses },
];
Ingredients
- Funcions
- RatllatSubratllatParàgrafs amb sagnat francès en un requadreTabuladors i farcimentsRequadresRequadres que es parteixen o noPaleta de color semànticaObertures dissenyadesAtributs de títolCapçaleres i folisCapçaleres segons el tipus de pàginaMarges simètricsEstils de paràgrafVídues, òrfenes i línies curtesExportació a PDFFonts incrustades al PDF
- Tipografia
- Source Serif 4, Source Sans 3 (SIL OFL 1.1)
- Recursos
- Cap: totes les imatges es dibuixen en codi
Elaboració
#1 · El canvi es marca on passa
El codi és la resposta curta de més amunt. Les marques són al Markdown: ~~El Gobierno habrá~~ :underline[El Estado y las Comunidades Autónomas habrán] ratlla l'antic i subratlla el nou (ratllat, subratllat). Cap de les dues línies no ocupa lloc, així que l'article 49 de 1978, ratllat sencer a la pàgina 3, es justifica i es divideix com el text que l'envolta. Cada línia surt de les mesures de ratllat i subratllat de la mateixa font, en el color de les paraules.
#2 · Els apartats pengen dins del requadre
body.hangingIndent en un estil de requadre penja tots els seus paràgrafs (tipografia dins d'un requadre): la primera línia comença a la vora interior i les següents 7 mm més endins. Un tabulador a aquests mateixos 7 mm porta el text que segueix el número fins a aquesta vora, sigui quina sigui l'amplada del número, així que al Markdown escrius 1.:tab Todas las Administraciones…. Els paràgrafs sense número d'un apartat comencen per :tab i queden alineats amb el text penjat. Els dos requadres comparteixen la tipografia i només canvia el marc: un filet vermell sobre el text de la llei de reforma, una tinta darrere del text vigent.
#3 · Una banda per a l'obertura
const at = (to, edge, x = 0, y = 0) => ({ anchor: { to, edge }, offset: { x: mm(x), y: mm(y) } });
const BAND = 66; // mm from the trim top to the foot of the band
const opener = { enabled: true, minHeight: mm(BAND - 22 + 6), marginBottom: pt(0), slot: {
elements: [
{ kind: 'box', id: 'band', style: { backgroundColor: col('band') },
placement: { ...at('bleed', 'top-left'), size: { width: 'fill', height: mm(BAND + 3) } } },
{ kind: 'text', id: 'kicker', content: '{attr.kicker}', ...label, color: col('pale'),
placement: { ...at('container', 'top-left', 0, 6), size: { width: mm(112) } } },
{ kind: 'text', id: 'title', content: '{titleText}', fontFamily: SERIF, fontWeight: 700,
fontSize: pt(30), lineHeight: 1.05, color: col('paper'), align: 'left',
placement: { ...at('#kicker', 'below', 0, 3), size: { width: mm(112), height: 'auto' } } },
{ kind: 'text', id: 'dek', content: '{attr.dek}', fontFamily: SERIF, italic: true,
fontSize: pt(10.5), lineHeight: 1.3, color: col('pale'), align: 'left',
placement: { ...at('#title', 'below', 0, 3.5), size: { width: mm(104), height: 'auto' } } },
] } };
La banda blau marí surt a sang per dalt i pels costats, i l'avanttítol i l'entradeta surten d'atributs de la línia del títol (atributs de títol). minHeight fixa on comença la clau, uns mil·límetres sota la banda.
#4 · Capçaleres segons la paritat
const head = (id, content, parity, edge, x, extra = {}) => ({
kind: 'text', id, content, parity, pages: 'body', fontFamily: SANS, fontSize: pt(7.5),
fontWeight: 600, letterSpacing: pt(1.1), textTransform: 'uppercase', color: col('muted'),
placement: { anchor: { to: 'page', edge }, offset: { x: mm(x), y: mm(13) } }, ...extra });
const folio = { fontWeight: 700, color: col('ink') };
const header = { elements: [
head('verso-folio', '{pageNumber}', 'even', 'top-left', OUTER, folio),
head('verso-title', '{title}', 'even', 'top-left', OUTER + 8),
head('recto-title', '{firstMark.h2}', 'odd', 'top-right', -(OUTER + 8)),
head('recto-folio', '{pageNumber}', 'odd', 'top-right', -OUTER, folio),
] };
const footer = { elements: [head('drop-folio', '{pageNumber}', 'all', 'top', 0,
{ ...folio, pages: 'opener', placement: at('container', 'top', 0, 9) })] };
La pàgina parella porta el títol del quadern i la senar la part en què s'obre, llegida del primer títol de segon nivell de la pàgina. pages: 'body' les deixa fora de l'obertura, que porta un foli al peu.
La recepta completa
// ═══ Postext Cookbook · Nº 182 · An amendment shown struck through and underlined ═════
// https://postext.dev/en/cookbook/amendment-redline
// Code: MIT · Text: Pub. L. 105-298 and 17 U.S.C. (US Gov., PD); Constitución Española (BOE)
// Fonts: Source Serif 4, Source Sans 3 (SIL OFL 1.1) · Needs postext ≥ 1.73.0
// A comparative print: the law as it stood, each deletion ~~struck through~~ and each
// insertion :underline[underlined], then the amended text in a box whose clauses hang.
import { buildDocumentWithFonts, renderPageToCanvas } from 'https://esm.sh/postext';
import { renderToPdf, decompressWoff2 } from 'https://esm.sh/postext-pdf';
const LANG = 'es'; // @lang: the language of the sample document ('en' | 'es')
const RECIPE = 'amendment-redline';
// ─── 1 · Design ─────────────────────────────────────────────────────────────
// #region palette: a government-print navy, one red for rules and labels
const palette = {
ink: '#1b1d22', // text: a cool near-black
band: '#1f2b47', // the opener's band: navy
accent: '#a1321f', // labels, stripes, the legend's rule
tint: '#eef0f4', // the box of the amended text
rule: '#c7ccd6', // hairlines
muted: '#5d6370', // running heads, notes, colophon
paper: '#ffffff',
pale: '#c9d2e6', // the kicker and the standfirst on the band
};
const col = (id) => ({ hex: palette[id], model: 'hex', paletteId: id });
const colorPalette = [
...Object.entries(palette).map(([id, hex]) => ({ id, name: id, value: { hex, model: 'hex' } })),
{ id: 'main-color', name: 'accent (defaults)', value: { hex: palette.accent, model: 'hex' } },
];
// #endregion
const SERIF = 'Source Serif 4', SANS = 'Source Sans 3';
const TRIM = [152, 229], INNER = 20, OUTER = 17; // mm: a 6 × 9 in committee print
const LEAD = 14; // pt: the body leading
const HANG = mm(7); // how far the clauses of a box hang: the width of "(a)" and a space
// #region answer: the marks live in the Markdown; the boxes hang their clauses
// In the text, ~~fifty~~ strikes a deleted word and :underline[70] underlines the new one.
// Both lines are painted from the face's own metrics and take no room, so the struck and
// the inserted words justify and hyphenate like any others. The amended text then sits in
// a box whose paragraphs hang: '(a)', a tab, and every turnover line under the text.
const label = { fontFamily: SANS, fontSize: pt(7.5), fontWeight: 700, letterSpacing: pt(1.1),
textTransform: 'uppercase', color: col('accent') };
const clauses = { fontFamily: SERIF, fontSize: pt(9.5), lineHeight: pt(13), color: col('ink'),
boldColor: col('ink'), italicColor: col('ink'), textAlign: 'left', // a box's measure is short
hangingIndent: HANG, // every line but the first starts 7 mm in (postext ≥ 1.71)
tabStops: [{ position: HANG }] }; // and the tab after the marker takes the text there
const pad = (v, h) => ({ top: mm(v), right: mm(h), bottom: mm(v), left: mm(h) });
const calloutStyles = [
L'script.js compost funciona tal com és: enganxa'l com a script de mòdul en qualsevol pàgina o obre la recepta a CodePen. Carpeta de la recepta a GitHub ↗ (s'obre en una pestanya nova)
Variants
#Escriu el que s'afegeix com ++text++
Amb plusUnderline activat, ++y pasivo++ subratlla igual que :underline[y pasivo], la grafia que Pandoc i markdown-it fan servir per al text inserit.
textAlign: 'justify', firstLineIndent: mm(4.5), indentAfterHeading: false,
+ plusUnderline: true, // ++text++ subratlla; C++ al text s'escriu llavors C\+\+#Mantén sencer el requadre de la llei de reforma
Sense keepTogether: false el requadre passa sencer a la pàgina següent quan no hi cap, i la pàgina anterior acaba a la línia que el presenta.
- padding: pad(2.5, 0), body: clauses, keepTogether: false, // it may run on to the next page
+ padding: pad(2.5, 0), body: clauses,Errors freqüents
- Un paràgraf que comença per un número i un punt (
2. Solamente…) es llegeix com un element de llista, i una barra inversa davant del punt s'imprimeix. Aquesta edició posa un unidor de paraules (U+2060) entre la xifra i el punt al text corregut, i al requadre escriu el tabulador just darrere del punt,1.:tab, que no obre cap llista. - El color sol no sobreviu a una fotocòpia, que és com solen circular aquests quaderns; el ratllat i el subratllat es llegeixen en blanc i negre, i per això els van triar els redactors.
Crèdits
- Recepta
- Ignacio Ferro
- Text
- Section 102 of the Sonny Bono Copyright Term Extension Act (Pub. L. 105-298, 112 Stat. 2827, 1998) and sections 302–304 of title 17, United States Code, as in force in 1997 · United States Congress · domini públic
- Articles 13.2, 49 and 135 of the Spanish Constitution in their 1978 wording and the reforms of 1992, 2011 and 2024 (official texts, not subject to copyright under art. 13 LPI) · Cortes Generales, Boletín Oficial del Estado · domini públic
- The editor’s notes, the coding legends and the colophons · Ignacio Ferro · CC BY 4.0
- Fonts
- Source Serif 4 (SIL OFL 1.1) · Source Sans 3 (SIL OFL 1.1)
- Codi
- MIT, com Postext
Editar aquest text ↗ (s'obre en una pestanya nova)Carpeta de la recepta a GitHub ↗ (s'obre en una pestanya nova)


