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

Inconsistent highlighting between code block and inline code #11911

Open
cderv opened this issue Jan 20, 2025 · 1 comment
Open

Inconsistent highlighting between code block and inline code #11911

cderv opened this issue Jan 20, 2025 · 1 comment
Assignees
Labels
bug Something isn't working themes Related to HTML theming or any other style related issue (like highlight-style)
Milestone

Comments

@cderv
Copy link
Collaborator

cderv commented Jan 20, 2025

Discussed in #11910

Originally posted by heinrichcarraro January 20, 2025

Description

I just noticed that the highlighting style of inline code and code blocks is entirely different. Is there some way to achieve a consistent highlighting style.

Example (Edited by @cderv to remove engine):

---
highlight-style: github
---


```{.julia}
Y::AbstractMatrix
```

And here the inline version `Y::AbstractMatrix`{.julia}.

The code block is correctly formatted using the GitHub style (as much as I can see), but the inline code has a completely different highlighting.

From what I can see in the produced html and css, this seems to be the case because there is a span missing right after the code opening. The current html for the inline code is something like

<code class="sourceCode julia">Y<span class="op">::</span><span class="dt">AbstractMatrix</span></code>

If I change this to

<code class="sourceCode Julia"><span>Y<span class="op">::</span><span class="dt">AbstractMatrix</span></span></code>

then the highlighting is correct, only the background is still wrong. Is there some way I can achieve this without some additional javascript?

@cderv
Copy link
Collaborator Author

cderv commented Jan 20, 2025

Putting back my comment from #11910 (reply in thread)


So this hapens when the style have a color for Normal

"Normal": {
"selected-text-color": "#24292e",
"text-color": "#24292e"
},

This is assigned to CSS rule in our Quarto processing

[
"pre > code.sourceCode > span",
"code span",
"code.sourceCode > span",
"div.sourceCode,\ndiv.sourceCode pre.sourceCode",
]
.forEach((selector) => {
lines.push(`\n${selector} {`);
lines.push(...cssValues);
lines.push("}\n");
});
}

but it gets higher precedence than other rules created for other tokens

if (abbr !== "") {
lines.push(`\ncode span.${abbr} {`);
lines.push(...cssValues);
lines.push("}\n");
} else {

Image

So this does not seem right.

This is old code from Charles, so I need to understand it well before trying to change anything, but it does not seem right 🤔

For context, I believe this processing exists because we need to support more highlight style than Pandoc itself (highlight-style: github is one of them)

Something does not seem correct in how we process Normal style in them file

@cderv cderv self-assigned this Jan 20, 2025
@cderv cderv added bug Something isn't working themes Related to HTML theming or any other style related issue (like highlight-style) labels Jan 20, 2025
@cderv cderv added this to the v1.7 milestone Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working themes Related to HTML theming or any other style related issue (like highlight-style)
Projects
None yet
Development

No branches or pull requests

1 participant