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

Markdown/Code block compatible output #358

Merged
merged 2 commits into from
Jun 5, 2024

Conversation

peschmae
Copy link
Contributor

@peschmae peschmae commented Apr 8, 2024

The current output, while very readable, isn't compatible with syntax highlighting in markdown code blocks. Generally the code block output, is a special kind of human readable output, which needs to the very strict syntaxes of the highlighting library used.

What seems to be common is the requirement that the modifier, to highlight the line, needs to be at the beginning of the line without indentation, and only a full line can be highlighted (not single letters)

This pull requests implements a diff syntax highlighting compatible output, based on the HumanReport, with removed indentations, and a different prefix for paths, RootDescriptions and changeTypes (to avoid highlighting the introduction line for additiona & removal).
Additionally since only full lines can be coloured, the table style is disabled and multiline (as well as binary and certificate) changes, are prefixed continuously.

Using configurable prefixes, it's possible to easily support the Markdown code block on GitHub, GitLab, and Gitea/Forgejo, while ensuring it's easy to add support for further highlighting libraries (eg. for Bitbucket)

Fixes #325

@Arakos
Copy link

Arakos commented May 5, 2024

Great Feature, would like to see it added.

@MaxWinterstein
Copy link

Can confirm this works pretty nice for us 👍 Thanks

MarkdownReports are a special kind of human readable reports, and
are reusing the HumanReport code, but adapt the styling to conform
to diff syntax highlighting where necessary

Signed-off-by: Mathias Petermann <mathias.petermann@gmail.com>
Making the prefixes for blocks and paths configurable enables
to make the diff syntax compatible with different code
highlighters
For code blocks table output doesn't make sense, so it's always
disabled
For multiline changes like binary and certificates, the whole
block should be prefixed

Signed-off-by: Mathias Petermann <mathias.petermann@gmail.com>
@peschmae peschmae force-pushed the feat/markdown-using-indent branch from 1878428 to f8890da Compare May 31, 2024 07:44
@peschmae
Copy link
Contributor Author

@HeavyWombat Any chance to get some general feedback, or a review on this?

I've rebased the changes to the latest state of main

@HeavyWombat
Copy link
Member

@HeavyWombat Any chance to get some general feedback, or a review on this?

I've rebased the changes to the latest state of main

Thanks! I've been really busy lately, but still try to allocate time for my open-source projects.

Copy link

codecov bot commented Jun 3, 2024

Codecov Report

Attention: Patch coverage is 61.34969% with 63 lines in your changes missing coverage. Please review.

Project coverage is 81.24%. Comparing base (b5fc933) to head (f8890da).
Report is 1 commits behind head on main.

Files Patch % Lines
internal/cmd/common.go 5.88% 48 Missing ⚠️
pkg/dyff/output_diff_syntax.go 80.88% 7 Missing and 6 partials ⚠️
pkg/dyff/output_human.go 95.45% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #358      +/-   ##
==========================================
- Coverage   83.62%   81.24%   -2.39%     
==========================================
  Files          14       15       +1     
  Lines        1527     1658     +131     
==========================================
+ Hits         1277     1347      +70     
- Misses        184      239      +55     
- Partials       66       72       +6     
Flag Coverage Δ
unittests 81.24% <61.34%> (-2.39%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@HeavyWombat HeavyWombat left a comment

Choose a reason for hiding this comment

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

Thank you very much for this addition and I am sorry that you had to wade through some very old and ugly code of mine there.

@HeavyWombat HeavyWombat merged commit c7a780c into homeport:main Jun 5, 2024
6 checks passed
@peschmae
Copy link
Contributor Author

peschmae commented Jun 5, 2024

Nothing to be sorry about!

Thanks for developing this cool tool :)

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.

Feature request: GitHub markdown compatible diffs
4 participants