# madbot_cli.editor

*module*

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.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L1-1)

## madbot_cli.editor.LINK

*attribute* · *module attribute*

```python
LINK = re.compile('<a href="([^"]*)"[^>]*>(.*?)</a>')
```

A link of an EditorJS text: its address is part of the text compared.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L22-22)

## madbot_cli.editor.MD_BOLD

*attribute* · *module attribute*

```python
MD_BOLD = re.compile('\\*\\*([^\\*]+)\\*\\*')
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L26-26)

## madbot_cli.editor.MD_CHECKBOX

*attribute* · *module attribute*

```python
MD_CHECKBOX = re.compile('^\\[([x ])\\]\\s+(.+)$')
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L33-33)

## madbot_cli.editor.MD_CODE

*attribute* · *module attribute*

```python
MD_CODE = re.compile('`([^`]+)`')
```

The inline Markdown madbot turns into HTML in a paragraph or a quote.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L28-28)

## madbot_cli.editor.MD_HEADER

*attribute* · *module attribute*

```python
MD_HEADER = re.compile('^(#{1,6})\\s+(.+)$')
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L31-31)

## madbot_cli.editor.MD_ITALIC

*attribute* · *module attribute*

```python
MD_ITALIC = re.compile('\\*([^\\*]+)\\*')
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L27-27)

## madbot_cli.editor.MD_LINK

*attribute* · *module attribute*

```python
MD_LINK = re.compile('\\[([^\\]]+)\\]\\(([^\\)]+)\\)')
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L25-25)

## madbot_cli.editor.MD_LIST

*attribute* · *module attribute*

```python
MD_LIST = re.compile('^(\\s*)([-*]|\\d+\\.)\\s+(.+)$')
```

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L32-32)

## madbot_cli.editor.MD_SEPARATOR

*attribute* · *module attribute*

```python
MD_SEPARATOR = re.compile('^-+$')
```

The lines madbot reads as a header, a list item, a checkbox or a table rule.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L34-34)

## madbot_cli.editor.QUOTE_PREFIXES

*attribute* · *module attribute*

```python
QUOTE_PREFIXES = ('💡 ', 'ℹ️ ')
```

The marks of a call-out and of details, which madbot keeps as a variant.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L37-37)

## madbot_cli.editor.TAGS

*attribute* · *module attribute*

```python
TAGS = re.compile('</?[A-Za-z][^<>]*>')
```

The inline HTML of an EditorJS text, such as ``<b>``; not a ``<`` of the text.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L19-19)

## madbot_cli.editor.block_texts

*function*

```python
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**

- `block` (`Any`) — The block.
- `links` (`bool`) (default: `False`) — Keep the address of each link after its text, as ``text (address)``.

**Returns**

- (`list of str`) — Its texts, without their inline HTML.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L89-124)

## madbot_cli.editor.blocks_of

*function*

```python
def blocks_of(value: Any) -> list | None
```

Give the blocks of an EditorJS object, or of its JSON string.

**Parameters**

- `value` (`Any`) — A value of a metadata field.

**Returns**

- (`list or None`) — The blocks; None when the value is not an EditorJS text.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L41-62)

## madbot_cli.editor.code_text

*function*

```python
def code_text(lines: list[str], i: int) -> tuple[str, int]
```

Read a block of code of Markdown, as madbot keeps it.

**Parameters**

- `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.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L193-213)

## madbot_cli.editor.editor_text

*function*

```python
def editor_text(value: Any) -> str | None
```

Give the plain text of an EditorJS object or of its JSON string.

**Parameters**

- `value` (`Any`) — A value of a metadata field.

**Returns**

- (`str or None`) — Its blocks as paragraphs, separated by a blank line; None when the value is not an EditorJS text.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L127-145)

## madbot_cli.editor.inline_text

*function*

```python
def inline_text(text: str) -> str
```

Remove the inline Markdown madbot turns into HTML, as its text reads once saved.

**Parameters**

- `text` (`str`) — A paragraph or a quote of a file.

**Returns**

- (`str`) — The text, a link as ``text (address)``.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L173-190)

## madbot_cli.editor.item_texts

*function*

```python
def item_texts(items: Any) -> list[str]
```

Give the texts of the items of an EditorJS list, nested items included.

**Parameters**

- `items` (`Any`) — The ``items`` of a list block.

**Returns**

- (`list of str`) — The text of each item, then of its own items.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L65-86)

## madbot_cli.editor.markdown_texts

*function*

```python
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**

- `text` (`str`) — The text of a file.

**Returns**

- (`list of str`) — The texts of the blocks madbot would make.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L261-315)

## madbot_cli.editor.plain

*function*

```python
def plain(value: Any) -> Any
```

Put the plain text in place of every EditorJS text of a value.

**Parameters**

- `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.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L148-170)

## madbot_cli.editor.quote_text

*function*

```python
def quote_text(line: str) -> str
```

Read a quote of Markdown, without its mark of a call-out or of details.

**Parameters**

- `line` (`str`) — The line, starting with ``>``.

**Returns**

- (`str`) — Its text, as madbot keeps it.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L242-258)

## madbot_cli.editor.same

*function*

```python
def same(current: Any, value: Any) -> bool
```

Tell 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.

**Parameters**

- `current` (`Any`) — The value madbot holds.
- `value` (`Any`) — The value of the file.

**Returns**

- (`bool`) — True when they are the same, editor texts compared by their words.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L346-378)

## madbot_cli.editor.table_texts

*function*

```python
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**

- `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.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L216-239)

## madbot_cli.editor.words

*function*

```python
def words(value: Any) -> str | None
```

Give 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**

- `value` (`Any`) — An EditorJS object, its JSON string, or a text of a file.

**Returns**

- (`str or None`) — The text; None when the value is not a text.

[View source](https://gitlab.com/ifb-elixirfr/madbot/madbot/-/blob/c7108faae5e7dd06591be53c8d5bd5e75d880ebe/cli/madbot_cli/editor.py#L318-343)
