diff options
author | ptmcg <ptmcg@austin.rr.com> | 2022-05-20 01:02:37 -0500 |
---|---|---|
committer | ptmcg <ptmcg@austin.rr.com> | 2022-05-20 01:02:37 -0500 |
commit | 3a256cc444258ecc1321001702672c65eb5d425a (patch) | |
tree | 651c3d2eeb6d830d7e086dd88bc31bacfae0899d /pyparsing/core.py | |
parent | 79fe2b54bc08c791383ca81d4701b5afdd3d7390 (diff) | |
download | pyparsing-git-3a256cc444258ecc1321001702672c65eb5d425a.tar.gz |
Add embed argument to create_diagram, to suppress DOCTYPE, HEAD, and BODY tags
Diffstat (limited to 'pyparsing/core.py')
-rw-r--r-- | pyparsing/core.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/pyparsing/core.py b/pyparsing/core.py index a806f5b..fb9d594 100644 --- a/pyparsing/core.py +++ b/pyparsing/core.py @@ -2170,6 +2170,7 @@ class ParserElement(ABC): vertical: int = 3, show_results_names: bool = False, show_groups: bool = False, + embed: bool = False, **kwargs, ) -> None: """ @@ -2183,6 +2184,8 @@ class ParserElement(ABC): - show_results_names - bool flag whether diagram should show annotations for defined results names - show_groups - bool flag whether groups should be highlighted with an unlabeled surrounding box + - embed - bool flag whether generated HTML should omit <HEAD>, <BODY>, and <DOCTYPE> tags to embed + the resulting HTML in an enclosing HTML source Additional diagram-formatting keyword arguments can also be included; see railroad.Diagram class. """ @@ -2205,10 +2208,10 @@ class ParserElement(ABC): ) if isinstance(output_html, (str, Path)): with open(output_html, "w", encoding="utf-8") as diag_file: - diag_file.write(railroad_to_html(railroad)) + diag_file.write(railroad_to_html(railroad, embed=embed)) else: # we were passed a file-like object, just write to it - output_html.write(railroad_to_html(railroad)) + output_html.write(railroad_to_html(railroad, embed=embed)) setDefaultWhitespaceChars = set_default_whitespace_chars inlineLiteralsUsing = inline_literals_using |