Blocks
INTELMO divides an article into a group of blocks. Developers can perform operations on these blocks and then return a new group of blocks.
What is a block?
A block could be a paragraph, a sentence or a word. It is a basic unit of an article. When INTELMO fetches an article from RSS feeds, it will divide the article into a group of blocks, each of which is a paragraph by default. A block has the following fields:
level
: The level of the block, which could beparagraph
,sentence
orword
. The rendering of a paragraph includes inter-paragraph spacing. INTELMO also provides aglobal
level, which is shown on the top of the reader.type
: Different types of blocks have different styles. For example, a block with typebold
will be rendered in bold.content
: the content of the block, which is a string.children
: a list of blocks. If a block has children, it will be rendered as a container. Otherwise, it will be rendered as a leaf. Details are shown in the Nesting blocks section.
Block(
level="paragraph",
type="bold",
content="Some paragraph content",
children=[]
)
Nesting blocks
As shown above, each block has a children
field, which is a list of blocks or set to empty by default. Developers can nest blocks by setting the children
field. When INTELMO recieves a block with children, it will render the children blocks inside the block itself. Otherwise, it will render the parent block with it's own content and style.
Block(
level="paragraph",
type="bold", # type omitted when children is not empty
content="", # content omitted when children is not empty
children=[
Block(
level="sentence",
type="italic",
content="Here is one sentence.",
children=[] # children can be empty
),
Block(
level="sentence",
type="italic", # type omitted when children is not empty
content="", # content omitted when children is not empty
children=[
Block(
level="word",
type="underline",
content="happy",
children=[]
),
Block(
level="word",
type="normal",
content="dog.",
children=[]
)
]
)
]
)
Available Configurations
Block Level
The level
field of a block can be set to paragraph
, sentence
, word
or global
.
Block Type
Type | Example |
---|---|
"normal" | The quick brown fox jumps over the lazy dog. |
"bold" | The quick brown fox jumps over the lazy dog. |
"italic" | The quick brown fox jumps over the lazy dog. |
"underline" | The quick brown fox jumps over the lazy dog. |
"light" | The quick brown fox jumps over the lazy dog. |
"title" | The quick brown fox jumps over the lazy dog |
"quote" | The quick brown fox jumps over the lazy dog. |