madbot_cli.editor
Read the texts written in the editor of madbot, such as a description, as plain text.
madbot keeps such a text as an EditorJS object ({"blocks": [...]}), while
a deposit file gives it as a text, which madbot reads as Markdown on write
(**bold** becomes <b>bold</b>, - a a list). fields writes the
plain text, the checks read it, and plan compares the words of both sides
without the markup, so that the values match once applied.
Attributes
| Name | Description |
|---|---|
LINK | A link of an EditorJS text: its address is part of the text compared. |
MD_BOLD | No description. |
MD_CHECKBOX | No description. |
MD_CODE | The inline Markdown madbot turns into HTML in a paragraph or a quote. |
MD_HEADER | No description. |
MD_ITALIC | No description. |
MD_LINK | No description. |
MD_LIST | No description. |
MD_SEPARATOR | The lines madbot reads as a header, a list item, a checkbox or a table rule. |
QUOTE_PREFIXES | The marks of a call-out and of details, which madbot keeps as a variant. |
TAGS | The inline HTML of an EditorJS text, such as <b>; not a < of the text. |
Functions
| Name | Description |
|---|---|
block_texts | Give the texts of one EditorJS block: a paragraph, a header, a list, code or a table. |
blocks_of | Give the blocks of an EditorJS object, or of its JSON string. |
code_text | Read a block of code of Markdown, as madbot keeps it. |
editor_text | Give the plain text of an EditorJS object or of its JSON string. |
inline_text | Remove the inline Markdown madbot turns into HTML, as its text reads once saved. |
item_texts | Give the texts of the items of an EditorJS list, nested items included. |
markdown_texts | Give the texts madbot keeps of a text of a file, which it reads as Markdown. |
plain | Put the plain text in place of every EditorJS text of a value. |
quote_text | Read a quote of Markdown, without its mark of a call-out or of details. |
same | Tell whether madbot already holds the value of the file. |
table_texts | Read a table of Markdown: the cells of each row, without its rule. |
words | Give the text of an editor value as plan compares it: without markup, spaces folded. |
LINKattributemodule attribute#
LINK = re.compile('<a href="([^"]*)"[^>]*>(.*?)</a>')A link of an EditorJS text: its address is part of the text compared.
MD_BOLDattributemodule attribute#
MD_BOLD = re.compile('\\*\\*([^\\*]+)\\*\\*')MD_CHECKBOXattributemodule attribute#
MD_CHECKBOX = re.compile('^\\[([x ])\\]\\s+(.+)$')MD_CODEattributemodule attribute#
MD_CODE = re.compile('`([^`]+)`')The inline Markdown madbot turns into HTML in a paragraph or a quote.
MD_HEADERattributemodule attribute#
MD_HEADER = re.compile('^(#{1,6})\\s+(.+)$')MD_ITALICattributemodule attribute#
MD_ITALIC = re.compile('\\*([^\\*]+)\\*')MD_LINKattributemodule attribute#
MD_LINK = re.compile('\\[([^\\]]+)\\]\\(([^\\)]+)\\)')MD_LISTattributemodule attribute#
MD_LIST = re.compile('^(\\s*)([-*]|\\d+\\.)\\s+(.+)$')MD_SEPARATORattributemodule attribute#
MD_SEPARATOR = re.compile('^-+$')The lines madbot reads as a header, a list item, a checkbox or a table rule.
QUOTE_PREFIXESattributemodule attribute#
QUOTE_PREFIXES = ('💡 ', 'ℹ️ ')The marks of a call-out and of details, which madbot keeps as a variant.
TAGSattributemodule attribute#
TAGS = re.compile('</?[A-Za-z][^<>]*>')The inline HTML of an EditorJS text, such as <b>; not a < of the text.
block_textsfunction#
def block_texts(block: Any, *, links: bool = False) -> list[str]Give the texts of one EditorJS block: a paragraph, a header, a list, code or a table.
Parameters
Returns
list of str- Its texts, without their inline HTML.
blocks_offunction#
def blocks_of(value: Any) -> list | NoneGive the blocks of an EditorJS object, or of its JSON string.
Parameters
| Name | Type | Description |
|---|---|---|
value | Any | A value of a metadata field. |
code_textfunction#
def code_text(lines: list[str], i: int) -> tuple[str, int]Read a block of code of Markdown, as madbot keeps it.
Parameters
| Name | Type | Description |
|---|---|---|
lines | list of str | The lines of the text. |
i | int | The line after the opening fence. |
Returns
tuple- The code, and the line after the closing fence.
editor_textfunction#
def editor_text(value: Any) -> str | NoneGive the plain text of an EditorJS object or of its JSON string.
Parameters
| Name | Type | Description |
|---|---|---|
value | Any | A value of a metadata field. |
inline_textfunction#
def inline_text(text: str) -> strRemove the inline Markdown madbot turns into HTML, as its text reads once saved.
Parameters
| Name | Type | Description |
|---|---|---|
text | str | A paragraph or a quote of a file. |
Returns
str- The text, a link as
text (address).
item_textsfunction#
def item_texts(items: Any) -> list[str]Give the texts of the items of an EditorJS list, nested items included.
Parameters
| Name | Type | Description |
|---|---|---|
items | Any | The items of a list block. |
Returns
list of str- The text of each item, then of its own items.
markdown_textsfunction#
def markdown_texts(text: str) -> list[str]Give the texts madbot keeps of a text of a file, which it reads as Markdown.
Follows how madbot turns Markdown into EditorJS: a header, a list item or a table cell keeps its text as written, a paragraph or a quote loses its inline Markdown.
Parameters
| Name | Type | Description |
|---|---|---|
text | str | The text of a file. |
Returns
list of str- The texts of the blocks madbot would make.
plainfunction#
def plain(value: Any) -> AnyPut the plain text in place of every EditorJS text of a value.
Parameters
| Name | Type | Description |
|---|---|---|
value | Any | A value of a metadata field, such as a list of descriptions each with its language. |
Returns
Any- The same value, its editor texts as plain text.
quote_textfunction#
def quote_text(line: str) -> strRead a quote of Markdown, without its mark of a call-out or of details.
Parameters
| Name | Type | Description |
|---|---|---|
line | str | The line, starting with >. |
Returns
str- Its text, as madbot keeps it.
samefunction#
def same(current: Any, value: Any) -> boolTell whether madbot already holds the value of the file.
Only an editor text is compared by its words: any other text must be the same, a space included.
Returns
bool- True when they are the same, editor texts compared by their words.
table_textsfunction#
def table_texts(lines: list[str], i: int) -> tuple[list[str], int]Read a table of Markdown: the cells of each row, without its rule.
Parameters
| Name | Type | Description |
|---|---|---|
lines | list of str | The lines of the text. |
i | int | Its first row. |
Returns
tuple- The text of each row, and the line after the table.
wordsfunction#
def words(value: Any) -> str | NoneGive the text of an editor value as plan compares it: without markup, spaces folded.
madbot may cut a text into paragraphs or lines of its own, and keeps its Markdown as HTML: the text is the same whatever its spaces, its line breaks and its markup.
Parameters
| Name | Type | Description |
|---|---|---|
value | Any | An EditorJS object, its JSON string, or a text of a file. |

