File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Filter options
Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
Original file line number Diff line number Diff line change
1
+ [
2
+ {
3
+ "_key" : " e5b6e416e6e9" ,
4
+ "_type" : " block" ,
5
+ "children" : [
6
+ { "_key" : " 3bbbff0f158b" , "_type" : " span" , "marks" : [], "text" : " resers" }
7
+ ],
8
+ "level" : 1 ,
9
+ "listItem" : " bullet" ,
10
+ "markDefs" : [],
11
+ "style" : " normal"
12
+ },
13
+ {
14
+ "_key" : " 73405dda68e0" ,
15
+ "_type" : " extraInfoBlock" ,
16
+ "extraInfo" : " This informations is not supported by Block" ,
17
+ "markDefs" : [],
18
+ "style" : " normal"
19
+ }
20
+ ]
Original file line number Diff line number Diff line change 1
1
import html
2
2
import json
3
3
from pathlib import Path
4
+ from typing import Optional
4
5
5
6
import pytest
6
7
7
8
from portabletext_html .renderer import MissingSerializerError , UnhandledNodeError , render
9
+ from portabletext_html .types import Block
10
+
11
+
12
+ def extraInfoSerializer (node : dict , context : Optional [Block ], list_item : bool ) -> str :
13
+ extraInfo = node .get ('extraInfo' )
14
+
15
+ return f'<p>{ extraInfo } </p>'
8
16
9
17
10
18
def load_fixture (fixture_name ) -> dict :
@@ -59,3 +67,10 @@ def test_invalid_node():
59
67
fixture = load_fixture ('invalid_node.json' )
60
68
with pytest .raises (UnhandledNodeError ):
61
69
render (fixture )
70
+
71
+
72
+ def test_custom_serializer_node_after_list ():
73
+ fixture = load_fixture ('custom_serializer_node_after_list.json' )
74
+ output = render (fixture , custom_serializers = {'extraInfoBlock' : extraInfoSerializer })
75
+
76
+ assert output == '<div><ul><li>resers</li></ul><p>This informations is not supported by Block</p></div>'
You can’t perform that action at this time.
0 commit comments