From 387e1b0a16d6c12a09f6ee7dfeff1eca96bf9205 Mon Sep 17 00:00:00 2001 From: Ben Edgington Date: Mon, 16 Jun 2025 12:33:51 +0100 Subject: [PATCH] Introduce spans for wrapping long strings --- bin/pdf/filters/linebreaks.lua | 14 ++++++++++++++ bin/pdf/inc/header.tex | 5 +++++ src/css/page.css | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/bin/pdf/filters/linebreaks.lua b/bin/pdf/filters/linebreaks.lua index f69e073..073803f 100644 --- a/bin/pdf/filters/linebreaks.lua +++ b/bin/pdf/filters/linebreaks.lua @@ -15,3 +15,17 @@ function RawInline (el) end return el end + +-- We now support ... +-- These spans must contain only raw text (or backquoted code), with no nested elements +function Span (span) + if span.classes:includes('wrap') then + if (span.content[1].t == 'Str') then + return pandoc.RawInline('latex', '\\seqsplit{' .. span.content[1].text .. '}') + end + if (span.content[1].t == 'Code') then + return pandoc.RawInline('latex', '\\texttt{\\seqsplit{' .. span.content[1].text .. '}}') + end + end + return span +end diff --git a/bin/pdf/inc/header.tex b/bin/pdf/inc/header.tex index 8195493..1ebb8bb 100644 --- a/bin/pdf/inc/header.tex +++ b/bin/pdf/inc/header.tex @@ -154,3 +154,8 @@ \let\prevsubparagraph\subparagraph \renewcommand{\subparagraph}[1]{\prevsubparagraph{#1}\nopagebreak} \fi + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% Used by linebreaks.lua to split long hexadecimal strings + +\usepackage{seqsplit} diff --git a/src/css/page.css b/src/css/page.css index 1088773..de987b2 100644 --- a/src/css/page.css +++ b/src/css/page.css @@ -86,6 +86,11 @@ code { font-size: 95%; } +/*** Wrapping long lines of hex ***/ +span.wrap { + word-break: break-all; +} + /*** Constant line heights ***/ sup, sub {