Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
513997e1
Commit
513997e1
authored
Feb 28, 2011
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utility to clean up converted from TeX rst docs
parent
4bb893aa
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
reformat.py
docroot/reformat.py
+42
-0
No files found.
docroot/reformat.py
0 → 100644
View file @
513997e1
import
os
,
sys
,
re
finput
=
open
(
sys
.
argv
[
1
],
"rt"
)
# read the whole file content to s
s
=
""
.
join
(
finput
.
readlines
())
finput
.
close
()
# normalize line endings
s
=
re
.
sub
(
r"\r\n"
,
"
\n
"
,
s
)
# remove trailing whitespaces
s
=
re
.
sub
(
r"[ \t]+\n"
,
"
\n
"
,
s
)
# compress multiple empty lines
for
i
in
range
(
5
):
s
=
re
.
sub
(
r"\n\n\n"
,
"
\n\n
"
,
s
)
# remove empty line before ".." that terminates a code block
s
=
re
.
sub
(
r"\n\n\.\.\n"
,
"
\n
..
\n
"
,
s
)
# move :: starting a code block to the end of previous line
s
=
re
.
sub
(
r"\n\n::\n"
,
" ::
\n
"
,
s
)
# remove extra line breaks before/after _ or ,
s
=
re
.
sub
(
r"\n[ \t]*([_,])\n"
,
r"\1"
,
s
)
# remove extra line breaks after `
s
=
re
.
sub
(
r"`\n"
,
"` "
,
s
)
# remove extra line breaks before `
s
=
re
.
sub
(
r"\n[ \t]*`"
,
" `"
,
s
)
# remove links to wiki
s
=
re
.
sub
(
r"\n[ \t]*`id=\d[^`]+`__\n"
,
""
,
s
)
# remove trailing whitespaces one more time
s
=
re
.
sub
(
r"[ \t]+\n"
,
"
\n
"
,
s
)
foutput
=
open
(
sys
.
argv
[
2
],
"wt"
)
foutput
.
write
(
s
)
foutput
.
close
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment