-
Notifications
You must be signed in to change notification settings - Fork 743
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
resolves #1082 HTMLTable formatter delegates to format method of inner formatter #1083
resolves #1082 HTMLTable formatter delegates to format method of inner formatter #1083
Conversation
Note that this line wasn't doing anything: @inner.span(Token::Tokens::Text::Whitespace, "\n") { |str| formatted << str } I've restored the functionality of appending the newline, but I decided not to format it as whitespace. That makes the formatting inconsistent with how other newlines are handled. |
Is it really necessary to yield more than once? I'd like to write the yield statement as follows: yield %(<table class="#{@table_class}"><tbody><tr><td class="#{@gutter_class} gl"><pre class="lineno">#{formatted_line_numbers}</pre></td><td class="#{@code_class}"><pre>#{formatted}</pre></td></tr></tbody></table>) |
@mojavelinux This is separate to #1085, right? Will that have any impact on this? |
1388482
to
159bb0f
Compare
Yes, this is separate from #1085. However, the whole purpose of this change is so that it can be used in combination with the line-wise formatter. I'd still like to avoid the multiple yields, so I'm interested in getting feedback on that aspect. Yielding multiple times just seems wasteful. |
@mojavelinux I wonder if the multiple yields are a way of making the HTML easier to read without breaking the tests? When I try to use HEREDOC syntax with a single |
@pyrmont I'm fine with splitting up the string to make it easier to read, but the multiple calls to yield introduce a different contract. Whatever it's yielding to is now receiving disconnected fragments of HTML instead of something whole, making it virtually impossible to do anything meaningful with them. I think the HTML needs to be assembled first, then yielded. We're mixing style with function here. |
I'll make an attempt to yield once and verify we can still pass the tests. |
…od of inner formatter - HTMLTable formatter delegates to format method of inner formatter instead of span method - append trailing newline if missing (but don't wrap as whitespace token) - add test - only yield once in stream method of HTMLTable formatter
159bb0f
to
dcd2ded
Compare
I've updated as we discussed and all tests are passing. |
Thanks @mojavelinux :) |
@mojavelinux Is there a possibility that this introduced an extra newline at the end of the rendered output?
|
Yes, I believe so. It's this line: https://github.com/rouge-ruby/rouge/blob/master/lib/rouge/formatters/html_table.rb#L29. I don't remember whether that was supposed to be part of this PR or not. The rationale is that it's important for the end of the lines stay clean to allow postprocessing to operate on all lines in the same way. When the closing |
I'd recommend updating the test in Jekyll to make this trailing newline optional in the assertion. |
I see.. Thanks for the above insight. |
@mojavelinux One more question: What is |
It's a character literal. |
...and it's effectively a constant. |
TIL 🥂 to both of you 😄 |
resolves #1082