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

Allow formatting pre-diffed content #59

Closed
wants to merge 1 commit into from
Closed

Conversation

wilg
Copy link

@wilg wilg commented Mar 12, 2015

Proof-of-concept.

No tests currently, waiting to see if this is something that would be welcomed.

@samg
Copy link
Owner

samg commented Apr 12, 2015

Could you provide a bit more info on what you're looking to accomplish with this change? Why not just display the content and bypass diffy entirely? Thanks!

@wilg
Copy link
Author

wilg commented Apr 12, 2015

@samg For sure – I have the text of a git diff already, but I'd like to format it as HTML. I'd prefer to use the existing diff-text-to-html transformation you've already got without rolling my own.

@samg
Copy link
Owner

samg commented Apr 12, 2015

Ah, makes sense.

You may be able to accomplish this more easily by just using the html formatter class directly.

e.g.

Diffy::HtmlFormatter.new(`git diff`.split("\n")).to_s

It expects an enumerable object containing lines of text (e.g. an array or strings). Splitting your diff on newlines as shown above will likely get you the result you want.

Let me know if that works for you. If it does I may try to document that this is possible in the README so others with the same issue can figure it out without having to analyze the source code.

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.

2 participants