retype icon indicating copy to clipboard operation
retype copied to clipboard

H2 should not page-break-before

Open DannyBen opened this issue 4 months ago • 1 comments

This new (?) CSS is too opinionated in how H2s are used throughout the document.

@media print {
  .retype-markdown h2 {
    page-break-before: always;
  }
}

Even the Retype site itself does not benefit from this setting.

Just the first example I tried: https://retype.com/guides/key-setup/

yields this (first 3 pages):

Image

This CSS should be removed in my opinion, and if there are any style customizations exposed in the Settings, it could be opt-in there.


For the time being, I am solving it with this include file (which also disables the unsolicited centering of the H1).

<!-- src/_includes/head.html -->
<style>
  @media print {
    /* Stop H1 from being centered */
    .retype-markdown h1 {
      text-align: start !important; /* follows document direction */
    }

    /* Stop H2 from starting a new page */
    .retype-markdown h2 {
      break-before: avoid-page !important;   /* modern */
      page-break-before: avoid !important;   /* legacy */
    }

    /* keep the heading with the first block after it */
    .retype-markdown h2 + * {
      break-inside: avoid !important;        /* modern */
      page-break-inside: avoid !important;   /* legacy */
    }
  }
</style>

DannyBen avatar Sep 07 '25 11:09 DannyBen

Thanks for report. We will remove the text-align on the H1, remove the break-before on the H2, and we will add break-inside: avoid to the H2.

These enhancements will be included in the next release of Retype.

geoffreymcgill avatar Sep 08 '25 19:09 geoffreymcgill