Skip to content

Commit 8a88980

Browse files
Merge pull request #382 from feelpp/380-support-figure-and-table-references
380 support figure and table references
2 parents 98abe58 + 369cf6c commit 8a88980

File tree

31 files changed

+316
-115
lines changed

31 files changed

+316
-115
lines changed
Lines changed: 71 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,26 @@
11
.figure-container {
22
position: relative;
3-
margin: 1.5rem auto;
4-
padding: 1rem;
5-
background-color: #fff;
6-
border: 1px solid #ddd;
7-
border-radius: 8px;
8-
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
3+
width: 100%;
4+
max-width: 100%;
5+
box-sizing: border-box;
6+
margin: 1.2rem 0;
7+
background: none;
8+
box-shadow: none;
9+
padding: 0.5rem;
10+
border: 1px solid #ccc;
11+
border-radius: 4px;
912
}
1013

1114
.subfigure-container {
1215
position: absolute;
13-
top: 0;
14-
left: 0;
15-
width: 100%;
16-
height: 100%;
17-
background-color: #f9f9f9;
18-
padding: 1rem;
19-
border: 1px solid #ddd;
20-
border-top: none;
21-
border-radius: 0 0 8px 8px;
16+
inset: 0;
17+
background: none;
18+
padding: 0;
19+
border: none;
2220
}
2321

2422
.subfigure-container.active {
2523
position: relative;
26-
opacity: 1;
27-
pointer-events: auto;
28-
z-index: 1;
2924
}
3025

