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

Newlines are not kept in longDescription #51

Closed
alranel opened this issue Mar 19, 2019 · 5 comments · Fixed by #180
Closed

Newlines are not kept in longDescription #51

alranel opened this issue Mar 19, 2019 · 5 comments · Fixed by #180
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@alranel
Copy link
Member

alranel commented Mar 19, 2019

As of now, the >- syntax is used for multiline fields. However this will not preserve newlines correctly. For instance:

    longDescription: |
      Agave è composto dai seguenti blocchi logici:

      * Un'**area amministrativa** (CMS)
      * Un **sito web statico** (Jekyll) contenente un **template** Jekyll

will be parsed as:

    longDescription: |-
      Agave è composto dai seguenti blocchi logici:
      * Un'**area amministrativa** (CMS) * Un **sito web statico** (Jekyll) contenente un **template** Jekyll

We need to use |- instead of >-, as explained here: https://yaml-multiline.info

I think this change should only apply to longDescription, where we might expect text with newlines.

@alranel alranel added the bug Something isn't working label Mar 19, 2019
@alranel alranel added this to the 1.0 milestone Mar 19, 2019
@sebbalex
Copy link
Member

as for now the editor produce the longDescription field using > operator

@sebbalex
Copy link
Member

Library used for yaml conversion manages long string field in a proper logic way. Since this PR#181 related to issue #66 adds this behaviour.
Actually there is no parameter to set folded/literal scalar block.

To achieve our goal we have two ways in front of us:

  • go back to html format and use <br /> tag to manage newlines and translate back to markdown in parser.
  • set the lineWidth parameter (doc) to force the | operator but we will have very long line in yaml, so bad for readability.

@alranel alranel modified the milestones: 1.0, 1.1 Mar 25, 2019
@alranel
Copy link
Member Author

alranel commented Apr 8, 2019

Further testing shows that publiccode-editor generates valid YAML. It tries to be smart to sometimes it uses > and other times it uses |. When > is used, additional newlines are inserted in the document, for example:

foo: >
  * foo
  
  * bar

This seems to be correctly parsed as * foo\n*bar because > collapses multiple newlines, so the round-trip is correct. However, the YAML file becomes not user-friendly and easy to edit because a human would never understand why double newlines should be inserted in a Markdown list.
We probably need a way for forcing | so that the YAML file contains literal strings and stays human-editable.

@alranel alranel removed this from the 1.1 milestone Apr 8, 2019
@alranel alranel added the enhancement New feature or request label Apr 8, 2019
@bfabio
Copy link
Member

bfabio commented Nov 5, 2019

This depends on nodeca/js-yaml#515 being merged, unless we want to workaround it.

@bfabio bfabio self-assigned this Oct 8, 2020
@bfabio
Copy link
Member

bfabio commented Oct 8, 2020

@sebbalex @libremente Do we want to vendor js-yaml? An option would be to use patch-package until that PR is merged upstream.

bfabio added a commit to bfabio/publiccode-editor that referenced this issue Oct 14, 2020
Literal blocks allow us to preserve newlines correctly.
Use patch-package to patch js-yaml until a proper solution
reaches upstream.

Fix italia#51.
bfabio added a commit to bfabio/publiccode-editor that referenced this issue Nov 24, 2020
Literal blocks allow us to preserve newlines correctly.
Use patch-package to patch js-yaml until a proper solution
reaches upstream.

Fix italia#51.
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants