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

Use YAML Block Chomping Indicator to avoid ending line breaks #4

Merged
merged 1 commit into from
Jun 21, 2023

Conversation

jordanbtucker
Copy link
Contributor

This PR resolves #3.

@ArchLeaders ArchLeaders self-requested a review June 20, 2023 23:08
Copy link
Member

@ArchLeaders ArchLeaders left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this break desterilizing because there's an extra character now? (For context, msbt doesn't use a yaml deserializer, but rather just jumps through the characters).

https://github.com/EPD-Libraries/msbt/blob/main/src/msbt.cpp#L58-L83

@jordanbtucker
Copy link
Contributor Author

jordanbtucker commented Jun 20, 2023

I does not appear to break deserializing. The code appears to look for the next line that starts with two spaces after the : character. It doesn't even handle the | character at all.

In other words, the following entries all appear to be equivalent to the code.

Item_001: |
  Text_001
Item_001: |-
  Text_001
Item_001: |anything I want here
  Text_001

You can even test that with the current version of NxEditor.

Perhaps it would be better if the code searched for : |\n or : |-\n to be sure.

Even better if it parsed the text as actual YAML. Although that would add the invalid line breaks back in if the source YAML didn't use the chomping indicator.

@jordanbtucker
Copy link
Contributor Author

As an aside, MSBT::MSBT(std::string_view text) doesn't follow YAML correctly since it always strips out the ending line break regardless of a chomping indicator.

@ArchLeaders
Copy link
Member

I does not appear to break deserializing. The code appears to look for the next line that starts with two spaces after the : character. It doesn't even handle the | character at all.

In other words, the following entries all appear to be equivalent to the code.

Item_001: |
  Text_001
Item_001: |-
  Text_001
Item_001: |anything I want here
  Text_001

Perhaps it would be better if the code searched for : |\n or : |-\n to be sure.

Even better if it parsed the text as actual YAML. Although that would add the invalid line breaks back in if the source YAML didn't use the chomping indicator.

Ah right, and have you been able to test this or should I?

@jordanbtucker
Copy link
Contributor Author

I tried to test it, but I'm getting the following error when running ./msbt_to_yaml PouchContent.msbt.

terminate called without an active exception
Aborted

However, I get that error without my changes too, so there's something wrong with my build pipeline.

@ArchLeaders
Copy link
Member

Hm, I'll look into it later.

@ArchLeaders ArchLeaders merged commit bc58efe into EPD-Libraries:main Jun 21, 2023
@jordanbtucker jordanbtucker deleted the yaml-chomp branch June 21, 2023 20:08
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 this pull request may close these issues.

Use block-chomping indicator in yaml output
2 participants