Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error parsing PUML file with 2 consecutive !include statements #23

Closed
derekmcn1 opened this issue Jun 13, 2022 · 1 comment · Fixed by #24
Closed

Error parsing PUML file with 2 consecutive !include statements #23

derekmcn1 opened this issue Jun 13, 2022 · 1 comment · Fixed by #24

Comments

@derekmcn1
Copy link
Contributor

Using mkdocs-build-plantuml-plugin 1.7.3, if there are 2 !include statements in a PUML file, without an extra line between them, like so:

!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4.puml
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Context.puml

an error is returned during processing

Converting /Users/foo/repo/docs/diagrams/src/blah.puml
Wrong response status for data-sci-env-context.puml: 400

After debugging this, I narrowed it down to the _readFileRec function in plantuml.py.

195     # Reads the file recursively
196     def _readFileRec(self, lines, temp_file, diagram, directory, dark_mode):
197
198         for line in lines:
199             line = line.strip()
200             if line.startswith("!include"):
201                 temp_file = self._readInclLine(
202                     diagram, line, temp_file, directory, dark_mode
203                 )
204             else:
205                 temp_file += line
206                 if "\n" not in line:
207                     temp_file += "\n"
208
209         return temp_file

If we are being called recursively because of an !include in a base PUML file, (i.e. line 201), and the included file does not end in a newline, then the next line read from the base file will be added to the end of the last line from the included file. This causes a syntax error when parsed by the PlantUML server..

A workaround is to put a blank line in between the 2 !include statements, thus resulting in a newline between the end of the included file and the next line in the base file.

Will provide a fix via a PR.

@christo-ph
Copy link
Collaborator

Released under 1.7.4

Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants