3.45. kink/doc/model/BLOCK

Provides blocks in sections of docs.

A block is either a paragraph block or a preformatted code block.

3.45.1. BLOCK.new_paragraph(Text)

new_paragraph makes a paragraph block.

Precondition:

• Text must be a str matching the pattern “[^\u0000-\u0020\u007f]([^\u0000-\u001f\u007f]*[^\u0000-\u0020\u007f])?”

3.45.2. BLOCK.new_code(Text)

new_code makes a code block.

Precondition:

• Text must be a str matching the pattern “([^\u0000-\u001f\u007f]*\n)+”

3.45.3. BLOCK.is?(Val)

BLOCK.is? returns whether Val is a block.

3.45.4. type block

A block is a text block in a section of a doc page.

Block.text

Block.text returns the text of the block.

Block.paragraph?

Block.paragraph? returns whether the Block is a paragraph block.

Block.code?

Block.code? returns whether the Block is a code block.

Block.to_json_val

Block.to_json_val converts the block to a JSON val.

Example:

:BLOCK.require_from('kink/doc/model/')

:Para <- BLOCK.new_paragraph('hey!')
stdout.print_line(Para.to_json_val.repr)
# => Flat_map("text" "hey!"; "type" "paragraph")

:Code <- BLOCK.new_code("1 + 2\n")
stdout.print_line(Code.to_json_val.repr)
# => Flat_map("text" "1 + 2\n"; "type" "code")

Block.op_eq(Another_block)

Two blocks are equal when they are of the same variant (paragraph or code), and have the same text.