snapshot of https://github.com/tldraw/tldraw.git (main, 2026-09-23; blobs > 131072B omitted)
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled
Some checks failed
Deploy analytics worker / Deploy analytics worker to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
i18n upload strings / Upload latest strings (push) Failing after 1s
Deploy bemo / Deploy bemo to ${{ (github.ref == 'refs/heads/bemo-production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Failing after 1s
Deploy grafana resources / ${{ github.event_name == 'push' && 'Deploy grafana resources' || 'Validate grafana resources (dry run)' }} (push) Failing after 0s
End to end tests (dotcom) / Check for relevant changes (push) Failing after 0s
End to end tests (examples) / Check for relevant changes (push) Failing after 0s
End to end tests (mermaid readability) / Check for relevant changes (push) Failing after 1s
End to end tests (perf) / Check for relevant changes (push) Failing after 0s
Publish editor extensions / Publish editor extensions (push) Failing after 1s
Publish SDK packages / Remove the publish-packages label (push) Has been skipped
Checks / Tests & checks (push) Has been cancelled
Checks / Build all projects (push) Has been cancelled
Deploy templates / Deploy templates (push) Has been cancelled
End to end tests (dotcom) / End to end tests (dotcom) (push) Has been cancelled
End to end tests (mermaid readability) / End to end tests (mermaid readability) (push) Has been cancelled
End to end tests (perf) / End to end tests (perf) (push) Has been cancelled
Deploy .com / Deploy dotcom to ${{ (github.ref == 'refs/heads/production' && 'production') || (github.ref == 'refs/heads/main' && 'staging') || 'preview' }} (push) Has been cancelled
End to end tests (examples) / End to end tests (examples) (push) Has been cancelled
Publish SDK packages / Publish SDK packages (push) Has been cancelled
Publish SDK packages / Tell user released version (push) Has been cancelled
Publish SDK packages / Publishes code templates to separate repositories (push) Has been cancelled
Publish SDK packages / Deploys the template demos with the new SDK version (push) Has been cancelled
This commit is contained in:
220
internal/scripts/create-docs-reference.ts
Normal file
220
internal/scripts/create-docs-reference.ts
Normal file
@@ -0,0 +1,220 @@
|
||||
#!/usr/bin/env tsx
|
||||
|
||||
/**
|
||||
* Creates a reference document for Pandoc with custom styling:
|
||||
* - Times New Roman for all prose
|
||||
* - Consolas for all code
|
||||
* - Tighter margins and spacing for density
|
||||
*/
|
||||
|
||||
import { writeFileSync } from 'fs'
|
||||
import { dirname, resolve } from 'path'
|
||||
import {
|
||||
convertInchesToTwip,
|
||||
Document,
|
||||
HeadingLevel,
|
||||
Packer,
|
||||
PageOrientation,
|
||||
Paragraph,
|
||||
TextRun,
|
||||
} from 'docx'
|
||||
import { nicelog } from './lib/nicelog'
|
||||
|
||||
const DOCS_DIR = resolve(dirname(dirname(dirname(__filename))), 'documentation')
|
||||
const REFERENCE_FILE = resolve(DOCS_DIR, 'reference.docx')
|
||||
|
||||
// Font settings
|
||||
const BODY_FONT = 'Times New Roman'
|
||||
const CODE_FONT = 'Consolas'
|
||||
const BODY_SIZE = 22 // 11pt in half-points
|
||||
const CODE_SIZE = 20 // 10pt in half-points
|
||||
const HEADING1_SIZE = 32 // 16pt
|
||||
const HEADING2_SIZE = 28 // 14pt
|
||||
const HEADING3_SIZE = 24 // 12pt
|
||||
|
||||
async function main() {
|
||||
nicelog('📄 Creating reference document for Pandoc...')
|
||||
|
||||
const doc = new Document({
|
||||
styles: {
|
||||
default: {
|
||||
document: {
|
||||
run: {
|
||||
font: BODY_FONT,
|
||||
size: BODY_SIZE,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
after: 120, // 6pt after paragraphs
|
||||
line: 240, // Single line spacing (240 twips = 1 line)
|
||||
},
|
||||
},
|
||||
},
|
||||
heading1: {
|
||||
run: {
|
||||
font: BODY_FONT,
|
||||
size: HEADING1_SIZE,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
before: 240,
|
||||
after: 120,
|
||||
},
|
||||
},
|
||||
},
|
||||
heading2: {
|
||||
run: {
|
||||
font: BODY_FONT,
|
||||
size: HEADING2_SIZE,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
before: 200,
|
||||
after: 100,
|
||||
},
|
||||
},
|
||||
},
|
||||
heading3: {
|
||||
run: {
|
||||
font: BODY_FONT,
|
||||
size: HEADING3_SIZE,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
before: 160,
|
||||
after: 80,
|
||||
},
|
||||
},
|
||||
},
|
||||
heading4: {
|
||||
run: {
|
||||
font: BODY_FONT,
|
||||
size: BODY_SIZE,
|
||||
bold: true,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
before: 120,
|
||||
after: 60,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
paragraphStyles: [
|
||||
{
|
||||
id: 'Normal',
|
||||
name: 'Normal',
|
||||
run: {
|
||||
font: BODY_FONT,
|
||||
size: BODY_SIZE,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
after: 120,
|
||||
line: 240,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'SourceCode',
|
||||
name: 'Source Code',
|
||||
basedOn: 'Normal',
|
||||
run: {
|
||||
font: CODE_FONT,
|
||||
size: CODE_SIZE,
|
||||
},
|
||||
paragraph: {
|
||||
spacing: {
|
||||
after: 0,
|
||||
line: 220,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'VerbatimChar',
|
||||
name: 'Verbatim Char',
|
||||
basedOn: 'Normal',
|
||||
run: {
|
||||
font: CODE_FONT,
|
||||
size: CODE_SIZE,
|
||||
},
|
||||
},
|
||||
],
|
||||
characterStyles: [
|
||||
{
|
||||
id: 'VerbatimChar',
|
||||
name: 'Verbatim Char',
|
||||
run: {
|
||||
font: CODE_FONT,
|
||||
size: CODE_SIZE,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
sections: [
|
||||
{
|
||||
properties: {
|
||||
page: {
|
||||
margin: {
|
||||
top: convertInchesToTwip(0.75),
|
||||
right: convertInchesToTwip(0.75),
|
||||
bottom: convertInchesToTwip(0.75),
|
||||
left: convertInchesToTwip(0.75),
|
||||
},
|
||||
size: {
|
||||
orientation: PageOrientation.PORTRAIT,
|
||||
},
|
||||
},
|
||||
},
|
||||
children: [
|
||||
// Sample content to establish styles
|
||||
new Paragraph({
|
||||
text: 'Heading 1',
|
||||
heading: HeadingLevel.HEADING_1,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: 'Heading 2',
|
||||
heading: HeadingLevel.HEADING_2,
|
||||
}),
|
||||
new Paragraph({
|
||||
text: 'Heading 3',
|
||||
heading: HeadingLevel.HEADING_3,
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: 'Normal body text in Times New Roman.',
|
||||
font: BODY_FONT,
|
||||
size: BODY_SIZE,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
new Paragraph({
|
||||
children: [
|
||||
new TextRun({
|
||||
text: 'const code = "Consolas font";',
|
||||
font: CODE_FONT,
|
||||
size: CODE_SIZE,
|
||||
}),
|
||||
],
|
||||
style: 'SourceCode',
|
||||
}),
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
const buffer = await Packer.toBuffer(doc)
|
||||
writeFileSync(REFERENCE_FILE, buffer)
|
||||
|
||||
nicelog(`✅ Created: ${REFERENCE_FILE}`)
|
||||
nicelog(' Use with: pandoc --reference-doc=documentation/reference.docx')
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
nicelog(`❌ Failed: ${error}`)
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user