Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
badw-it
DHParser
Commits
c148e5ef
Commit
c148e5ef
authored
May 25, 2021
by
di68kap
Browse files
preprocess.py: Refactoring
parent
6f9992cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/LaTeX/LaTeXParser.py
View file @
c148e5ef
...
...
@@ -49,7 +49,7 @@ from DHParser import start_logging, suspend_logging, resume_logging, is_filename
positions_of
,
replace_tag_names
,
add_attributes
,
delimit_children
,
merge_connected
,
\
has_attr
,
has_parent
,
ThreadLocalSingletonFactory
,
Error
,
canonical_error_strings
,
\
has_errors
,
apply_unless
,
WARNING
,
ERROR
,
FATAL
,
EMPTY_NODE
,
TreeReduction
,
CombinedParser
,
\
Preprocess
e
rResult
,
preprocess_includes
,
gen_find_include_func
,
flatten_sxpr
,
\
Preprocess
o
rResult
,
preprocess_includes
,
gen_find_include_func
,
flatten_sxpr
,
\
replace_content_with
...
...
@@ -63,7 +63,7 @@ from DHParser import start_logging, suspend_logging, resume_logging, is_filename
RX_TEX_INPUT
=
r
'\\input{(?P<name>.*)}'
def
LaTeXPreprocessor
(
text
:
str
,
file_name
:
str
)
->
Preprocess
e
rResult
:
def
LaTeXPreprocessor
(
text
:
str
,
file_name
:
str
)
->
Preprocess
o
rResult
:
find_includes
=
gen_find_include_func
(
RX_TEX_INPUT
,
LaTeXGrammar
.
comment_rx__
)
return
preprocess_includes
(
text
,
file_name
,
find_includes
)
...
...
examples/LaTeX/tst_LaTeX_docs.py
View file @
c148e5ef
...
...
@@ -83,7 +83,7 @@ def tst_func():
doc
=
f
.
read
()
print
(
f
'
\n\n
Preprocessing document: "
{
file
}
"'
)
preprocessed
,
source_mapper
=
preprocessor
(
doc
,
file
)
preprocessed
,
_
,
source_mapper
=
preprocessor
(
doc
,
file
)
print
(
f
'
\n\n
Parsing document: "
{
file
}
"'
)
result
=
parser
(
preprocessed
)
print
(
"Number of CST-nodes: "
+
str
(
tree_size
(
result
)))
...
...
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