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

Add newline check for mdox-exec output #68

Merged
merged 2 commits into from
Aug 4, 2021

Conversation

saswatamcode
Copy link
Collaborator

This PR adds a check to ensure mdgen output for a command always has a new line at the end so that there are no surprising formatting issues. Test case added. Fixes #67.

Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
@saswatamcode saswatamcode self-assigned this Aug 1, 2021
Copy link
Owner

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

LGTM!

return b.Bytes(), nil
output := b.Bytes()
// Add newline to output if not present.
if !bytes.HasSuffix(output, []byte("\n")) {
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
if !bytes.HasSuffix(output, []byte("\n")) {
if !bytes.HasSuffix(output, newLineChar) {

.. to not creat slice every time? (micro-optimization, but also readability) and I think we already have newLineChar somewhere 🤔

Copy link
Owner

Choose a reason for hiding this comment

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

not a blocker

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

Signed-off-by: Saswata Mukherjee <saswataminsta@yahoo.com>
Copy link
Owner

@bwplotka bwplotka left a comment

Choose a reason for hiding this comment

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

thanks!

@bwplotka bwplotka merged commit 13fc035 into bwplotka:main Aug 4, 2021
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.

Check newline in mdox-exec output
2 participants