Skip to content

Commit 604231f

Browse files
committed
Update README.md
1 parent b936df8 commit 604231f

File tree

1 file changed

+37
-66
lines changed

1 file changed

+37
-66
lines changed

README.md

Lines changed: 37 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,66 +9,39 @@ Check the following example on how this parser will translate a Discord message:
99
![image](https://user-images.githubusercontent.com/1405498/131235730-94ba8100-2b42-492f-9479-bbce80c592f0.png)
1010

1111
```python
12-
(
13-
{'node_type': 'ITALIC',
14-
'children': (
15-
{'node_type': 'TEXT', 'text_content': 'italic star single'},
16-
)},
17-
18-
{'node_type': 'TEXT', 'text_content': '\n'},
19-
20-
{'node_type': 'ITALIC',
21-
'children': (
22-
{'node_type': 'TEXT', 'text_content': 'italic underscore single'},
23-
)},
24-
25-
{'node_type': 'TEXT', 'text_content': '\n'},
26-
27-
{'node_type': 'BOLD',
28-
'children': (
29-
{'node_type': 'TEXT', 'text_content': 'bold single'},
30-
)},
31-
32-
{'node_type': 'TEXT', 'text_content': '\n'},
33-
34-
{'node_type': 'UNDERLINE',
35-
'children': (
36-
{'node_type': 'TEXT', 'text_content': 'underline single'},
37-
)},
38-
39-
{'node_type': 'TEXT', 'text_content': '\n'},
40-
41-
{'node_type': 'STRIKETHROUGH',
42-
'children': (
43-
{'node_type': 'TEXT', 'text_content': 'strikethrough single'},
44-
)},
45-
46-
{'node_type': 'TEXT', 'text_content': '\n\n'},
47-
48-
{'node_type': 'QUOTE_BLOCK',
49-
'children': (
50-
{'node_type': 'TEXT', 'text_content': 'quote\nblock\n'},
51-
)},
52-
53-
{'node_type': 'TEXT', 'text_content': '\n'},
54-
55-
{'node_type': 'CODE_INLINE',
56-
'children': (
57-
{'node_type': 'TEXT', 'text_content': 'inline code'},
58-
)},
59-
60-
{'node_type': 'TEXT', 'text_content': '\n\n'},
61-
62-
{'node_type': 'QUOTE_BLOCK',
63-
'children': (
64-
{'node_type': 'CODE_BLOCK',
65-
'code_lang': 'python',
66-
'children': (
67-
{'node_type': 'TEXT',
68-
'text_content': 'code\nblock\nwith\npython\nhighlighting\n'},),
69-
},
70-
)},
71-
)
12+
[
13+
{'node_type': 'ITALIC', 'content': 'italic star single', 'children': [
14+
{'node_type': 'TEXT', 'content': 'italic star single', 'children': []}
15+
]},
16+
{'node_type': 'TEXT', 'content': '\n', 'children': []},
17+
{'node_type': 'ITALIC', 'content': 'italic underscore single', 'children': [
18+
{'node_type': 'TEXT', 'content': 'italic underscore single', 'children': []}
19+
]},
20+
{'node_type': 'TEXT', 'content': '\n', 'children': []},
21+
{'node_type': 'BOLD', 'content': 'bold single', 'children': [
22+
{'node_type': 'TEXT', 'content': 'bold single', 'children': []}
23+
]},
24+
{'node_type': 'TEXT', 'content': '\n', 'children': []},
25+
{'node_type': 'UNDERLINE', 'content': 'underline single', 'children': [
26+
{'node_type': 'TEXT', 'content': 'underline single', 'children': []}
27+
]},
28+
{'node_type': 'TEXT', 'content': '\n', 'children': []},
29+
{'node_type': 'STRIKETHROUGH', 'content': 'strikethrough single', 'children': [
30+
{'node_type': 'TEXT', 'content': 'strikethrough single', 'children': []}
31+
]},
32+
{'node_type': 'TEXT', 'content': '\n\n', 'children': []},
33+
{'node_type': 'QUOTE_BLOCK', 'content': 'quote\nblock\n', 'children': [
34+
{'node_type': 'TEXT', 'content': 'quote\nblock\n', 'children': []}
35+
]},
36+
{'node_type': 'TEXT', 'content': '\n', 'children': []},
37+
{'node_type': 'CODE_INLINE', 'content': 'inline code', 'children': [
38+
{'node_type': 'TEXT', 'content': 'inline code', 'children': []}
39+
]},
40+
{'node_type': 'TEXT', 'content': '\n\n', 'children': []},
41+
{'node_type': 'QUOTE_BLOCK', 'content': '```py\ncode\nblock\nwith\npython\nhighlighting\n```', 'children': [
42+
{'node_type': 'CODE_BLOCK', 'content': 'code\nblock\nwith\npython\nhighlighting\n', 'code_lang': 'py', 'children': []}
43+
]}
44+
]
7245
```
7346

7447
### Installation
@@ -105,9 +78,7 @@ QUOTE_BLOCK
10578
- can not contain another quote block (Discord has no nested quotes)
10679
10780
CODE_BLOCK
108-
- fields: "children", "code_lang" "content"
109-
- can only contain a single TEXT node, all other markdown syntax inside the code block
110-
is ignored
81+
- fields: "code_lang" "content"
11182
- may or may not have a language specifier
11283
- first newline is stripped according to the same rules that the Discord client uses
11384
@@ -183,9 +154,6 @@ with how it's rendered in the Discord client:
183154
- `***bold and italic***` will be detected as bold-only with extra stars.
184155
This only happens when the italic and bold stars are right next to each other.
185156
This does not happen when mixing bold stars with italic underscores.
186-
- `*italic with whitespace before star closer *`
187-
will be detected as italic even though the Discord client won't.
188-
Note that Discord doesn't have this weird requirement for `_underscore italic_`.
189157
- ````
190158
||spoilers around
191159
```
@@ -197,3 +165,6 @@ with how it's rendered in the Discord client:
197165
client will only show spoiler bars before and after the code segment, but not on top
198166
of it.
199167
- Custom parsers are experimental, tends to work for different pair of values.
168+
- The URL matching scheme of Discord is quite complex and not fully understood, so there
169+
might be some edge cases where the parser doesn't recognize a URL that the Discord
170+
client does, and vice versa.

0 commit comments

Comments
 (0)