File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed
Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,17 @@ Text Formatting
3535
3636 The builder supports keyboard shortcuts using the standard ``:kbd: `` role: Press :kbd: `Ctrl + C ` to copy, :kbd: `Ctrl + V ` to paste.
3737
38+ Line Blocks
39+ ~~~~~~~~~~~~
40+
41+ .. rest-example ::
42+
43+ The builder supports line blocks using pipe characters to preserve line breaks:
44+
45+ | This is a line block
46+ | with multiple lines
47+ | preserved exactly as written
48+
3849Admonitions
3950~~~~~~~~~~~
4051
Original file line number Diff line number Diff line change @@ -225,6 +225,15 @@ def _process_rich_text_node(child: nodes.Node) -> Text:
225225 raise ValueError (unsupported_child_type_msg )
226226
227227
228+ @beartype
229+ @_process_rich_text_node .register
230+ def _ (child : nodes .line ) -> Text :
231+ """
232+ Process line nodes by creating rich text.
233+ """
234+ return _create_styled_text_from_node (child = child )
235+
236+
228237@beartype
229238@_process_rich_text_node .register
230239def _ (child : nodes .reference ) -> Text :
@@ -1497,6 +1506,23 @@ def _(
14971506 return []
14981507
14991508
1509+ @beartype
1510+ @_process_node_to_blocks .register
1511+ def _ (
1512+ node : nodes .line_block ,
1513+ * ,
1514+ section_level : int ,
1515+ ) -> list [Block ]:
1516+ """
1517+ Process line block nodes by creating separate paragraph blocks for each
1518+ line.
1519+ """
1520+ del section_level
1521+
1522+ line_text = _create_rich_text_from_children (node = node )
1523+ return [UnoParagraph (text = line_text )]
1524+
1525+
15001526@beartype
15011527class NotionTranslator (NodeVisitor ):
15021528 """
Original file line number Diff line number Diff line change @@ -3076,3 +3076,32 @@ def test_embed_and_video(
30763076 # We explain in the README that this is necessary.
30773077 confoverrides = {"suppress_warnings" : ["app.add_directive" ]},
30783078 )
3079+
3080+
3081+ def test_line_block (
3082+ * ,
3083+ make_app : Callable [..., SphinxTestApp ],
3084+ tmp_path : Path ,
3085+ ) -> None :
3086+ """
3087+ Line blocks (created with pipe character) become empty Notion paragraph
3088+ blocks.
3089+ """
3090+ rst_content = """
3091+ | This is a line block
3092+ | with multiple lines
3093+ | preserved exactly as written
3094+ """
3095+
3096+ expected_objects : list [Block ] = [
3097+ UnoParagraph (text = text (text = "This is a line block" )),
3098+ UnoParagraph (text = text (text = "with multiple lines" )),
3099+ UnoParagraph (text = text (text = "preserved exactly as written" )),
3100+ ]
3101+
3102+ _assert_rst_converts_to_notion_objects (
3103+ rst_content = rst_content ,
3104+ expected_objects = expected_objects ,
3105+ make_app = make_app ,
3106+ tmp_path = tmp_path ,
3107+ )
You can’t perform that action at this time.
0 commit comments