-
-
Notifications
You must be signed in to change notification settings - Fork 8k
markup/highlight: Adjust inline markup #9638
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
Conversation
2f28623
to
d3344a4
Compare
d3344a4
to
c235fcf
Compare
func (h *HightlightResult) Inner() template.HTML { | ||
h.innerInit.Do(func() { | ||
inner := string(h.highlighted[h.innerLow:h.innerHigh]) | ||
if h.inline { |
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.
/cc @kaushalmodi
I think this change will work. I would only suggest that the display:flex; regex be made stricter. If a user does Suggestion:
or
With that, even if the user has |
@kaushalmodi did you say something somewhere about the flex style? |
I haven't yet, but given that the current regex |
@bep I had opened an issue on chroma regarding Does this help from there?
|
inner := string(h.highlighted[h.innerLow:h.innerHigh]) | ||
if h.inline { | ||
inner = strings.Replace(inner, `<span class="line">`, `<span class="chroma inline">`, 1) | ||
inner = strings.Replace(inner, "display:flex;", "", -1) |
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.
@bep am I missing something or would this unconditionally replace the string display:flex;
anywhere in the user provided code snippet? For example what happens if I do this?
{{< highlight css "hl_inline=true" >}}.line { display:flex; }{{< /highlight >}}
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.
See #9638 (comment) 😄
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.
Yea, I will take another look at this today, I had a massive day of "doing everything on my list" yesterday, and this came in late ... I'm sure Chroma has a better API for this.
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.
@kaushalmodi ah, thankssorry I missed your comment I was just looking at the diffs.
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.
@marshall007 You might be interested in alecthomas/chroma#618. After that, these replaceRE hacks won't be needed in Hugo.
See my comment in alecthomas/chroma#617 (comment) We need to wait for a fix upstream, so I need to revert this "inline thing", but I'll keep this PR open so I can finish it when time is right. |
@bep This fix is waiting in the Chroma PR, and will need Hugo to use the new Thanks. |
@bep This PR was feature complete. Only the regex part was hacky, but those are internal details. Can you please merge this feature in, and then update the internal Chroma API when that gets fixed upstream? |
@bep Can you please take another look at this? The feature was working great with with regex fix 😃 . I'll really appreciate if this feature can go in first. When a proper fix arrives from upstream Chroma, that fix will be transparent to the users. |
Closes gohugoio#9442 Closes gohugoio#9635 Closes gohugoio#9638
Closes gohugoio#9442 Closes gohugoio#9635 Closes gohugoio#9638
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
See #9634
Closes #9635