-
Notifications
You must be signed in to change notification settings - Fork 687
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
Don't change document graphics state when rendering with option dry_run in Text::Formatted::Box #736
Conversation
It looks like this behavior change is desirable, but I'm not comfortable introducing another instance variable here. Maybe pass an optional value into |
You're right. I changed it to an optional parameter. |
@@ -205,11 +205,12 @@ def initialize(formatted_text, options={}) | |||
# | |||
def render(flags={}) | |||
unprinted_text = [] | |||
dry_run = flags[:dry_run] === true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We probably don't need this line, as flags[:dry_run]
can be used directly in the two other places it is mentioned (213, 224)
There are many test failures on this pull request... please investigate those and let me know when the build is green again. |
…un in Text::Formatted::Box
I just updated the pull request and now the build passes without errors. |
From the looks of it, this will mutate the input data, meaning you can't safely pass the same array to the method twice (i.e. once for a dry run and then again to actually render). Please work on a solution that does not mutate the inputs. |
I don't know if I get you right, but the variable
|
I see, we do copy the input arguments. This is surprising because I'm still not sure how good I feel about this solution, though. It's extremely implicit behavior, and so I'm worried about breakage in future changes to this code. Really we should be having explicitly defined behavior for dry run vs. actual rendering, and not adding various checks for This isn't your fault, because it is how the code is designed currently. But I think we should give this more thought before merging. |
I get your point. Is there anything I can do here? Unfortunately I'm not that familiar with the codebase to do such a change. |
Sorry for the delay in response. I'd say if this patch is working for you, just use your fork until we get something similar merged upstream. |
I looked into fixing the underlying design issues for the dry run mechanism, but it's really complicated because the entire formatted text system is pretty tangled up. So as an alternative I basically applied your same patch in dd92069, but moved the code into a helper method just to make it less likely to be lost or broken during future refactorings. |
@ingk: Because your pull request was accepted, you now have commit access to Prawn. Please see our contributor guidelines, and happy hacking! |
Rendering a Text::Formatted::Box with the dry_run option led to output in the rendered PDF.