notionary 0.2.3__py3-none-any.whl → 0.2.5__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.
@@ -114,14 +114,6 @@ class CodeBlockElement(NotionBlockElement):
114
114
  {
115
115
  "type": "text",
116
116
  "text": {"content": content},
117
- "annotations": {
118
- "bold": False,
119
- "italic": False,
120
- "strikethrough": False,
121
- "underline": False,
122
- "code": False,
123
- "color": "default",
124
- },
125
117
  "plain_text": content,
126
118
  }
127
119
  ],
@@ -25,6 +25,7 @@ class PageContentRetriever(LoggingMixin):
25
25
 
26
26
  async def get_page_content(self) -> str:
27
27
  blocks = await self._get_page_blocks_with_children()
28
+ print("blocks", json.dumps(blocks, indent=2))
28
29
  return self._notion_to_markdown_converter.convert(blocks)
29
30
 
30
31
  async def _get_page_blocks_with_children(
@@ -1,5 +1,4 @@
1
- import os
2
- from pathlib import Path
1
+ from textwrap import dedent
3
2
  from typing import Type, List
4
3
  from notionary.elements.notion_block_element import NotionBlockElement
5
4
 
@@ -12,29 +11,46 @@ class MarkdownSyntaxPromptGenerator:
12
11
  and formats them optimally for LLMs.
13
12
  """
14
13
 
15
- def __init__(self):
16
- # Lade das Template aus der Markdown-Datei
17
- self.SYSTEM_PROMPT_TEMPLATE = self._load_template()
18
-
19
- def _load_template(self) -> str:
20
- """
21
- Lädt das Prompt-Template aus der Markdown-Datei.
14
+ SYSTEM_PROMPT_TEMPLATE = dedent(
22
15
  """
23
- current_file = Path(__file__).resolve()
24
- current_dir = current_file.parent
25
- template_path = current_dir / "res" / "notion_syntax_prompt.md"
26
-
27
- try:
28
- with open(template_path, "r", encoding="utf-8") as file:
29
- return file.read()
30
- except FileNotFoundError:
31
- raise FileNotFoundError(
32
- f"Template file not found at {template_path}\n"
33
- f"Current working directory: {os.getcwd()}\n"
34
- f"Script location: {current_file}"
35
- )
36
- except Exception as e:
37
- raise RuntimeError(f"Error loading template file: {e}")
16
+ You are a knowledgeable assistant that helps users create content for Notion pages.
17
+ Notion supports standard Markdown with some special extensions for creating rich content.
18
+
19
+ # Understanding Notion Blocks
20
+
21
+ Notion documents are composed of individual blocks. Each block has a specific type (paragraph, heading, list item, etc.) and format.
22
+ The Markdown syntax you use directly maps to these Notion blocks.
23
+
24
+ {element_docs}
25
+
26
+ CRITICAL USAGE GUIDELINES:
27
+
28
+ 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.
29
+
30
+ 2. INLINE FORMATTING - VERY IMPORTANT:
31
+ ✅ You can use inline formatting within almost any block type.
32
+ ✅ Combine **bold**, _italic_, `code`, and other formatting as needed.
33
+ ✅ Format text to create visual hierarchy and emphasize important points.
34
+ ❌ DO NOT overuse formatting - be strategic with formatting for best readability.
35
+
36
+ 3. BACKTICK HANDLING - EXTREMELY IMPORTANT:
37
+ ❌ NEVER wrap entire content or responses in triple backticks (```).
38
+ ❌ DO NOT use triple backticks (```) for anything except CODE BLOCKS or DIAGRAMS.
39
+ ❌ DO NOT use triple backticks to mark or highlight regular text or examples.
40
+ ✅ USE triple backticks ONLY for actual programming code, pseudocode, or specialized notation.
41
+ ✅ For inline code, use single backticks (`code`).
42
+ ✅ When showing Markdown syntax examples, use inline code formatting with single backticks.
43
+
44
+ 4. BLOCK SEPARATION - IMPORTANT:
45
+ ✅ Use empty lines between different blocks to ensure proper rendering in Notion.
46
+ ✅ For major logical sections, use the spacer element (see documentation below).
47
+ ⚠️ While headings can sometimes work without an empty line before the following paragraph, including empty lines between all block types ensures consistent rendering.
48
+
49
+ 5. CONTENT FORMATTING - CRITICAL:
50
+ ❌ DO NOT include introductory phrases like "I understand that..." or "Here's the content...".
51
+ ✅ Provide ONLY the requested content directly without any prefacing text or meta-commentary.
52
+ ✅ Generate just the content itself, formatted according to these guidelines."""
53
+ )
38
54
 
39
55
  @staticmethod
40
56
  def generate_element_doc(element_class: Type[NotionBlockElement]) -> str:
@@ -91,7 +107,5 @@ class MarkdownSyntaxPromptGenerator:
91
107
  """
92
108
  Generates a complete system prompt for LLMs.
93
109
  """
94
- # Erstelle eine Instanz, um das Template zu laden
95
- instance = cls()
96
110
  element_docs = cls.generate_element_docs(element_classes)
97
- return instance.SYSTEM_PROMPT_TEMPLATE.format(element_docs=element_docs)
111
+ return cls.SYSTEM_PROMPT_TEMPLATE.format(element_docs=element_docs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: notionary
3
- Version: 0.2.3
3
+ Version: 0.2.5
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
@@ -8,7 +8,7 @@ notionary/elements/audio_element.py,sha256=7bEpFl9jA6S1UZlEXsmFzEUVoViEp1o_7zZIC
8
8
  notionary/elements/bookmark_element.py,sha256=msCtZvuPkIj1kiShNwE8i1GDYwamFb5mwRyZm4XyVY4,8145
9
9
  notionary/elements/bulleted_list_element.py,sha256=obsb3JqUNET3uS5OZM3yzDqxSzJzUuEob-Fzx0UIg9Y,2664
10
10
  notionary/elements/callout_element.py,sha256=ZsRvRtVy9kxdTwgrB5JGjZ4qcCiwcC0WimWJ_cW0aLY,4492
11
- notionary/elements/code_block_element.py,sha256=IbwpptMLtHDFO0Hyvt2o0p5AZ0S4vhxfzoBhTqKexSY,6240
11
+ notionary/elements/code_block_element.py,sha256=Zy5l8bsX2R1QBgmCZDM_tkxzSXylHABshKY8r0kNBBo,5853
12
12
  notionary/elements/divider_element.py,sha256=0e10YK-CC8uGuL7921dEIjeJK9ha-WhRIYRf2fFuxVQ,2211
13
13
  notionary/elements/embed_element.py,sha256=Zcc18Kl8SGoG98P2aYE0TkBviRvSz-sYOdjMEs-tvgk,4579
14
14
  notionary/elements/heading_element.py,sha256=kqgjyfaawEODir2tzDyf7-7wm38DbqoZnsH5k94GsA0,3013
@@ -36,7 +36,7 @@ notionary/page/notion_page.py,sha256=NDxAJaNk4tlKUrenhKBdnuvjlVgnxC0Z6fprf2LyNeE
36
36
  notionary/page/notion_page_factory.py,sha256=2A3M5Ub_kV2-q7PPRqDgfwBjhkGCwtL5i3Kr2RfvvVo,7213
37
37
  notionary/page/notion_to_markdown_converter.py,sha256=vUQss0J7LUFLULGvW27PjaTFuWi8OsRQAUBowSYorkM,6408
38
38
  notionary/page/content/notion_page_content_chunker.py,sha256=xRks74Dqec-De6-AVTxMPnXs-MSJBzSm1HfJfaHiKr8,3330
39
- notionary/page/content/page_content_retriever.py,sha256=btVWarx06KZ2A2ZRxNpNEvkeYwyyI2tnM8dKWSkiQGQ,2235
39
+ notionary/page/content/page_content_retriever.py,sha256=i6y4Q3_5EIzsd6HRgO3G-v1STZs1060OJe5DFkZi-QI,2290
40
40
  notionary/page/content/page_content_writer.py,sha256=czBzNCGcwdpqNLSQPyna1s8Y7pjyPzDgJC3UUK5PLGA,3793
41
41
  notionary/page/metadata/metadata_editor.py,sha256=HI7m8Zn_Lz6x36rBnW1EnbicVS-4Q8NmCJYKN-OlY-c,5130
42
42
  notionary/page/metadata/notion_icon_manager.py,sha256=6a9GS5sT0trfuAb0hlF2Cw_Wc1oM59a1QA4kO9asvMA,2576
@@ -49,12 +49,12 @@ notionary/page/relations/notion_page_relation_manager.py,sha256=tfkvLHClaYel_uEa
49
49
  notionary/page/relations/notion_page_title_resolver.py,sha256=dIjiEeHjjNT-DrIhz1nynkfHkMpUuJJFOEjb25Wy7f4,3575
50
50
  notionary/page/relations/page_database_relation.py,sha256=8lEp8fQjPwjWhA8nZu3k8mW6EEc54ki1Uwf4iUV1DOU,2245
51
51
  notionary/prompting/element_prompt_content.py,sha256=tHref-SKA81Ua_IQD2Km7y7BvFtHl74haSIjHNYE3FE,4403
52
- notionary/prompting/markdown_syntax_prompt_generator.py,sha256=N6t9FHS_4IP9L5-zFpTM6iS7E-QJvoe7muPwEnF3UgQ,3352
52
+ notionary/prompting/markdown_syntax_prompt_generator.py,sha256=0hD2DZDDjQ3ZKHPvZnDKpUs6Puq5O_E2IGW1te1R6v4,4751
53
53
  notionary/util/logging_mixin.py,sha256=b6wHj0IoVSWXbHh0yynfJlwvIR33G2qmaGNzrqyb7Gs,1825
54
54
  notionary/util/page_id_utils.py,sha256=EYNMxgf-7ghzL5K8lKZBZfW7g5CsdY0Xuj4IYmU8RPk,1381
55
55
  notionary/util/warn_direct_constructor_usage.py,sha256=vyJR73F95XVSRWIbyij-82IGOpAne9SBPM25eDpZfSU,1715
56
- notionary-0.2.3.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
57
- notionary-0.2.3.dist-info/METADATA,sha256=5GDY-SZ4tVpUd_3KdQo6jNWMc7PCv4sQWHuAhnL3ALs,8374
58
- notionary-0.2.3.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
59
- notionary-0.2.3.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
60
- notionary-0.2.3.dist-info/RECORD,,
56
+ notionary-0.2.5.dist-info/licenses/LICENSE,sha256=zOm3cRT1qD49eg7vgw95MI79rpUAZa1kRBFwL2FkAr8,1120
57
+ notionary-0.2.5.dist-info/METADATA,sha256=QT7PBlbv3Qu6BqzamzrxZnf28zwZp43_IgBa4F3uCwo,8374
58
+ notionary-0.2.5.dist-info/WHEEL,sha256=DnLRTWE75wApRYVsjgc6wsVswC54sMSJhAEd4xhDpBk,91
59
+ notionary-0.2.5.dist-info/top_level.txt,sha256=fhONa6BMHQXqthx5PanWGbPL0b8rdFqhrJKVLf_adSs,10
60
+ notionary-0.2.5.dist-info/RECORD,,