Skip to content

Papercut 0.5.0

Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 30 Oct 01:03
· 110 commits to main since this release

Added

  • Syntax-highlighted code blocks: CodeBlock::make($code)->language('php') in PHP and <x-doc::pre language="php"> in Blade, coloured by a TextMate theme (default papercut-light; theme, or CodeHighlighting(theme: ...)). Highlighting uses the optional phiki/phiki; without it, or for an unknown language, the block is plain text, and an unknown theme is highlighted with the default one; each is reported as dropped highlighting (strict mode throws).
  • Code block labels: the language's name in capitals by default, label="..." for your own text, false to hide it. text, plaintext, txt and plain give a TEXT label with no colours; nohighlight and no-highlight give neither.
  • Code block looks: the default label line, variant="strip" (label in a header bar) and variant="caption" (label above the box, rule on the left), with code-block* named styles. Word export writes shaded paragraphs or tables; HTML writes <pre><code> with coloured spans.
  • PhikiHighlighter::grammar(), theme(), alias() and injection() register your own TextMate grammars, themes, aliases and VS Code style injection grammars; Laravel reads them from papercut.code.{theme,variant,grammars,themes,aliases,injections}.
  • <pre><code class="language-x"> in Markup::html() and <x-doc::markup> becomes a code block. MarkupOptions(code: false) or papercut.markup.highlight = false keeps the plain pre.

Changed

  • In Word, two horizontal rules in a row are now two rules, as in the PDF, instead of one.

Fixed

  • A table whose columns don't fit its box even at their narrowest no longer runs into the margin or off the page. The widest auto and fr columns (and the length columns of a table from Markup::html()) are narrowed to a shared width and long words in them break across lines. No column gets narrower than its content can go (cell padding plus its widest letter; a fixed-width box or a nested table keeps the width it needs, while images, SVGs and imported PDF pages scale down). This is reported as approximated, with how much more room the table needed. A table that still can't fit, such as one with hand-set length columns wider than its box, throws LayoutOverflow in throw mode instead of only warning; clip mode draws it too wide and warns, as before. A header or footer that is laid out only to look ahead, and never drawn, doesn't throw or report. Word export uses the same column widths and reports each table at its own path.
  • Body text containing papercut-shd- no longer makes Word export throw.
  • In Word, a kept-together table (or a kept-together box that Word draws as a table) now stays on one page. Before, each row stayed whole but the table could still break between rows.
  • Headings now keep with the block after them, as the docs say. A heading is no longer left alone at the bottom of a page when a keep-together block, table or code block after it moves to the next page. In Word the heading paragraph gets keep-with-next, and in HTML break-after: avoid. Turn it off on one heading with keepWithNext(false). When a heading and the block after it can't fit on one page together, the heading still ends up alone.