Toggle navigation
Toggle navigation
This project
Loading...
Sign in
万朱浩
/
Venue-Ops
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
马一丁
2025-11-15 15:23:05 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fd1a23c7fbeec69885838a79d4780295c9a530fd
fd1a23c7
1 parent
90d12a09
Improve IR Binding Logic
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
0 deletions
ReportEngine/core/stitcher.py
ReportEngine/core/stitcher.py
View file @
fd1a23c
...
...
@@ -51,6 +51,8 @@ class DocumentComposer:
anchor
=
chapter
.
get
(
"anchor"
)
or
f
"section-{idx}"
chapter
[
"anchor"
]
=
self
.
_ensure_unique_anchor
(
anchor
)
chapter
.
setdefault
(
"order"
,
idx
*
10
)
if
chapter
.
get
(
"errorPlaceholder"
):
self
.
_ensure_heading_block
(
chapter
)
document
=
{
"version"
:
IR_VERSION
,
...
...
@@ -76,5 +78,23 @@ class DocumentComposer:
self
.
_seen_anchors
.
add
(
anchor
)
return
anchor
def
_ensure_heading_block
(
self
,
chapter
:
Dict
[
str
,
object
])
->
None
:
"""保证占位章节仍然拥有可用于目录的heading block。"""
blocks
=
chapter
.
get
(
"blocks"
)
if
isinstance
(
blocks
,
list
):
for
block
in
blocks
:
if
isinstance
(
block
,
dict
)
and
block
.
get
(
"type"
)
==
"heading"
:
return
heading
=
{
"type"
:
"heading"
,
"level"
:
2
,
"text"
:
chapter
.
get
(
"title"
)
or
"占位章节"
,
"anchor"
:
chapter
.
get
(
"anchor"
),
}
if
isinstance
(
blocks
,
list
):
blocks
.
insert
(
0
,
heading
)
else
:
chapter
[
"blocks"
]
=
[
heading
]
__all__
=
[
"DocumentComposer"
]
...
...
Please
register
or
login
to post a comment