Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
Scripts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Specification Tools
Scripts
Commits
3a462976
Commit
3a462976
authored
10 months ago
by
Andreas Kraft
Browse files
Options
Downloads
Patches
Plain Diff
Improved marking of hanging paragraphs
parent
dbce0546
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
toMkdocs/toMkdocs.py
+9
-6
9 additions, 6 deletions
toMkdocs/toMkdocs.py
with
9 additions
and
6 deletions
toMkdocs/toMkdocs.py
+
9
−
6
View file @
3a462976
...
...
@@ -34,7 +34,7 @@ class LineType(Enum):
@dataclass
class
Line
:
"""
Represents a line in the markdown file.
"""
text
:
str
=
''
text
:
str
=
'
\n
'
lineType
:
LineType
=
LineType
.
TEXT
...
...
@@ -128,12 +128,13 @@ class Clause:
def
__len__
(
self
)
->
int
:
"""
Return the number of characters in the clause.
"""
Return the number of characters in the clause. This does not include
empty lines or lines that contain only whitespace.
Returns:
The number of characters in the clause.
"""
return
sum
([
len
(
l
.
text
)
for
l
in
self
.
lines
])
return
sum
([
len
(
l
.
text
.
strip
()
)
for
l
in
self
.
lines
])
_matchHeader
=
re
.
compile
(
r
'
(#+)\s+(.*)
'
,
re
.
IGNORECASE
)
...
...
@@ -341,11 +342,11 @@ def prepareForMkdocs(clauses:list[Clause], includeHangingParagraphs:bool = False
# Check if there is a sub-clause in the next clause
if
i
+
1
<
len
(
clauses
)
and
clauses
[
i
+
1
].
level
>
clause
.
level
:
# This is a hanging paragraph. Remove the text from the current clause.
print
(
f
'
[yellow]Hanging paragraph in clause
"
{
clause
.
title
}
"
{
"
(removed)
"
if
not
includeHangingParagraphs
else
"
(kept)
"
}
'
)
print
(
f
'
[yellow]Hanging paragraph in clause
"
{
clause
.
title
}
"
{
"
(removed)
"
if
not
includeHangingParagraphs
else
"
(kept
+ warning
)
"
}
'
)
if
not
includeHangingParagraphs
:
clauses
[
i
].
lines
=
[]
else
:
clauses
[
i
].
lines
=
[
Line
(
"
<mark>Editor note: This is a hanging paragraph and it must be moved to its own clause</mark>
"
)]
+
[
Line
()]
+
clauses
[
i
].
lines
clauses
[
i
].
lines
=
[
Line
(
'
<mark>Editor note: This is a hanging paragraph and it must be moved to its own clause</mark>
\n
'
),
Line
()]
+
clauses
[
i
].
lines
# Repair wrong markdown for indented lines.
# Add 2 spaces to existing 2-space indentions
...
...
@@ -510,7 +511,9 @@ def writeClauses(outClauses:list[Clause], filename:str, navTitle:str, addNavTitl
else
:
file
.
write
(
f
"
{
indentation
}{
'
'
*
f
.
level
}
-
'
{
_title
}
'
:
\n
"
)
if
len
(
f
)
>
0
:
file
.
write
(
f
"
{
indentation
}{
'
'
*
nextClause
.
level
}
-
'
Hanging paragraph
'
:
'
{
navTitle
}
/
{
f
.
clauseNumber
}
.md
'
\n
"
)
file
.
write
(
f
"
{
indentation
}{
'
'
*
nextClause
.
level
}
-
'
<mark>Hanging paragraph</mark>
'
:
'
{
navTitle
}
/
{
f
.
clauseNumber
}
.md
'
\n
"
)
if
verbose
:
print
(
f
'
[dim]Added hanging paragraph to navigation for clause
"
{
f
.
title
}
"'
)
def
copyMediaFiles
(
filename
:
str
,
navTitle
:
str
,
mediaDirectory
:
str
=
'
media
'
)
->
None
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment