Skip to content

Commit 1368df1

Browse files
authored
Merge pull request #55 from b-rodrigues/claude/add-figure-crossreferences-01Md8Vp3EkTohuaSTKhMd2GP
Add figure labels and cross-references
2 parents 4e07b1f + 01016ce commit 1368df1

File tree

9 files changed

+1767
-33
lines changed

9 files changed

+1767
-33
lines changed

example/reference_doc.md

Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
# Cross-Reference Feature Reference Document {#sec:intro}
2+
3+
This document demonstrates all cross-reference features available in Korppi. It can be used to test importing markdown documents and exporting to DOCX format.
4+
5+
## Overview {#sec:overview}
6+
7+
Korppi supports three types of cross-references:
8+
9+
1. **Figures** - Images with captions and labels
10+
2. **Sections** - Headings with labels
11+
3. **Tables** - Tables with labels
12+
13+
Each type uses a consistent Pandoc-compatible syntax for labels (`{#type:label}`) and references (`@type:label`).
14+
15+
## Section References {#sec:sections}
16+
17+
Sections can be labeled by adding `{#sec:label}` at the end of any heading. For example, this section is labeled as `sec:sections`.
18+
19+
You can reference any labeled section:
20+
21+
- See @sec:intro for the introduction
22+
- See @sec:overview for the overview
23+
- See @sec:figures for information about figures
24+
- See @sec:tables for table examples
25+
- See @sec:combined for a combined example
26+
27+
### Subsection Example {#sec:subsection}
28+
29+
Subsections can also have labels. This subsection is labeled as `sec:subsection`.
30+
31+
As mentioned in @sec:overview, there are three types of cross-references. This subsection (@sec:subsection) demonstrates that any heading level can be labeled.
32+
33+
## Figures {#sec:figures}
34+
35+
Figures are created by adding `{#fig:label}` after an image. The syntax is:
36+
37+
```
38+
![Caption text](image-url){#fig:label}
39+
```
40+
41+
### Simple Figure
42+
43+
![A sample chart showing quarterly sales data](https://via.placeholder.com/600x400?text=Sales+Chart){#fig:sales}
44+
45+
The figure above (@fig:sales) shows a placeholder for a sales chart.
46+
47+
### Multiple Figures
48+
49+
Here are additional figures to demonstrate numbering:
50+
51+
![Distribution of customer segments](https://via.placeholder.com/500x300?text=Customer+Segments){#fig:segments}
52+
53+
![Revenue trends over time](https://via.placeholder.com/500x300?text=Revenue+Trends){#fig:trends}
54+
55+
![Comparison of product performance](https://via.placeholder.com/500x300?text=Product+Comparison){#fig:comparison}
56+
57+
As shown in @fig:segments, customer segments vary significantly. When combined with @fig:trends, we can see how revenue has changed. Finally, @fig:comparison provides a detailed product analysis.
58+
59+
## Tables {#sec:tables}
60+
61+
Tables are labeled by adding `{#tbl:label}` on a new line after the table.
62+
63+
### Basic Table
64+
65+
| Quarter | Revenue | Growth |
66+
|---------|---------|--------|
67+
| Q1 2024 | $1.2M | 5% |
68+
| Q2 2024 | $1.4M | 8% |
69+
| Q3 2024 | $1.5M | 7% |
70+
| Q4 2024 | $1.8M | 12% |
71+
72+
{#tbl:quarterly}
73+
74+
@tbl:quarterly shows the quarterly revenue figures for 2024.
75+
76+
### Detailed Data Table
77+
78+
| Product | Category | Units Sold | Revenue | Margin |
79+
|---------|----------|------------|---------|--------|
80+
| Widget A | Hardware | 1,500 | $45,000 | 32% |
81+
| Widget B | Hardware | 2,300 | $69,000 | 28% |
82+
| Service X | Software | 800 | $120,000 | 65% |
83+
| Service Y | Software | 1,200 | $180,000 | 70% |
84+
| Bundle Z | Mixed | 450 | $90,000 | 45% |
85+
86+
{#tbl:products}
87+
88+
The product breakdown in @tbl:products reveals that software services have higher margins than hardware products.
89+
90+
### Summary Statistics
91+
92+
| Metric | Value |
93+
|--------|-------|
94+
| Total Revenue | $504,000 |
95+
| Average Margin | 48% |
96+
| Top Product | Service Y |
97+
98+
{#tbl:summary}
99+
100+
See @tbl:summary for the key metrics derived from @tbl:products.
101+
102+
## Combined Example {#sec:combined}
103+
104+
This section demonstrates using all three types of cross-references together in a cohesive narrative.
105+
106+
### Analysis Methodology {#sec:methodology}
107+
108+
As outlined in @sec:overview, our analysis uses multiple data sources. The methodology follows these steps:
109+
110+
1. Data collection (see @tbl:quarterly for raw data)
111+
2. Visualization (see @fig:trends for trend analysis)
112+
3. Comparison (see @fig:comparison for product comparison)
113+
114+
### Key Findings {#sec:findings}
115+
116+
Based on the data presented in @tbl:products and visualized in @fig:segments:
117+
118+
- Revenue increased consistently each quarter (@tbl:quarterly)
119+
- Customer segments show distinct purchasing patterns (@fig:segments)
120+
- Software services outperform hardware products (@tbl:products)
121+
122+
![Summary dashboard combining all metrics](https://via.placeholder.com/700x400?text=Summary+Dashboard){#fig:dashboard}
123+
124+
@fig:dashboard provides an integrated view of all the metrics discussed in @sec:methodology and @sec:findings.
125+
126+
### Recommendations {#sec:recommendations}
127+
128+
Based on our analysis in @sec:findings:
129+
130+
1. Focus on software services (highest margins per @tbl:products)
131+
2. Target growing customer segments (see @fig:segments)
132+
3. Maintain Q4 momentum (strongest growth per @tbl:quarterly)
133+
134+
## Formatting Examples {#sec:formatting}
135+
136+
This section includes various formatting to test DOCX export compatibility.
137+
138+
### Text Formatting
139+
140+
- **Bold text** for emphasis
141+
- *Italic text* for titles or foreign words
142+
- ~~Strikethrough~~ for deletions
143+
- `inline code` for technical terms
144+
- Combinations: ***bold and italic***, **bold with `code`**
145+
146+
### Lists
147+
148+
Ordered list:
149+
150+
1. First item
151+
2. Second item
152+
3. Third item
153+
154+
Unordered list:
155+
156+
- Item A
157+
- Item B
158+
- Item C
159+
160+
### Block Quote
161+
162+
> This is a block quote that might contain important information
163+
> or a citation from another source. It can span multiple lines.
164+
165+
### Code Block
166+
167+
```python
168+
def calculate_growth(current, previous):
169+
"""Calculate percentage growth between two values."""
170+
if previous == 0:
171+
return 0
172+
return ((current - previous) / previous) * 100
173+
```
174+
175+
## Conclusion {#sec:conclusion}
176+
177+
This document has demonstrated:
178+
179+
- Section references (@sec:intro through @sec:conclusion)
180+
- Figure references (@fig:sales, @fig:segments, @fig:trends, @fig:comparison, @fig:dashboard)
181+
- Table references (@tbl:quarterly, @tbl:products, @tbl:summary)
182+
183+
All cross-references should resolve to their correct numbers when exported to DOCX format. The label syntax (`{#type:label}`) should be removed from the output, and references (`@type:label`) should be replaced with "Figure N", "Section N", or "Table N" as appropriate.
184+
185+
---
186+
187+
## Reference Summary
188+
189+
### All Sections
190+
- @sec:intro - Introduction
191+
- @sec:overview - Overview
192+
- @sec:sections - Section References
193+
- @sec:subsection - Subsection Example
194+
- @sec:figures - Figures
195+
- @sec:tables - Tables
196+
- @sec:combined - Combined Example
197+
- @sec:methodology - Analysis Methodology
198+
- @sec:findings - Key Findings
199+
- @sec:recommendations - Recommendations
200+
- @sec:formatting - Formatting Examples
201+
- @sec:conclusion - Conclusion
202+
203+
### All Figures
204+
- @fig:sales - Sales Chart
205+
- @fig:segments - Customer Segments
206+
- @fig:trends - Revenue Trends
207+
- @fig:comparison - Product Comparison
208+
- @fig:dashboard - Summary Dashboard
209+
210+
### All Tables
211+
- @tbl:quarterly - Quarterly Revenue
212+
- @tbl:products - Product Breakdown
213+
- @tbl:summary - Summary Statistics

package-lock.json

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ sha2 = "0.10"
3535
# DOCX export
3636
docx-rs = "0.4.18"
3737
pulldown-cmark = "0.13.0"
38+
regex = "1"
3839

3940
# XML parsing for DOCX/ODT import
4041
quick-xml = "0.31"

0 commit comments

Comments
 (0)