notionary 0.1.21__py3-none-any.whl → 0.1.22__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,21 +15,25 @@ Notion supports standard Markdown with some special extensions for creating rich
15
15
 
16
16
  {element_docs}
17
17
 
18
- Important usage guidelines:
18
+ CRITICAL USAGE GUIDELINES:
19
19
 
20
20
  1. Do NOT start content with a level 1 heading (# Heading). In Notion, the page title is already displayed in the metadata, so starting with an H1 heading is redundant. Begin with H2 (## Heading) or lower for section headings.
21
21
 
22
- 2. The backtick code fence syntax (```) should ONLY be used when creating actual code blocks or diagrams.
23
- Do not wrap examples or regular content in backticks unless you're showing code.
22
+ 2. BACKTICK HANDLING - EXTREMELY IMPORTANT:
23
+ NEVER wrap entire content or responses in triple backticks (```).
24
+ ❌ DO NOT use triple backticks (```) for anything except CODE BLOCKS or DIAGRAMS.
25
+ ❌ DO NOT use triple backticks to mark or highlight regular text or examples.
26
+ ✅ USE triple backticks ONLY for actual programming code, pseudocode, or specialized notation.
27
+ ✅ When showing Markdown syntax examples, use inline code formatting with single backticks.
24
28
 
25
29
  3. Use inline formatting (bold, italic, etc.) across all content to enhance readability.
26
- Proper typography is essential for creating scannable, well-structured documents.
30
+ Proper typography is essential for creating scannable, well-structured documents.
27
31
 
28
32
  4. Notion's extensions to Markdown provide richer formatting options than standard Markdown
29
- while maintaining the familiar Markdown syntax for basic elements.
33
+ while maintaining the familiar Markdown syntax for basic elements.
30
34
 
31
35
  5. Always structure content with clear headings, lists, and paragraphs to create visually appealing
32
- and well-organized documents.
36
+ and well-organized documents.
33
37
  """
34
38
 
35
39
  @staticmethod
@@ -14,7 +14,7 @@ class BlockElementRegistry:
14
14
  """
15
15
  Initialize a new registry instance.
16
16
  """
17
- self._elements = []
17
+ self._elements: List[NotionBlockElement] = []
18
18
 
19
19
  if elements:
20
20
  for element in elements:
@@ -33,6 +33,12 @@ class BlockElementRegistry:
33
33
  self._elements.remove(element_class)
34
34
  return True
35
35
  return False
36
+
37
+ def contains(self, element_class: Type[NotionBlockElement]) -> bool:
38
+ """
39
+ Check if the registry contains the specified element class.
40
+ """
41
+ return element_class in self._elements
36
42
 
37
43
  def clear(self):
38
44
  """Clear the registry completely."""
@@ -35,7 +35,11 @@ class PageContentManager(LoggingMixin):
35
35
  async def append_markdown(self, markdown_text: str) -> str:
36
36
  """
37
37
  Append markdown text to a Notion page, automatically handling content length limits.
38
+ First strips out triple backtick markdown fences if they wrap the entire content.
38
39
  """
40
+ # Strip out triple backticks if they wrap the entire content
41
+ markdown_text = self._strip_wrapping_backticks(markdown_text)
42
+
39
43
  try:
40
44
  blocks = self._markdown_to_notion_converter.convert(markdown_text)
41
45
 
@@ -172,3 +176,25 @@ class PageContentManager(LoggingMixin):
172
176
  async def get_text(self) -> str:
173
177
  blocks = await self.get_page_blocks_with_children()
174
178
  return self._notion_to_markdown_converter.convert(blocks)
179
+
180
+ def _strip_wrapping_backticks(self, text: str) -> str:
181
+ """
182
+ Strip out triple backticks if they wrap the entire content.
183
+ This prevents LLM-generated markdown fences from breaking the Notion import.
184
+
185
+ Args:
186
+ text: The markdown text that might be wrapped in backticks
187
+
188
+ Returns:
189
+ The text with wrapping backticks removed, if present
190
+ """
191
+ lines = text.strip().split('\n')
192
+
193
+ if len(lines) >= 2:
194
+ first_line = lines[0].strip()
195
+ last_line = lines[-1].strip()
196
+
197
+ if first_line.startswith('```') and last_line == '```':
198
+ return '\n'.join(lines[1:-1])
199
+
200
+ return text
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notionary
3
- Version: 0.1.21
3
+ Version: 0.1.22
4
4
  Summary: A toolkit to convert between Markdown and Notion blocks
5
5
  Home-page: https://github.com/mathisarends/notionary
6
6
  Author: Mathis Arends
@@ -26,8 +26,8 @@ notionary/elements/todo_lists.py,sha256=gyktOvG1tSQvta_SjDauowfP__woJ9ySUHzwMwlN
26
26
  notionary/elements/toggle_element.py,sha256=UZvvOeVlayMCoXi5bvYTreMq9-3W4TrP6Gs2uUJ8qsE,8149
27
27
  notionary/elements/video_element.py,sha256=37KzUkbUrxXgIxbhrq0iDAR_Mr-q7b4FlLTn7IonoKg,5513
28
28
  notionary/elements/prompts/element_prompt_content.py,sha256=DL60MqTLKSaSIT0AoByArw-L__glCkSf9y08oSpTLaE,666
29
- notionary/elements/prompts/synthax_prompt_builder.py,sha256=PBK4s9KhfzqsJN6KtRkk9re1sHGpxjFBx7-ueid-Q2s,3707
30
- notionary/elements/registry/block_element_registry.py,sha256=8SXhrDsuxg60W9NcLzb33nhq3rYY4E0OuHoMVPMlu0E,3325
29
+ notionary/elements/prompts/synthax_prompt_builder.py,sha256=6HcsigTShoGZclXjDfvruXDrjUCtU-8FokGO17JdMbw,4012
30
+ notionary/elements/registry/block_element_registry.py,sha256=-SZSOz0ZBkToII948KtOge4bYQ0vhKG8ywHyCz7y8Mo,3574
31
31
  notionary/elements/registry/block_element_registry_builder.py,sha256=N5SqUqSxDoNDxg4iOwCu9KsfTYj_KD0832oNpwS-pSw,9042
32
32
  notionary/exceptions/database_exceptions.py,sha256=I-Tx6bYRLpi5pjGPtbT-Mqxvz3BFgYTiuZxknJeLxtI,2638
33
33
  notionary/exceptions/page_creation_exception.py,sha256=4v7IuZD6GsQLrqhDLriGjuG3ML638gAO53zDCrLePuU,281
@@ -36,7 +36,7 @@ notionary/page/notion_page.py,sha256=pJSy-vWFqQdCqmtFifL9AdUZpWoM0DzfblRBBBUTsTI
36
36
  notionary/page/notion_page_factory.py,sha256=UUEZ-cyEWL0OMVPrgjc4vJdcplEa1bO2yHCYooACYC8,8189
37
37
  notionary/page/notion_to_markdown_converter.py,sha256=qZIeZjDpeGFgW5RGTrcfi0mVI6NT0VvXeHM7jpP6ZHo,8067
38
38
  notionary/page/content/notion_page_content_chunker.py,sha256=xRks74Dqec-De6-AVTxMPnXs-MSJBzSm1HfJfaHiKr8,3330
39
- notionary/page/content/page_content_manager.py,sha256=gOynb6VTPsczD_HnjogUwslWYra0u1BEC5L-iMKIML4,6126
39
+ notionary/page/content/page_content_manager.py,sha256=wMWE-y28txVU8F1nyHFwvz2kVQZ88aJnZfeZkqlSl7M,7132
40
40
  notionary/page/metadata/metadata_editor.py,sha256=61uiw8oB25O8ePhytoJvZDetuof5sjPoM6aoHZGo4wc,4949
41
41
  notionary/page/metadata/notion_icon_manager.py,sha256=ixZrWsHGVpmF05Ncy9LCt8vZlKAQHYFZW-2yI5JZZDI,1426
42
42
  notionary/page/metadata/notion_page_cover_manager.py,sha256=qgQxQE-bx4oWjLFUQvpXD5GzO1Mx7w7htz1xC2BOqUg,1717
@@ -51,8 +51,8 @@ notionary/page/relations/page_database_relation.py,sha256=F9aGXFjjL8ZLNbfTGeGm_Q
51
51
  notionary/page/relations/relation_operation_result.py,sha256=NDxBzGntOxc_89ti-HG8xDSqfY6PwyGHKHrrKbCzNjM,5010
52
52
  notionary/util/logging_mixin.py,sha256=fKsx9t90bwvL74ZX3dU-sXdC4TZCQyO6qU9I8txkw_U,1369
53
53
  notionary/util/page_id_utils.py,sha256=EYNMxgf-7ghzL5K8lKZBZfW7g5CsdY0Xuj4IYmU8RPk,1381
54
- notionary-0.1.21.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
55
- notionary-0.1.21.dist-info/METADATA,sha256=M7rUxxRbiAwAfAaNorGjJuSMbnkqahMTSYa_gLOkd5A,8342
56
- notionary-0.1.21.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
57
- notionary-0.1.21.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
58
- notionary-0.1.21.dist-info/RECORD,,
54
+ notionary-0.1.22.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
55
+ notionary-0.1.22.dist-info/METADATA,sha256=Rw8x6s2AjB4gpC9bPCXMerdZ9PSeLOj1p3cf83A_ZcI,8342
56
+ notionary-0.1.22.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
57
+ notionary-0.1.22.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
58
+ notionary-0.1.22.dist-info/RECORD,,