4.44. kink/doc/model/BLOCK

Provides blocks in sections of docs.

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

4.44.1. type block

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

4.44.1.1. Block.text

Block.text returns the text of the block.

4.44.1.2. Block.type

`type` returns the type of `Block`.

The result is "paragraph", "code", or "heading".

4.44.1.3. 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")

4.44.1.4. Block.op_eq(Another_block)

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

4.44.2. BLOCK.new_paragraph(Text)

`new_paragraph` makes a block whose type is "paragraph".

Precondition:

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

4.44.3. BLOCK.new_code(Text)

`new_code` makes a block whose type is "code".

Precondition:

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

4.44.4. BLOCK.new_heading(Text)

`new_heading` makes a block whose type is "heading".

Precondition:

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

4.44.5. BLOCK.is?(Val)

BLOCK.is? returns whether Val is a block.