Login
You're viewing the functional.cafe public feed.
  • Nov 16, 2026, 5:44 PM

    Furthermore each iteration of this mainloop reads a chunk from the file exiting if none & hands it over to the XML parser propagating any errors.

    Upon a start element it strips off namespaces, validates tags aren't nested too deeply & that we're not ignoring these descendents, counts <body> tags setting a flag ignoring anything outside, counts section tags handling all but the 1st section specially, <title> starts a new bold paragraph, as does <subtitle> centre-aligned, ...

    3/?

    💬 1🔄 1⭐ 0

Replies

  • Nov 16, 2026, 5:50 PM

    ... <p> begin a new one styling specially specially if its nested in a (sub)title, <emphasis> flushes a word & remembers to make any child italic, as does <code>, <strong> works similarly too, <empty-line> flushes the word & adds whitespace possibly creating a new page, <image> is ignored, & various other block tags work like <empty-line>. For all but the 1st section it flushes the word buffer possibly creating a new page, & possibly invokes a callback while maybe stopping the parsing for now.

    💬 1🔄 1⭐ 0
  • Nov 16, 2026, 5:57 PM

    The callback for closing tags strips namespaces, flushes word buffer for certain tags, decrements a depth counter, clears any relevant properties, ignores anything outside the <body> tag, & branches over the (block) tagname to unset relevant flags & flush buffers.

    The callback for text validates that its in a <body> tag without being nested too deep before iterating over the chars moving non-whitespace over to the word buffer. Upon whitespace or excessively-long word it flushes the word buffer.

    💬 1🔄 1⭐ 0
  • Nov 16, 2026, 6:05 PM

    There's a helper for enqueueing validated non-empty words into the current text-block in Unicode NFC form laying out Arabic right-to-left. There's a helper to (unless we're aborting) open a new text block, or set the text-style on the existing one if empty possibly creating a new page. There's a helper for appending a new line of text to the layout possibly creating a new page so it fits, checking how many pages it has rendered against a limit.

    5/6

    💬 1🔄 1⭐ 0
  • Nov 16, 2026, 6:07 PM

    There's that helper for creating pages by flushing the current buffer, starting a new page if none's open, retrieving line height, text-wrapping that block with a callback carefully propagating to that other helper, & updates layout properties depending on whether we've hit a page limit & the configured spacing level.

    There's a helper checking flags to determine the appropriate font variant. And there's a helper to calculate the position of a given line of text.

    6/6 Fin for today! Next: HTML!

    💬 0🔄 1⭐ 0