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

[Workflow] remove new lines from workflow metadata #49272

Merged

Conversation

alexislefebvre
Copy link
Contributor

@alexislefebvre alexislefebvre commented Feb 6, 2023

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Tickets Fix #49174
License MIT
Doc PR no

Don't dump new lines in workflow dumps.

@carsonbot carsonbot added this to the 5.4 milestone Feb 6, 2023
@carsonbot carsonbot changed the title remove new lines from workflow metadata [Workflow] remove new lines from workflow metadata Feb 7, 2023
@alexislefebvre alexislefebvre force-pushed the 5.4-remove-new-lines-from-workflow-metadata branch from f295de1 to f0e8f16 Compare February 7, 2023 22:04
@alexislefebvre
Copy link
Contributor Author

Thanks for the reviews, suggestions have been taken into account.

@lyrixx
Copy link
Member

lyrixx commented Feb 8, 2023

I forgot to ask, are you sur other dumper needs this patch?

@alexislefebvre
Copy link
Contributor Author

I used the sanitizer so that the tests are not broken but I don't know if Mermaid or Graphviz accept new lines.

@lyrixx
Copy link
Member

lyrixx commented Feb 8, 2023

IMHO, you should fix only what is broken ; so there is not need for the trait anymore I guess.

Sorrry to go back and forth!

@alexislefebvre
Copy link
Contributor Author

Fair enough, let's not remove new lines if the tools support them, I'll check later.

Status: Needs work

@alexislefebvre
Copy link
Contributor Author

It took some examples and added new lines in the transitions.

Graphviz Dot

With this input:

Passing it to the Docker image nshine/dot gives this output:

dot

New lines don't cause errors, and they appear in the result. ✔️

Mermaid

Adding a new line in any transition in the live editor results in a Parse error.

I'm pretty sure that the live editor behaves like Mermaid, so I didn't test further. ❎

Summary

Symfony can keep new lines in the Graphviz dumper. The other formats need new lines to be removed.

@alexislefebvre
Copy link
Contributor Author

Status: Needs review

@fabpot fabpot force-pushed the 5.4-remove-new-lines-from-workflow-metadata branch from d320dfa to a3062c7 Compare February 20, 2023 13:29
@fabpot
Copy link
Member

fabpot commented Feb 20, 2023

Thank you @alexislefebvre.

@fabpot fabpot merged commit 6627291 into symfony:5.4 Feb 20, 2023
@alexislefebvre alexislefebvre deleted the 5.4-remove-new-lines-from-workflow-metadata branch February 23, 2023 19:21
nicolas-grekas added a commit that referenced this pull request Feb 24, 2023
… when rendering a PUML dump (alexislefebvre)

This PR was merged into the 5.4 branch.

Discussion
----------

[Workflow] display label with new lines + colours properly when rendering a PUML dump

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #49311
| License       | MIT
| Doc PR        | no

In #49272 I removed the new lines instead of formatting them properly.

The PUML format accept new lines in labels of transitions as long as the source file uses actual `\n` strings instead of line returns (like `PHP_EOL`).

I propose a novel approach that will handle new lines with or without colours.

Compare these outputs from plantuml.com, inputs are based on the [fixtures from Symfony](https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Workflow/Tests/fixtures/puml/arrow/complex-state-machine-marking.puml):

### After #49272

New lines are ignored

> ![image](https://user-images.githubusercontent.com/2071331/221030067-5d93b400-493d-4fb2-92d4-5c1490f6d1db.png)

([source](https://www.plantuml.com/plantuml/uml/TOx1IWCn48RlUOeXFHTfgxR8kfIjwCbB5Jo8I3OPsx2Jf2HPj8ZlRfAwKgJc5Bx_ctzc6QBmiJV4195xVpNwGziDYpeImeCsEy8RBJPU61OwRNSY_Q2aZVCA_ThrLgsSj-XXSd7QUTngsLaC0QP7GbeS4JuPfDS8sMtyeOgShofjTTI2wXf6YtaxFv-Srepm7QfipHQB-UgoM8UbnVY77qysb4fBVkji_9i-RNL4ziKEntB1uUYsWRPy-CcS3yC3L9pbmV6upkeLy3X9H2NoF5gZUldbrLkw06G-uVhEuxw-tuFiGtG6eXSsfBNE0eaM2MRLMRRhrDIMfePwB5Moh9Z-19ceGcQSBT6gtj0t))

### Correct output from this PR

With this patch → the second line is Grey and no tag is visible

> ![image](https://user-images.githubusercontent.com/2071331/221025433-81033dfb-cc52-4087-bae8-7560a6c528ba.png)

([source](https://www.plantuml.com/plantuml/uml/TP9DImCn48Rl-HL3UYxILcsHTIbRqPENAdXGaMmojc7pKP8iMiJ_RfBjwg9rJ-6PP-Pz3xlqWRdGQaMOKlRjHSjtQJOaoA0GxgJUARoIREEO9hwHPiVY2_AqiawWMzlMY9Lr1XrCpeuxzrl96uFUmtGWnE20y44WVXNZpSPrfvHrHI6D39AfieJHObxFJoV7DSrSWo9PiyLYlZhFLXUQZN_uSBDIyMYUNriJVayVjZ8W-IHTMSee3BhrjARzYrFuMUwXe2GjZiTbKY-0Xaaa8fB7qHh5ypSlNcC3uAd2vOt3VNcx1zxwO3K4nuoFiTOK9yagdymVMx4Q5SmEGeoeSqIbMimPF6TF3uD4H2OpIfPeHFe7lW00))

---

### Why close and open `<font>` tags?

The output is broken if we use `\n` without taking into account the `<font>` tags → there is a second line but it is black and `</font>` is visible

> ![image](https://user-images.githubusercontent.com/2071331/221025397-153357d1-6518-49db-8596-f8c680827afd.png)

([source](https://www.plantuml.com/plantuml/uml/TP5VI_Cm5CRlyoaEsVLusVRgYjGoEj4hRwRWXOgaoR4BpP-HfEWGlxj9QgN8x5NuFR_pd0FT-C1SwBKYJ2dxzgBbkpGj2J8eX3kf3mgl96iTqyHtqXnOV45EQ-i4kftjZTXQPz31ukoqSx-Nl3FeFImdGbmS43u8nAzcl6lTKAMiAqjfP91CLHNCYdMp_hyuhMdcEXJ9MXN5UdkUhM5fDlxWqybQnTASNriJVgSFUncGV9BXMCeeJ6uRQKF75q_vE3n2GKaQdC-hf5u03Oj8H2IFinsAvnzUliOBWASJBcyS7glR8_3U1wiXE6PyN6lDar6iGGMhyb_IgrZLvAfQzPYxUDwn_0uI4PciADcW4UbVVm40))

Commits
-------

361dce2 fix style of label containing new lines in PUML dump
This was referenced Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants