title: Re-displaying the current heading after a page break
body: <p>I'm creating a document with WeasyPrint.
  I have sections that have names, some of which might span across multiple pages.
  When a section is too long, a page break occurs. What I am trying to do is to re-display the current section's name, ideally with the same formatting.</p>
  
  <p>The following MWE shows how the section title is not displayed after a page break:</p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;h1&gt;First section&lt;/h1&gt;
          &lt;p&gt;Lorem ipsum...&lt;/p&gt;
          &lt;p&gt;Lorem ipsum...&lt;/p&gt;
          &lt;p&gt;Lorem ipsum...&lt;/p&gt;
          &lt;p&gt;Lorem ipsum...&lt;/p&gt;
  
          &lt;p style="break-after: always;"&gt;&lt;/p&gt;
  
          &lt;p&gt;Lorem ipsum...&lt;/p&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Output of <code>weasyprint example.html example.pdf</code>:</p>
  
  <p><a href="https://i.stack.imgur.com/3muuJ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/3muuJ.png" alt="enter image description here"></a></p>
  
  <p>I want <code>First section</code> to be displayed, as a <code>&lt;h1&gt;</code> tag, at the top on the left page.</p>
  
  <p>I would like to do as <a href="https://tex.stackexchange.com/questions/47646/re-displaying-section-headings-after-page-breaks">this tex.stackexchange</a> post which, as I understand it, basically consists in checking if the current page number exceeds the current total page count, and if it does, inserting the last section title encountered.</p>
  
  <p>I'm not aware of the possibility to do so in HTML, does it exist?
  Is there any workaround to do this? If not, is it possible to have WeasyPrint execute custom Python code on some <code>page-break</code> hook?</p>