3126
.subfigure-container.inactive {
@@ -37,42 +32,76 @@
3732
/* Tabs container: display buttons inline with a bottom border to indicate grouping */
3833
.tabs-container {
3934
display: flex;
40-
border-bottom: 2px solid #007acc;
41-
margin-bottom: 0.5rem;
35+
justify-content: flex-start;
36+
gap: 0;
37+
margin-bottom: 0.4rem;
4238
}
4339

44-
/* Figure tab button styling */
40+
4541
.figure-tab {
46-
background: transparent;
42+
background: none;
4743
border: none;
48-
outline: none;
49-
padding: 0.5rem 1rem;
50-
margin-right: 0.3rem;
51-
font-size: 1rem;
52-
color: #007acc;
44+
font-size: 0.9rem;
45+
color: #444;
5346
cursor: pointer;
54-
border-radius: 4px 4px 0 0;
55-
transition: background-color 0.2s ease, color 0.2s ease;
47+
border: 1px solid #ccc;
48+
padding: 0.2rem 0.5rem;
49+
}
50+
51+
.figure-tab:hover {
52+
color: #000; /* subtle darkening on hover */
53+
background: none; /* no hover background */
5654
}
5755

58-
.figure-tab:hover,
59-
.figure-tab.active {
60-
background-color: #007acc;
61-
color: #fff;
56+
57+
.export-container {
58+
display: flex;
59+
justify-content: flex-end;
60+
gap: 0.3rem;
61+
margin-bottom: 0.3rem;
6262
}
6363

6464
.export-container button {
65-
background-color: #007acc;
66-
color: #fff;
65+
background: none;
66+
color: #666;
6767
border: none;
68-
padding: 0.4rem 0.8rem;
69-
margin-right: 0.4rem;
70-
border-radius: 4px;
68+
padding: 0;
69+
font-size: 0.75rem;
7170
cursor: pointer;
72-
font-size: 0.9rem;
73-
transition: background-color 0.2s ease;
71+
text-decoration: underline;
7472
}
7573

7674
.export-container button:hover {
77-
background-color: #005fa3;
78-
}
75+
color: #000;
76+
}
77+
78+
.exampleblock.plot{
79+
border: 1px solid #ccc;
80+
border-radius: 4px;
81+
}
82+
83+
/* Example block styling for plots */
84+
.exampleblock.plot,.exampleblock.grid,.exampleblock.image {
85+
border: none;
86+
padding: 0;
87+
margin: 1.5rem 0;
88+
display: flex;
89+
flex-direction: column;
90+
}
91+
92+
.exampleblock.plot>.content,.exampleblock.grid>.content ,.exampleblock.image>.content {
93+
order: 1;
94+
padding: 0;
95+
border: none;
96+
}
97+
98+
.exampleblock.plot>.title,.exampleblock.grid>.title,.exampleblock.image>.title, .plotly-figure-caption{
99+
order: 2;
100+
text-align: center;
101+
font-style: italic;
102+
margin-top: 0.5rem;
103+
}
104+
105+
.exampleblock.example {
106+
border-left: 4px solid var(--brand-primary);
107+
}

docs/modules/json_report/pages/json_schema/content/figure.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ The **Plot Node** defines a data visualization within the report. It specifies t
1010
|===
1111
|Field|Type|Description|Default Value
1212

13+
|`id`|string| *Optional.* Identifies the plot node within the report. Used for internal cross referencing |`null`
1314
|`type`|string|Must be set to `"plot"`.|`"plot"`
15+
|`caption`|string|*Optional.* A descriptive caption for the figure.|`null`
1416
|`ref`|string|The unique `name` of the data file (from the root `data` list) to reference for building the figure.|*Required*
1517
|`plot`|object|The nested configuration object (`Plot` schema) defining the figure's dimensions, type, and transformation.|*Required*
1618
|===

docs/modules/json_report/pages/json_schema/content/grid.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
= Grid Node
22

3-
The **Grid Node** is a layout node that can be used to structure content into a grid.
3+
The **Grid Node** is a layout node that can be used to structure content into a grid. Mainly used to arrange images, plots, or tables side by side in a visually appealing manner. Sub figures or sub plots can be created using this node, but numbering and labeling must be handled manually within the captions of the child nodes.
44

55
|===
66
|Field|Type|Description|Default Value
77

8+
|`id`|string| *Optional.* Identifies the grid node within the report. Used for internal cross referencing |`null`
89
|`type`|string|Must be set to `"grid"`.|`"grid"`
10+
|`caption`|string|*Optional.* A descriptive caption for the grid.|`null`
911
|`contents`|array of objects| A list of other (non-recursive) content nodes.|[]
1012
|columns|int| Number of columns for the grid. Must be between 1 and 4.| 1
1113
|gap|int| Must be beween 1 and 3| 2.

docs/modules/json_report/pages/json_schema/content/image.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ The `src` file path is typically resolved relative to the passed configuration f
1212
|===
1313
|Field|Type|Description|Default Value
1414

15+
|`id`|string| *Optional.* Identifies the image node within the report. Used for internal cross referencing |`null`
1516
|`type`|string|Must be set to `"image"`.|`"image"`
17+
|`caption`|string|*Optional.* A descriptive caption for the image.|`null`
1618
|`src`|string|The file path or URL of the image to embed.|*Required*
1719
|`caption`|string|An optional caption displayed beneath the image. If provided, the image is rendered using the `title` attribute in AsciiDoc.|`null`
1820
|`alt`|string|Alternative text for the image, used for accessibility and when the image cannot be displayed.|`null`

docs/modules/json_report/pages/json_schema/content/latex.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The **LaTeX Node** is designed for the direct embedding of mathematical formulas
55
|===
66
|Field|Type|Description|Default Value
77

8+
|`id`|string| *Optional.* Identifies the LaTeX node within the report. Used for internal cross referencing |`null`
9+
|`is_equation`|boolean|*Optional.* Indicates if the LaTeX content represents a standalone equation. It adds `\begin\{equation\}` and `\end\{equation\}` around the content if true.|`false`
810
|`type`|string|Must be set to `"latex"`.|`"latex"`
911
|`latex`|string|The raw LaTeX content (e.g., a mathematical equation or a custom LaTeX block).|*Required*
1012
|`ref`|string|The `name` of the data field to reference for dynamic placeholder resolution.|`null`

docs/modules/json_report/pages/json_schema/content/list.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ The **List Node** is used to render ordered lists. Its primary strength is that
77
|===
88
|Field|Type|Description|Default Value
99

10+
|`id`|string| *Optional.* Identifies the list node within the report. Used for internal cross referencing |`null`
1011
|`type`|string|Must be set to `"itemize"`.|`"itemize"`
1112
|`items`|array of objects/strings|The contents of the list. Each entry can be a simple string, a full `Text Node` object, or a `Text Configuration` object.|*Required*
1213
|`ref`|string|The `name` of the data field to reference for dynamic placeholder resolution within all list items.|`null`

docs/modules/json_report/pages/json_schema/content/section.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The **Section Node** is the fundamental building block for structuring your repo
55
|===
66
|Field|Type|Description|Default Value
77

8+
|`id`|string| *Optional.* Identifies the section node within the report. Used for internal cross referencing |`null`
89
|`type`|string|Must be set to `"section"`.|`"section"`
910
|`title`|string|The title of the section.|*Required*
1011
|`contents`|array of objects|A recursive list of other content nodes, including nested `SectionNode`s.| []

docs/modules/json_report/pages/json_schema/content/table.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The structure is composed of the `TableNode` container and the nested `Table` co
1010
|===
1111
|Field|Type|Description|Default Value
1212

13+
14+
|`id`|string| *Optional.* Identifies the table node within the report. Used for internal cross referencing |`null`
1315
|`type`|string|Must be set to `"table"`.|`"table"`
1416
|`ref`|string|The unique reference of the data file (from the root `data` list) containing the table to be rendered.|*Required*
1517
|`caption`|string|*Optional.* Table caption.| `null`

docs/modules/json_report/pages/json_schema/content/text.adoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ The **Text Node** is used to insert narrative content into your report. It suppo
55
|===
66
|Field|Type|Description|Default Value
77

8+
|`id`|string| *Optional.* Identifies the text node within the report. Used for internal cross referencing |`null`
89
|`type`|string|Must be set to `"text"`.|`"text"`
910
|`text`|string or object|The text content or a nested `Text` object.|*Required*
1011
|`ref`|string|The `name` of the data field to reference for dynamic placeholder resolution.|`null`
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
= Internal Cross References
2+
3+
It is possible to assign an optional unique identifier to any content node within the JSON report schema. This identifier can then be used to create internal cross-references within the report, allowing for easy navigation between different sections or elements.
4+
5+
== Assigning Identifiers
6+
7+
To assign an identifier to a content node, include the `id` field in the node's JSON object. The value of this field should be a unique string that serves as the identifier for that node.
8+
9+
[source,json]
10+
----
11+
{
12+
"type": "section",
13+
"id": "introduction",
14+
"title": "Introduction",
15+
"contents": [
16+
// Other content nodes
17+
]
18+
}
19+
----
20+
In this example, the section node is assigned the identifier `"introduction"`.
21+
22+
[IMPORTANT]
23+
Ensure that each id contains only alphanumeric characters, underscores, or hyphens, and does not start with a number. This ensures compatibility with AsciiDoc cross-referencing conventions.
24+
25+
== Figure and Table Numbering
26+
27+
Tables, figures and images are automatically numbered in the order they appear in the report. However, tables will be prefixed with "Table", figures, plots and images will be prefixed with "Figure". This means that automatic numbering will be independent between tables and figures/images.
28+
29+
[IMPORTANT]
30+
Elements included inside a grid node are NOT automatically numbered. You must manually include numbering in the caption if desired (e.g. "Figure 1a: ..."). The counter for the automatic numbering will not be incremented for these elements.
31+
32+
== Creating Cross-References
33+
34+
To create a cross-reference to a content node with an assigned identifier, use the link:https://docs.asciidoctor.org/asciidoc/latest/macros/xref/#internal-cross-references[AsciiDoc cross-referencing syntax]. The format is `\<<id, Display Text>>`, where `id` is the identifier of the target node, and `Display Text` is the text that will be displayed as the link in the report.
35+
36+
[source,asciidoc]
37+
----
38+
See <<introduction, Introduction Section>> for more details.
39+
----
40+
41+
In this example, the text "Introduction Section" will be a clickable link that navigates to the section with the identifier `"introduction"`.
42+
43+
[TIP]
44+
For images, figures and tables, it is possible to reference via their caption without the use of an explicit id (though it is discouraged for clarity). To do so, remove any parentheses from the reference, and replace spaces with hyphens. For example, if a table has the caption "Performance Metrics", you can reference it using `\<<Performance-Metrics>>`.
45+
46+
[IMPORTANT]
47+
Ensure that the identifiers used in cross-references match exactly with those assigned to the content nodes, including case sensitivity. Mismatched identifiers will result in broken links in the final report.
48+
49+
== Example
50+
51+
[source,json]
52+
----
53+
{
54+
"contents": [
55+
{
56+
"type":"text",
57+
"id":"intro_text",
58+
"text":"Welcome to the report."
59+
},
60+
{
61+
"type":"section",
62+
"id":"data_analysis",
63+
"title":"Data Analysis",
64+
"contents":[
65+
{
66+
"type":"table",
67+
"id":"results_table",
68+
"ref":"results_data",
69+
"caption":"Results Overview"
70+
},
71+
{
72+
"type":"text",
73+
"text":"Refer to <<intro_text, the introduction>> for context."
74+
}
75+
]
76+
},
77+
{
78+
"type":"text",
79+
"text":"See <<results_table, the results table>> for detailed metrics."
80+
}
81+
]
82+
}
83+
----

0 commit comments

Comments
 (0)