dknowc-dsh 1.0.3 → 1.1.0
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.
- package/README.md +9 -4
- package/package.json +2 -2
- package/skills/dknowc-official-doc-writer/SKILL.md +17 -8
- package/skills/dknowc-official-doc-writer/reference/sample_search_result.md +48 -0
- package/skills/dknowc-official-doc-writer/reference/sample_trace_report.html +75 -0
- package/skills/dknowc-official-doc-writer/reference/search_intro.md +72 -8
- package/skills/dknowc-official-doc-writer/scripts/register.mjs +1 -1
- package/skills/dknowc-ppt-assistant/README.md +54 -0
- package/skills/dknowc-ppt-assistant/SKILL.md +151 -0
- package/skills/dknowc-ppt-assistant/THIRD_PARTY_NOTICES.md +36 -0
- package/skills/dknowc-ppt-assistant/official-docs/output/.gitkeep +0 -0
- package/skills/dknowc-ppt-assistant/official-docs/search-results/.gitkeep +0 -0
- package/skills/dknowc-ppt-assistant/projects/.gitkeep +0 -0
- package/skills/dknowc-ppt-assistant/references/content-pack.md +55 -0
- package/skills/dknowc-ppt-assistant/references/material_usage.md +51 -0
- package/skills/dknowc-ppt-assistant/references/sample_effect.html +89 -0
- package/skills/dknowc-ppt-assistant/references/sample_search_result.md +48 -0
- package/skills/dknowc-ppt-assistant/references/search_intro.md +79 -0
- package/skills/dknowc-ppt-assistant/references/style-presets.md +126 -0
- package/skills/dknowc-ppt-assistant/references/svg-authoring.md +81 -0
- package/skills/dknowc-ppt-assistant/references/upstream-docs/svg-pipeline.md +842 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/01_cover.svg +28 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/02_quote.svg +38 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/03_origin.svg +96 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/README.md +15 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/design_spec.md +408 -0
- package/skills/dknowc-ppt-assistant/references/upstream-example/spec_lock.md +78 -0
- package/skills/dknowc-ppt-assistant/scripts/adapt_mcp_result.py +279 -0
- package/skills/dknowc-ppt-assistant/scripts/check_release.py +106 -0
- package/skills/dknowc-ppt-assistant/scripts/compact_svg_coordinates.py +345 -0
- package/skills/dknowc-ppt-assistant/scripts/config.py +707 -0
- package/skills/dknowc-ppt-assistant/scripts/console_encoding.py +33 -0
- package/skills/dknowc-ppt-assistant/scripts/error_helper.py +434 -0
- package/skills/dknowc-ppt-assistant/scripts/finalize_svg.py +507 -0
- package/skills/dknowc-ppt-assistant/scripts/hyperlink_contract.py +399 -0
- package/skills/dknowc-ppt-assistant/scripts/initialize.py +182 -0
- package/skills/dknowc-ppt-assistant/scripts/language_tags.py +283 -0
- package/skills/dknowc-ppt-assistant/scripts/mcp_direct.py +158 -0
- package/skills/dknowc-ppt-assistant/scripts/native_payloads.py +655 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_animation_presets.json +3440 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_animations.py +3965 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_effects.py +143 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_opc_validation.py +346 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/__init__.py +130 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/LICENSE-APACHE-2.0.txt +202 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/LICENSE-OPEN-XML-SDK-MIT.txt +23 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/NOTICE.md +54 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/presetShapeDefinitions.xml +19898 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/presetShapeSemantics.json +1217 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/data/shape_type_values.txt +187 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/errors.py +39 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/formula.py +336 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/loader.py +364 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/models.py +201 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/registry.py +270 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantic_hash.py +456 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/semantics.py +543 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_shapes/xml_safety.py +21 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/__init__.py +21 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/animation_import.py +287 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/chart_to_svg.py +2377 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/chartex_to_svg.py +422 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/color_resolver.py +894 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/converter.py +1143 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/custgeom_to_svg.py +165 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/effect_to_svg.py +410 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/emu_units.py +258 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/fill_to_svg.py +816 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/formula_import.py +611 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/hyperlinks.py +93 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/import_diagnostics.py +37 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/ln_to_svg.py +362 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/normalized_chart_svg.py +1217 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/ooxml_loader.py +506 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/pic_to_svg.py +653 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_authoring.py +894 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_registry_to_svg.py +216 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/preset_svg_markup.py +198 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/prstgeom_to_svg.py +162 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/shape_walker.py +556 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/slide_to_svg.py +2002 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/tbl_to_svg.py +1841 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/transition_import.py +201 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_to_svg/txbody_to_svg.py +1433 -0
- package/skills/dknowc-ppt-assistant/scripts/pptx_transitions.py +3153 -0
- package/skills/dknowc-ppt-assistant/scripts/preset_shape_svg.py +450 -0
- package/skills/dknowc-ppt-assistant/scripts/project_utils.py +645 -0
- package/skills/dknowc-ppt-assistant/scripts/register_key.mjs +183 -0
- package/skills/dknowc-ppt-assistant/scripts/register_template.py +1327 -0
- package/skills/dknowc-ppt-assistant/scripts/render_trace_html.py +1048 -0
- package/skills/dknowc-ppt-assistant/scripts/resource_paths.py +282 -0
- package/skills/dknowc-ppt-assistant/scripts/shape_boolean_svg.py +189 -0
- package/skills/dknowc-ppt-assistant/scripts/slide_roster.py +44 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/__init__.py +12 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/align_embed_images.py +672 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/crop_images.py +370 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/embed_icons.py +564 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/embed_images.py +288 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/fix_image_aspect.py +389 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/flatten_tspan.py +948 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_finalize/svg_rect_to_path.py +346 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/__init__.py +15 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/checker.py +7791 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/cli.py +193 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/svg_contracts.py +1121 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality/xml_support.py +35 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_quality_checker.py +59 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/__init__.py +37 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/animation_config.py +1622 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/canvas_contract.py +226 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/__init__.py +1 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/context.py +291 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/converter.py +1980 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/elements.py +5272 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/hyperlinks.py +162 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/paths.py +847 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/styles.py +752 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/text_properties.py +796 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_colors.py +283 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/theme_fonts.py +330 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/drawingml/utils.py +3555 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/geometry_properties.py +140 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/__init__.py +356 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chart_data.py +1449 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chart_style.py +886 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chart_xml.py +1495 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/chartex.py +272 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/fallback_hash.py +161 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula.py +243 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_ast.py +592 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_compiler.py +96 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_omml.py +1049 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_parser.py +2181 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_profile.py +739 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/formula_run_properties.py +234 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/inline_formula.py +311 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/marker_attributes.py +182 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/marker_common.py +806 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/marker_status.py +190 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/table.py +1113 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/native_objects/workbook.py +216 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/__init__.py +1 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/builder.py +6273 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/cli.py +2059 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/dimensions.py +189 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/discovery.py +120 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/media.py +160 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/narration.py +696 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/notes.py +336 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/slide_xml.py +138 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_structure.py +3457 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/pptx_package/template_validation.py +1536 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/semantic_markers.py +240 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/shape_boolean.py +1355 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/text_outline.py +1121 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/tspan_flattener.py +64 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx/use_expander.py +577 -0
- package/skills/dknowc-ppt-assistant/scripts/svg_to_pptx.py +21 -0
- package/skills/dknowc-ppt-assistant/scripts/trusted_search.py +336 -0
- package/skills/dknowc-ppt-assistant/scripts/update_spec.py +404 -0
- package/skills/dknowc-ppt-assistant/workflows/generate-pptx.md +142 -0
- package/skills/dknowc-ppt-assistant/workflows/routing.md +38 -0
- package/skills/dknowc-trusted-consulting/SKILL.md +21 -5
- package/skills/dknowc-trusted-consulting/reference/consult_intro.md +79 -0
- package/skills/dknowc-trusted-consulting/reference/sample_consult_answer.md +31 -0
- package/skills/dknowc-trusted-consulting/reference/sample_trace_report.html +76 -0
- package/skills/dknowc-trusted-consulting/scripts/register_key.mjs +1 -0
- package/skills/dknowc-trusted-search/SKILL.md +30 -2
- package/skills/dknowc-trusted-search/reference/sample_search_result.md +33 -0
- package/skills/dknowc-trusted-search/reference/sample_trace_report.html +450 -0
- package/skills/dknowc-trusted-search/reference/search_intro.md +79 -0
- package/skills/dknowc-trusted-search/scripts/register_key.mjs +1 -0
- package/src/index.js +7 -2
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
"""Markdown to plain text conversion and notes slide XML generation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
|
|
7
|
+
from language_tags import normalize_language_tag
|
|
8
|
+
|
|
9
|
+
from ..drawingml.utils import (
|
|
10
|
+
detect_text_lang,
|
|
11
|
+
text_has_rtl_characters,
|
|
12
|
+
text_uses_rtl,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def markdown_to_plain_text(md_content: str) -> str:
|
|
17
|
+
"""Convert Markdown notes to plain text for PPTX notes.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
md_content: Markdown formatted notes content.
|
|
21
|
+
|
|
22
|
+
Returns:
|
|
23
|
+
Plain text content.
|
|
24
|
+
"""
|
|
25
|
+
def strip_inline_bold(text: str) -> str:
|
|
26
|
+
text = re.sub(r'\*\*(.+?)\*\*', r'\1', text)
|
|
27
|
+
text = re.sub(r'__(.+?)__', r'\1', text)
|
|
28
|
+
return text
|
|
29
|
+
|
|
30
|
+
lines: list[str] = []
|
|
31
|
+
for line in md_content.split('\n'):
|
|
32
|
+
if line.startswith('#'):
|
|
33
|
+
text = re.sub(r'^#+\s*', '', line).strip()
|
|
34
|
+
text = strip_inline_bold(text)
|
|
35
|
+
if text:
|
|
36
|
+
lines.append(text)
|
|
37
|
+
lines.append('')
|
|
38
|
+
elif line.strip().startswith('- '):
|
|
39
|
+
item_text = line.strip()[2:]
|
|
40
|
+
item_text = strip_inline_bold(item_text)
|
|
41
|
+
lines.append('• ' + item_text)
|
|
42
|
+
elif line.strip():
|
|
43
|
+
text = strip_inline_bold(line.strip())
|
|
44
|
+
lines.append(text)
|
|
45
|
+
else:
|
|
46
|
+
lines.append('')
|
|
47
|
+
|
|
48
|
+
# Merge consecutive empty lines
|
|
49
|
+
result: list[str] = []
|
|
50
|
+
is_prev_empty = False
|
|
51
|
+
for line in lines:
|
|
52
|
+
if line == '':
|
|
53
|
+
if not is_prev_empty:
|
|
54
|
+
result.append(line)
|
|
55
|
+
is_prev_empty = True
|
|
56
|
+
else:
|
|
57
|
+
result.append(line)
|
|
58
|
+
is_prev_empty = False
|
|
59
|
+
|
|
60
|
+
return '\n'.join(result).strip()
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def create_notes_slide_xml(
|
|
64
|
+
slide_num: int,
|
|
65
|
+
notes_text: str,
|
|
66
|
+
primary_language: str | None = None,
|
|
67
|
+
) -> str:
|
|
68
|
+
"""Create notes slide XML.
|
|
69
|
+
|
|
70
|
+
Args:
|
|
71
|
+
slide_num: Slide number.
|
|
72
|
+
notes_text: Notes text in plain text format.
|
|
73
|
+
primary_language: Canonical BCP-47 deck language, when available.
|
|
74
|
+
|
|
75
|
+
Returns:
|
|
76
|
+
Notes slide XML string.
|
|
77
|
+
"""
|
|
78
|
+
primary_language = (
|
|
79
|
+
normalize_language_tag(primary_language)
|
|
80
|
+
if primary_language is not None
|
|
81
|
+
else None
|
|
82
|
+
)
|
|
83
|
+
default_language = primary_language or 'en-US'
|
|
84
|
+
notes_text = (notes_text
|
|
85
|
+
.replace('&', '&')
|
|
86
|
+
.replace('<', '<')
|
|
87
|
+
.replace('>', '>'))
|
|
88
|
+
|
|
89
|
+
paragraphs: list[str] = []
|
|
90
|
+
for para in notes_text.split('\n'):
|
|
91
|
+
if para.strip():
|
|
92
|
+
lang = detect_text_lang(para, primary_language)
|
|
93
|
+
paragraph_rtl = ' rtl="1"' if text_uses_rtl(
|
|
94
|
+
para,
|
|
95
|
+
primary_language,
|
|
96
|
+
) else ''
|
|
97
|
+
run_rtl = (
|
|
98
|
+
'<a:rtl val="1"/>'
|
|
99
|
+
if text_has_rtl_characters(para)
|
|
100
|
+
else ''
|
|
101
|
+
)
|
|
102
|
+
paragraphs.append(f'''<a:p>
|
|
103
|
+
<a:pPr{paragraph_rtl}/>
|
|
104
|
+
<a:r>
|
|
105
|
+
<a:rPr lang="{lang}" dirty="0">{run_rtl}</a:rPr>
|
|
106
|
+
<a:t>{para}</a:t>
|
|
107
|
+
</a:r>
|
|
108
|
+
</a:p>''')
|
|
109
|
+
else:
|
|
110
|
+
paragraph_rtl = (
|
|
111
|
+
' rtl="1"'
|
|
112
|
+
if primary_language and text_uses_rtl('', primary_language)
|
|
113
|
+
else ''
|
|
114
|
+
)
|
|
115
|
+
paragraphs.append(
|
|
116
|
+
f'<a:p><a:pPr{paragraph_rtl}/>'
|
|
117
|
+
f'<a:endParaRPr lang="{default_language}" dirty="0"/></a:p>'
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
paragraphs_xml = (
|
|
121
|
+
'\n '.join(paragraphs)
|
|
122
|
+
if paragraphs
|
|
123
|
+
else (
|
|
124
|
+
f'<a:p><a:endParaRPr lang="{default_language}" dirty="0"/></a:p>'
|
|
125
|
+
)
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
129
|
+
<p:notes xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
130
|
+
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
131
|
+
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
|
|
132
|
+
<p:cSld>
|
|
133
|
+
<p:spTree>
|
|
134
|
+
<p:nvGrpSpPr>
|
|
135
|
+
<p:cNvPr id="1" name=""/>
|
|
136
|
+
<p:cNvGrpSpPr/>
|
|
137
|
+
<p:nvPr/>
|
|
138
|
+
</p:nvGrpSpPr>
|
|
139
|
+
<p:grpSpPr>
|
|
140
|
+
<a:xfrm>
|
|
141
|
+
<a:off x="0" y="0"/>
|
|
142
|
+
<a:ext cx="0" cy="0"/>
|
|
143
|
+
<a:chOff x="0" y="0"/>
|
|
144
|
+
<a:chExt cx="0" cy="0"/>
|
|
145
|
+
</a:xfrm>
|
|
146
|
+
</p:grpSpPr>
|
|
147
|
+
<p:sp>
|
|
148
|
+
<p:nvSpPr>
|
|
149
|
+
<p:cNvPr id="2" name="Slide Image Placeholder 1"/>
|
|
150
|
+
<p:cNvSpPr>
|
|
151
|
+
<a:spLocks noGrp="1" noRot="1" noChangeAspect="1"/>
|
|
152
|
+
</p:cNvSpPr>
|
|
153
|
+
<p:nvPr>
|
|
154
|
+
<p:ph type="sldImg" idx="2"/>
|
|
155
|
+
</p:nvPr>
|
|
156
|
+
</p:nvSpPr>
|
|
157
|
+
<p:spPr/>
|
|
158
|
+
</p:sp>
|
|
159
|
+
<p:sp>
|
|
160
|
+
<p:nvSpPr>
|
|
161
|
+
<p:cNvPr id="3" name="Notes Placeholder 2"/>
|
|
162
|
+
<p:cNvSpPr>
|
|
163
|
+
<a:spLocks noGrp="1"/>
|
|
164
|
+
</p:cNvSpPr>
|
|
165
|
+
<p:nvPr>
|
|
166
|
+
<p:ph type="body" sz="quarter" idx="3"/>
|
|
167
|
+
</p:nvPr>
|
|
168
|
+
</p:nvSpPr>
|
|
169
|
+
<p:spPr/>
|
|
170
|
+
<p:txBody>
|
|
171
|
+
<a:bodyPr/>
|
|
172
|
+
<a:lstStyle/>
|
|
173
|
+
{paragraphs_xml}
|
|
174
|
+
</p:txBody>
|
|
175
|
+
</p:sp>
|
|
176
|
+
</p:spTree>
|
|
177
|
+
</p:cSld>
|
|
178
|
+
<p:clrMapOvr>
|
|
179
|
+
<a:masterClrMapping/>
|
|
180
|
+
</p:clrMapOvr>
|
|
181
|
+
</p:notes>'''
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def create_notes_slide_rels_xml(slide_num: int) -> str:
|
|
185
|
+
"""Create notes slide relationship file XML.
|
|
186
|
+
|
|
187
|
+
Args:
|
|
188
|
+
slide_num: Slide number.
|
|
189
|
+
|
|
190
|
+
Returns:
|
|
191
|
+
Relationship file XML string.
|
|
192
|
+
"""
|
|
193
|
+
return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
194
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
195
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="../notesMasters/notesMaster1.xml"/>
|
|
196
|
+
<Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="../slides/slide{slide_num}.xml"/>
|
|
197
|
+
</Relationships>'''
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
def create_notes_master_xml(primary_language: str | None = None) -> str:
|
|
201
|
+
"""Create a minimal PowerPoint-compatible notes master XML."""
|
|
202
|
+
language = (
|
|
203
|
+
normalize_language_tag(primary_language)
|
|
204
|
+
if primary_language is not None
|
|
205
|
+
else 'en-US'
|
|
206
|
+
)
|
|
207
|
+
paragraph_rtl = ' rtl="1"' if text_uses_rtl('', language) else ''
|
|
208
|
+
return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
209
|
+
<p:notesMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
210
|
+
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
211
|
+
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
|
|
212
|
+
<p:cSld>
|
|
213
|
+
<p:spTree>
|
|
214
|
+
<p:nvGrpSpPr>
|
|
215
|
+
<p:cNvPr id="1" name=""/>
|
|
216
|
+
<p:cNvGrpSpPr/>
|
|
217
|
+
<p:nvPr/>
|
|
218
|
+
</p:nvGrpSpPr>
|
|
219
|
+
<p:grpSpPr>
|
|
220
|
+
<a:xfrm>
|
|
221
|
+
<a:off x="0" y="0"/>
|
|
222
|
+
<a:ext cx="0" cy="0"/>
|
|
223
|
+
<a:chOff x="0" y="0"/>
|
|
224
|
+
<a:chExt cx="0" cy="0"/>
|
|
225
|
+
</a:xfrm>
|
|
226
|
+
</p:grpSpPr>
|
|
227
|
+
<p:sp>
|
|
228
|
+
<p:nvSpPr>
|
|
229
|
+
<p:cNvPr id="2" name="Header Placeholder 1"/>
|
|
230
|
+
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
231
|
+
<p:nvPr><p:ph type="hdr" sz="quarter"/></p:nvPr>
|
|
232
|
+
</p:nvSpPr>
|
|
233
|
+
<p:spPr>
|
|
234
|
+
<a:xfrm>
|
|
235
|
+
<a:off x="0" y="0"/>
|
|
236
|
+
<a:ext cx="2971800" cy="457200"/>
|
|
237
|
+
</a:xfrm>
|
|
238
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
239
|
+
</p:spPr>
|
|
240
|
+
<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
|
|
241
|
+
</p:sp>
|
|
242
|
+
<p:sp>
|
|
243
|
+
<p:nvSpPr>
|
|
244
|
+
<p:cNvPr id="3" name="Date Placeholder 2"/>
|
|
245
|
+
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
246
|
+
<p:nvPr><p:ph type="dt" sz="half" idx="1"/></p:nvPr>
|
|
247
|
+
</p:nvSpPr>
|
|
248
|
+
<p:spPr>
|
|
249
|
+
<a:xfrm>
|
|
250
|
+
<a:off x="3884613" y="0"/>
|
|
251
|
+
<a:ext cx="2971800" cy="457200"/>
|
|
252
|
+
</a:xfrm>
|
|
253
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
254
|
+
</p:spPr>
|
|
255
|
+
<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
|
|
256
|
+
</p:sp>
|
|
257
|
+
<p:sp>
|
|
258
|
+
<p:nvSpPr>
|
|
259
|
+
<p:cNvPr id="4" name="Slide Image Placeholder 3"/>
|
|
260
|
+
<p:cNvSpPr><a:spLocks noGrp="1" noRot="1" noChangeAspect="1"/></p:cNvSpPr>
|
|
261
|
+
<p:nvPr><p:ph type="sldImg" idx="2"/></p:nvPr>
|
|
262
|
+
</p:nvSpPr>
|
|
263
|
+
<p:spPr>
|
|
264
|
+
<a:xfrm>
|
|
265
|
+
<a:off x="1143000" y="685800"/>
|
|
266
|
+
<a:ext cx="4572000" cy="3429000"/>
|
|
267
|
+
</a:xfrm>
|
|
268
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
269
|
+
</p:spPr>
|
|
270
|
+
</p:sp>
|
|
271
|
+
<p:sp>
|
|
272
|
+
<p:nvSpPr>
|
|
273
|
+
<p:cNvPr id="5" name="Notes Placeholder 4"/>
|
|
274
|
+
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
275
|
+
<p:nvPr><p:ph type="body" sz="quarter" idx="3"/></p:nvPr>
|
|
276
|
+
</p:nvSpPr>
|
|
277
|
+
<p:spPr>
|
|
278
|
+
<a:xfrm>
|
|
279
|
+
<a:off x="685800" y="4343400"/>
|
|
280
|
+
<a:ext cx="5486400" cy="4114800"/>
|
|
281
|
+
</a:xfrm>
|
|
282
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
283
|
+
</p:spPr>
|
|
284
|
+
<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
|
|
285
|
+
</p:sp>
|
|
286
|
+
<p:sp>
|
|
287
|
+
<p:nvSpPr>
|
|
288
|
+
<p:cNvPr id="6" name="Footer Placeholder 5"/>
|
|
289
|
+
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
290
|
+
<p:nvPr><p:ph type="ftr" sz="quarter" idx="4"/></p:nvPr>
|
|
291
|
+
</p:nvSpPr>
|
|
292
|
+
<p:spPr>
|
|
293
|
+
<a:xfrm>
|
|
294
|
+
<a:off x="0" y="8685213"/>
|
|
295
|
+
<a:ext cx="2971800" cy="457200"/>
|
|
296
|
+
</a:xfrm>
|
|
297
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
298
|
+
</p:spPr>
|
|
299
|
+
<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
|
|
300
|
+
</p:sp>
|
|
301
|
+
<p:sp>
|
|
302
|
+
<p:nvSpPr>
|
|
303
|
+
<p:cNvPr id="7" name="Slide Number Placeholder 6"/>
|
|
304
|
+
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
|
|
305
|
+
<p:nvPr><p:ph type="sldNum" sz="quarter" idx="5"/></p:nvPr>
|
|
306
|
+
</p:nvSpPr>
|
|
307
|
+
<p:spPr>
|
|
308
|
+
<a:xfrm>
|
|
309
|
+
<a:off x="3884613" y="8685213"/>
|
|
310
|
+
<a:ext cx="2971800" cy="457200"/>
|
|
311
|
+
</a:xfrm>
|
|
312
|
+
<a:prstGeom prst="rect"><a:avLst/></a:prstGeom>
|
|
313
|
+
</p:spPr>
|
|
314
|
+
<p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:pPr{paragraph_rtl}/><a:endParaRPr lang="{language}"/></a:p></p:txBody>
|
|
315
|
+
</p:sp>
|
|
316
|
+
</p:spTree>
|
|
317
|
+
</p:cSld>
|
|
318
|
+
<p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2"
|
|
319
|
+
accent1="accent1" accent2="accent2" accent3="accent3"
|
|
320
|
+
accent4="accent4" accent5="accent5" accent6="accent6"
|
|
321
|
+
hlink="hlink" folHlink="folHlink"/>
|
|
322
|
+
<p:hf/>
|
|
323
|
+
<p:notesStyle>
|
|
324
|
+
<a:lvl1pPr marL="0" algn="l"{paragraph_rtl}>
|
|
325
|
+
<a:defRPr sz="1200" lang="{language}"/>
|
|
326
|
+
</a:lvl1pPr>
|
|
327
|
+
</p:notesStyle>
|
|
328
|
+
</p:notesMaster>'''
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
def create_notes_master_rels_xml() -> str:
|
|
332
|
+
"""Create notes master relationships XML."""
|
|
333
|
+
return '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
334
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
335
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="../theme/theme2.xml"/>
|
|
336
|
+
</Relationships>'''
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"""Slide XML and slide relationship XML generation."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pptx_transitions import create_transition_xml
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def create_slide_xml_with_svg(
|
|
9
|
+
slide_num: int,
|
|
10
|
+
png_rid: str,
|
|
11
|
+
svg_rid: str,
|
|
12
|
+
width_emu: int,
|
|
13
|
+
height_emu: int,
|
|
14
|
+
transition: str | None = 'fade',
|
|
15
|
+
transition_duration: float = 0.5,
|
|
16
|
+
auto_advance: float | None = None,
|
|
17
|
+
use_compat_mode: bool = True,
|
|
18
|
+
transition_effect_options: dict[str, object] | None = None,
|
|
19
|
+
) -> str:
|
|
20
|
+
"""Create slide XML containing an SVG image.
|
|
21
|
+
|
|
22
|
+
Args:
|
|
23
|
+
slide_num: Slide number.
|
|
24
|
+
png_rid: PNG fallback image relationship ID.
|
|
25
|
+
svg_rid: SVG relationship ID.
|
|
26
|
+
width_emu: Width in EMU.
|
|
27
|
+
height_emu: Height in EMU.
|
|
28
|
+
transition: Transition effect name.
|
|
29
|
+
transition_effect_options: PowerPoint Effect Options for the selected
|
|
30
|
+
native transition.
|
|
31
|
+
transition_duration: Transition duration in seconds.
|
|
32
|
+
auto_advance: Auto-advance interval in seconds.
|
|
33
|
+
use_compat_mode: Whether to use compatibility mode (PNG + SVG dual format).
|
|
34
|
+
"""
|
|
35
|
+
transition_xml = ''
|
|
36
|
+
if transition is not None or auto_advance is not None:
|
|
37
|
+
transition_fragment = create_transition_xml(
|
|
38
|
+
effect=transition,
|
|
39
|
+
duration=transition_duration,
|
|
40
|
+
advance_after=auto_advance,
|
|
41
|
+
effect_options=transition_effect_options,
|
|
42
|
+
)
|
|
43
|
+
if transition_fragment:
|
|
44
|
+
transition_xml = '\n' + transition_fragment
|
|
45
|
+
|
|
46
|
+
if use_compat_mode:
|
|
47
|
+
blip_xml = f'''<a:blip r:embed="{png_rid}">
|
|
48
|
+
<a:extLst>
|
|
49
|
+
<a:ext uri="{{96DAC541-7B7A-43D3-8B79-37D633B846F1}}">
|
|
50
|
+
<asvg:svgBlip xmlns:asvg="http://schemas.microsoft.com/office/drawing/2016/SVG/main" r:embed="{svg_rid}"/>
|
|
51
|
+
</a:ext>
|
|
52
|
+
</a:extLst>
|
|
53
|
+
</a:blip>'''
|
|
54
|
+
else:
|
|
55
|
+
blip_xml = f'<a:blip r:embed="{svg_rid}"/>'
|
|
56
|
+
|
|
57
|
+
return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
58
|
+
<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"
|
|
59
|
+
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"
|
|
60
|
+
xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">
|
|
61
|
+
<p:cSld>
|
|
62
|
+
<p:spTree>
|
|
63
|
+
<p:nvGrpSpPr>
|
|
64
|
+
<p:cNvPr id="1" name=""/>
|
|
65
|
+
<p:cNvGrpSpPr/>
|
|
66
|
+
<p:nvPr/>
|
|
67
|
+
</p:nvGrpSpPr>
|
|
68
|
+
<p:grpSpPr>
|
|
69
|
+
<a:xfrm>
|
|
70
|
+
<a:off x="0" y="0"/>
|
|
71
|
+
<a:ext cx="0" cy="0"/>
|
|
72
|
+
<a:chOff x="0" y="0"/>
|
|
73
|
+
<a:chExt cx="0" cy="0"/>
|
|
74
|
+
</a:xfrm>
|
|
75
|
+
</p:grpSpPr>
|
|
76
|
+
<p:pic>
|
|
77
|
+
<p:nvPicPr>
|
|
78
|
+
<p:cNvPr id="2" name="SVG Image {slide_num}"/>
|
|
79
|
+
<p:cNvPicPr>
|
|
80
|
+
<a:picLocks noChangeAspect="1"/>
|
|
81
|
+
</p:cNvPicPr>
|
|
82
|
+
<p:nvPr/>
|
|
83
|
+
</p:nvPicPr>
|
|
84
|
+
<p:blipFill>
|
|
85
|
+
{blip_xml}
|
|
86
|
+
<a:stretch>
|
|
87
|
+
<a:fillRect/>
|
|
88
|
+
</a:stretch>
|
|
89
|
+
</p:blipFill>
|
|
90
|
+
<p:spPr>
|
|
91
|
+
<a:xfrm>
|
|
92
|
+
<a:off x="0" y="0"/>
|
|
93
|
+
<a:ext cx="{width_emu}" cy="{height_emu}"/>
|
|
94
|
+
</a:xfrm>
|
|
95
|
+
<a:prstGeom prst="rect">
|
|
96
|
+
<a:avLst/>
|
|
97
|
+
</a:prstGeom>
|
|
98
|
+
</p:spPr>
|
|
99
|
+
</p:pic>
|
|
100
|
+
</p:spTree>
|
|
101
|
+
</p:cSld>
|
|
102
|
+
<p:clrMapOvr>
|
|
103
|
+
<a:masterClrMapping/>
|
|
104
|
+
</p:clrMapOvr>{transition_xml}
|
|
105
|
+
</p:sld>'''
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def create_slide_rels_xml(
|
|
109
|
+
png_rid: str,
|
|
110
|
+
png_filename: str,
|
|
111
|
+
svg_rid: str,
|
|
112
|
+
svg_filename: str,
|
|
113
|
+
use_compat_mode: bool = True,
|
|
114
|
+
slide_layout_target: str = "../slideLayouts/slideLayout1.xml",
|
|
115
|
+
) -> str:
|
|
116
|
+
"""Create slide relationship file XML.
|
|
117
|
+
|
|
118
|
+
Args:
|
|
119
|
+
png_rid: PNG image relationship ID.
|
|
120
|
+
png_filename: PNG filename.
|
|
121
|
+
svg_rid: SVG relationship ID.
|
|
122
|
+
svg_filename: SVG filename.
|
|
123
|
+
use_compat_mode: Whether to use compatibility mode.
|
|
124
|
+
slide_layout_target: Target for the slide's actual layout part.
|
|
125
|
+
"""
|
|
126
|
+
if use_compat_mode:
|
|
127
|
+
return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
128
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
129
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="{slide_layout_target}"/>
|
|
130
|
+
<Relationship Id="{png_rid}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/{png_filename}"/>
|
|
131
|
+
<Relationship Id="{svg_rid}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/{svg_filename}"/>
|
|
132
|
+
</Relationships>'''
|
|
133
|
+
else:
|
|
134
|
+
return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
135
|
+
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
|
|
136
|
+
<Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slideLayout" Target="{slide_layout_target}"/>
|
|
137
|
+
<Relationship Id="{svg_rid}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/image" Target="../media/{svg_filename}"/>
|
|
138
|
+
</Relationships>'''
|