Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
CTI Tools
tosca2doc
Commits
0a2c03ff
Commit
0a2c03ff
authored
Jul 30, 2021
by
Miguel Angel Reina Ortega
Browse files
Bug 262 - Handling of newline character and end of text block
Signed-off-by:
reinaortega
<
miguelangel.reinaortega@etsi.org
>
parent
efd233d6
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/example.py
View file @
0a2c03ff
...
...
@@ -29,10 +29,17 @@ def is_body_of_example(line: str):
Returns true if the line is part of the body of an example.
'''
return
line
==
""
or
\
line
.
startswith
(
"
\n
"
)
or
\
line
.
startswith
(
"."
)
or
\
line
.
startswith
(
"#"
)
or
\
line
.
startswith
(
" "
)
or
\
bool
(
re
.
match
(
r
'^[a-zA-Z_]*:'
,
line
))
def
is_last_line
(
line
:
str
,
txt
):
'''
Returns true if it is the last line of the text.
'''
return
line
==
txt
[
len
(
txt
)
-
1
]
def
get_example_file_name
(
line
:
str
):
'''
...
...
@@ -88,6 +95,8 @@ def parse_all_examples(txt):
new_example
=
"# "
+
filename
+
"
\n
"
+
linetext
elif
new_example
!=
""
and
is_body_of_example
(
linetext
):
new_example
=
new_example
+
"
\n
"
+
linetext
if
is_last_line
(
line
,
txt
):
res
.
append
(
Example
(
filename
,
new_example
))
elif
len
(
new_example
)
>
0
:
res
.
append
(
Example
(
filename
,
new_example
))
new_example
=
""
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment