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
Inconsistent style in table cells with some monospaced text #4535
Comments
That selector is there for a reason. The background on an isolated code span in a table cell looks terrible, so the stylesheet intentionally overrides this.
When a column has only monospace text, it should have the Unfortunately, based on the HTML that Asciidoctor produces, there's no way to differentiate between a normal table cell with a single code span and a monospace table cell. However, what I might consider is only applying this rule if the code span has no CSS class (no role). That would allow you to preserve the inline styling of the code span by adding a role.
The name of the role wouldn't matter. This seems like a reasonable compromise to consider. |
I get that and I didn't mean to suggest removing it. Sorry if my message could be interpret that way.
Yes, I just felt the example was simpler this way. Both methods produce identical HTML.
That would be prettier in the HTML output than What do you think about adding a class for table cells that use the monospace ( I had never written any Ruby before but this change to html5.rb line 910 appears to do something useful (although I suspect it's not good as is since it only modifies the first
The CSS selector would then become This wouldn't be perfectly backwards compatible because tables that don't use the |
And I think they should because it is not a quirk, it's a design. A cell with just monospace text should be displayed not as a code span, but as monospace text. If they want it to appear as a code span, then they need to specify it as such. This is how you can get two different appearances. Logically, there's just no other way it can be.
That's a significant change (since it modifies the HTML) and I don't think we can rely on it until at least a minor version (as you suggested), perhaps even a major one (in the latter case, it would be more suitable for the new HTML converter in development). With that said, I still think that a normal cell with a single code span should look the same as a monospace table cell. There are cases when you need to use that form to achieve something (such as to add a note). That's why I think using the role is the more adequate solution. It allows you to control which style you get all of the time. |
I apologize if I'm wrong but I suspect that my main point hasn't been understood. In my first message, the first column of the table looks great without the gray background; I don't want to change the style in the first column. However, in the second column, there are three monospace I originally noticed this in a table where the cells had a few sentences of text. In one cell the gray background was missing from a monospaced word in the middle of a sentence. In the second cell, a monospaced word in a similar sentence did have the gray background. The generated HTML looked similar for both cells and I was confused for a moment. Then I realized that the word in the second cell had the gray background because another sentence in the same cell had an emphasized word in it. It wasn't intuitive that emphasizing a word in one sentence affects the style of a word in another sentence. Is it an intentional and desired part of the design that only two of the three If yes, then your suggestion about applying the style only when the code span has no role might be a good workaround (it's better than using
I agree now. The idea in my previous message isn't good. (The rest of this message was written with the assumption that the three cooks example is not desired behavior and that it's worth fixing.) Below is another attempt at code. It would use the same
It checks if a paragraph in a cell consist of a single
It checks that there is no
That checks rejects nested
Changing the HTML output by adding the A new stylesheet would have the new selector. If a new stylesheet was used with HTML from an old Asciidoctor version then unwanted gray backgrounds would appear. I don't see other compatibility considerations now but it doesn't mean there aren't any. Is this kind of change wanted at all? Is using a regex to match the I apologize for being so insistent if my thoughts on this actually are on a wrong track. Thanks for reading! |
Yes, because given the tools we have available in CSS, there's no way to distinguish between a code span that is the only child and a code span that is preceded or followed by text. It's a limitation of CSS. It thinks an element surrounded by only text is an only child (which is clearly wrong, but CSS is just broken in this case). With my proposal, if you want to ensure there is a background, you have to add a role to the code that is surrounded by only text (for example,
We could add a CSS class to the cell that is a monospace style, but that's a (minor) breaking change and can only be done in a minor or major release. This may be inconvenient, but it's just where we are.
Changing the HTML itself is a breaking change. |
One possible docinfo workaround in the interim is to use JavaScript to add the empty span in the case both a code span and text are detected in the same cell. Sometimes, JavaScript is just needed to patch what CSS gets wrong. |
|
I do understand what you're saying and I assure you that you're not being misunderstood. Your messages are clear. However, due to compatibility issues, the path forward is just not clear or easy. This is one of those situations where a CSS bug has broken an assumption made when designing the HTML (which was done over a decade ago). The assumption is that CSS can differentiate between a monospace cell and a default cell with monospace in it. I think it's perfectly reasonable to add more information into the HTML to avoid this kind of situation, which we can do in the new HTML converter, as I mentioned. |
Unfortunately yes. Firefox has
Thanks! I will keep that in mind. The other workarounds are starting to feel OK now that I understand the overall issue better.
In theory someone might have a document with Using Since there already are workarounds with similar-enough complexity as your suggestion, I guess it's not worth changing the stylesheet solely to add a new workaround variant. Custom table roles can be a workaround in some cases. The current
This may be nicer than needing to mark individual monospace strings in the cells.
Hasty frequent changes would be far more inconvenient. :-) The stability of the HTML output is appreciated.
Great! I know it will take time until the new HTML converter is out but it's good to hear that this detail has been taken into consideration. Thanks! |
Test case with the default stylesheet:
On the first row,
cook
doesn't have the gray background. On the other two rows it has the background.It happens because of this:
I get that it can make the first column in the table look better. The current implementation makes semantics and style mix a bit though because one may need to add an empty extra element to get the correct style when there is also non-monospace content in the table cell.
It's only a minor thing that is easy to work around once one is aware of it. The small details just grab one's attention when everything else looks very polished already. :-)
The text was updated successfully, but these errors were encountered: