Text::...Blocks(3pm)

πŸŽ€ Text::WikiFormat::Blocks β€” the blocktypes for Text::WikiFormat πŸŽ€

okay bestie, welcome to the little module that does the blocky part of Text::WikiFormat. This is a page from the User Contributed Perl Documentation section of the manual, and it's lowkey just here to tell you what a "block" is and what it can do. πŸ’…


✨ NAME ✨

Text::WikiFormat::Blocks β€” blocktypes for Text::WikiFormat


🌸 SYNOPSIS 🌸

None. Like, actually none. Use Text::WikiFormat as the public interface, bestie β€” unless you're feeling main character energy and want to create your own block type. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

So this module merely creates subclasses of Text::WikiFormat::Block, which is where the actually interesting code lives. No cap.

And what even is a block? A block is a collection of related lines, bestie. Like:

  • a code block β€” text you display verbatim in a monospaced font πŸ’»
  • a header
  • an unordered list
  • an ordered list
  • a paragraph β€” text you display in a proportional font

Every block extends Text::WikiFormat::Block. Every single one. Fr fr.


πŸ’– METHODS πŸ’–

The following methods exist, and yes we're going through all of them:

  • new( %args ) β€” Creates and returns a new block. πŸŽ€ The valid arguments are:
    • text β€” the text of the line found in the block.
    • args β€” the arguments captured by the block-identifying regular expression.
    • level β€” the level of indentation for the block (usually only useful for list blocks).
    • tags β€” the tags in effect for the current type of wiki formatting.
    • opts β€” the options in effect for the current type of wiki formatting.

Use the accessors of the same names to retrieve the values of the attributes. iykyk.

  • add_text( @lines_of_text ) β€” Adds a list of lines of text to the current text for the block. This is very useful when you encounter a block and want to merge it with the previous block of the same type. 🌈
  • add_args( @arguments ) β€” Adds further arguments to the block; useful when merging blocks.
  • formatted_text() β€” Returns text formatted appropriately for this block. Blocks don't have to have formatters, but they may. πŸ™ˆ
  • formatter( $line_of_text ) β€” Formats the $line using Text::WikiFormat::format_line(). You can add your own formatter here; this is worth overriding. ✨
  • merge( $next_block ) β€” Merges the current block with $next_block (the next block encountered) if they're of the same type and are at the same level. This adds the text and args of $next_block to the current block.
⚠️ It's your responsibility to remove $next_block from whatever your code iterates over. Not the module's. Yours. πŸ’€
  • nests() β€” Returns true if this block should nest (as in lists and unordered lists) for the active wiki formatting.
  • nest( $next_block ) β€” Nests $next_block under this block if they both nest and if $next_block has a level greater than the current block. This actually adds $next_block as a text item within the current block.
🚨 Beware. That's it. That's the whole warning. Beware.

πŸ‘‘ AUTHOR πŸ‘‘

chromatic, chromatic at wgz dot org


πŸ’€ BUGS πŸ’€

No known bugs. We ate and left no crumbs. πŸ“


Copyright (c) 2006, chromatic. Some rights reserved.

This module is free software; you can use, redistribute, and modify it under the same terms as Perl 5.8.x. 🫢


and that's the whole page, bestie β€” this was perl v5.40.1, dated 2025-04-07, from the Text::...Blocks(3pm) corner of the manual. slay, go build a block type πŸ’–βœ¨

πŸ“¦ where this page comes from