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

[bug] \n Displayed in Cable Notes #86

Closed
davidrea opened this issue Jul 14, 2020 · 6 comments
Closed

[bug] \n Displayed in Cable Notes #86

davidrea opened this issue Jul 14, 2020 · 6 comments

Comments

@davidrea
Copy link

Adding a \n escaped character works to insert a line break in:

  • Connector notes: entities
  • Connector type: and subtype: entities

But the \n escaped character is printed in cable notes: entities:

image

Source for above:

connectors:

  P1:
    type: Socket housing
    subtype: Molex SL\n50579406
    pinout: [VDD, SWCLK, GND, SWDIO, NRST, SWO]
    notes: "Terminal: 16020086 or equiv."

  P2:
    type: Pin header
    subtype: Adam Tech\nBHR-20-VUA\nor Equiv.
    pinout: [VCC, VCC (optional), TRST, GND, TDI, GND, DIO/TMS, GND, DCK/TCK, GND, RTCK, GND, SWO/TDO, GND, NRST, GND, NC, GND, NC, GND]
    notes: Solder wires to pins,\nheat shrink individually

cables:
  W1:
    gauge: 24 AWG
    length: 0.2
    wirecount: 6
    category: bundle
    colors: [RD, GY, BK, GY, GY, GY]
    notes: Stranded,\nHeat shrink bundle 2 plcs
    # ^^^ this line contains printed \n ^^^

connections:
  -
    - P1: [1, 2, 3, 4, 5, 6]
    - W1: [1, 2, 3, 4, 5, 6]
    - P2: [1, 9, 4, 7, 15, 13]
@davidrea davidrea changed the title \n works in connector notes, not \n displayed in cable notes Jul 14, 2020
@davidrea davidrea changed the title \n displayed in cable notes \n Displayed in Cable Notes Jul 14, 2020
@davidrea
Copy link
Author

Just tacking onto this, \n escaped characters also appear in HTML BOM:

image

@formatc1702
Copy link
Collaborator

Thanks for the heads up. I can't look at the issue in detail now, but I can offer solution that (IMHO) is more elegant than using \n for new lines, since YAML supports multiline strings natively.
The code below fixes both the rendering and BOM issues:

connectors:
  P1:
    type: Socket housing
    subtype: |
      Molex SL
      50579406
    pinout: [VDD, SWCLK, GND, SWDIO, NRST, SWO]
    notes: "Terminal: 16020086 or equiv."

  P2:
    type: Pin header
    subtype: |
      Adam Tech
      BHR-20-VUA
      or Equiv.
    pinout: [VCC, VCC (optional), TRST, GND, TDI, GND, DIO/TMS, GND, DCK/TCK, GND, RTCK, GND, SWO/TDO, GND, NRST, GND, NC, GND, NC, GND]
    notes: |
      Solder wires to pins,
      heat shrink individually

cables:
  W1:
    gauge: 24 AWG
    length: 0.2
    wirecount: 6
    category: bundle
    colors: [RD, GY, BK, GY, GY, GY]
    notes: |
      Stranded,
      Heat shrink bundle 2 plcs

connections:
  -
    - P1: [1, 2, 3, 4, 5, 6]
    - W1: [1, 2, 3, 4, 5, 6]
    - P2: [1, 9, 4, 7, 15, 13]

I will still keep this open, but I'm unsure whether converting \n to newline is something that should be implemented if there is a more standard way in YAML.

@formatc1702
Copy link
Collaborator

formatc1702 commented Jul 14, 2020

Looking at the Flow Scalars section on yaml-multiline.info, it seems that not converting \n into a newline for plain strings is the expected behavior. I can't say why it does work in connectors and not in cables... would need some time to do more testing.

I can confirm that, putting the cable's notes info in double quotes does convert \n into the desired new line, matching the behavior described in the link above.

@formatc1702 formatc1702 changed the title \n Displayed in Cable Notes [bug] \n Displayed in Cable Notes Jul 14, 2020
@kvid
Copy link
Collaborator

kvid commented Jul 15, 2020

WireViz does not interprete the \n escape sequence, and sends it untouched to the output files, including the .gv file that is read by Graphviz. However, Graphviz does interprete several escape sequences and that is why the \n split the line in connector attributes that use shape=record. The wire nodes are formatted with HTML and the \n escape sequence is apparently not interpreted then (<BR/> is used to break the line in HTML).

@kvid
Copy link
Collaborator

kvid commented Jul 15, 2020

When testing the better approach with multi-line strings in YAML, I became aware of a minor inconsistency about horizontal alignment that I raised as the new issue #90

@davidrea
Copy link
Author

Thanks for the feedback on yaml, I wasn't aware of that! I'll switch to using the standard multiline input on this diagram.

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

No branches or pull requests

3 participants