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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

emoji is rendered in code blocks #4978

Closed
splashx opened this issue Jul 20, 2018 · 15 comments
Closed

emoji is rendered in code blocks #4978

splashx opened this issue Jul 20, 2018 · 15 comments

Comments

@splashx
Copy link

splashx commented Jul 20, 2018

I have enableEmoji: True and the following content in a page:

```
    :az:ab:cd:
```

It should be rendered as:

screen shot 2018-07-20 at 14 37 56

But instead I get an emoji 馃啂 instead of :ab: - picture:

screen shot 2018-07-20 at 14 36 52

$ hugo version
Hugo Static Site Generator v0.44/extended darwin/amd64 BuildDate: unknown

theme: vjeantet/hugo-theme-docdock [latest]

@kaushalmodi
Copy link
Member

kaushalmodi commented Jul 20, 2018

I confirm the bug. Though, it's a Blackfriday bug and an issue should be opened in Blackfriday's repo instead.

To fool Blackfriday, you can insert the ZERO WIDTH SPACE (0x200b) before the colons. Your code-block won't be then copy/pasteable, but it will atleast display as intended.


Update: Sorry for that misinformation; this is not related to Blackfriday.

@bep
Copy link
Member

bep commented Jul 20, 2018

I assume this is with enableemoji enabled, in which this is as designed. You can solve this by turning that off.

@kaushalmodi
Copy link
Member

kaushalmodi commented Jul 20, 2018

I assume this is with enableemoji enabled, in which this is as designed.

It's a bug.. why should Blackfriday Hugo render emojis in code blocks?


Update: See #4978 (comment) for clarification.

@bep
Copy link
Member

bep commented Jul 20, 2018

Blackfriday render emojis in code blocks?

Blackfriday doesn't render any emojis. Emoji is a Unicode character -- if you insert it into a document, the browser renders it.

@kaushalmodi
Copy link
Member

kaushalmodi commented Jul 20, 2018

Blackfriday doesn't render any emojis. Emoji is a Unicode character -- if you insert it into a document, the browser renders it.

Seems like we are talking of different things.

See below (source of Hugo generated HTML from Markdown code block source that OP posted):

image

<pre><code>:az馃啂cd:
</code></pre>

Blackfriday Hugo replaced the :ab: with that AB emoji i.e. hard-coded it. The browser simply shows that emoji in the default font.

Blackfriday Hugo should have left that :ab: in the <pre>/<code> tags as-is.


Update: But I can see that Hugo probably cannot figure out if the replaced emoji string is in code block or not.

@bep
Copy link
Member

bep commented Jul 20, 2018

I will repeat it one last time: This isn't a Blackfriday issue.

@kaushalmodi
Copy link
Member

kaushalmodi commented Jul 20, 2018

So then, who is replacing the 4-char string ":ab:" with the Unicode char 馃啂 (0x1F18E) in the HTML?


Update: Sorry, I now realize. It's something that happen between hugo and github.com/kyokomi/emoji? But it's not a "browser rendering" issue too, correct? Because the emoji unicodes are hard-coded in HTML.

Update 2: Found it! (helpers/emoji.go).. So Hugo has no context of where (in code block? in text?) those emoji strings appear.. and it does a blanket search/replace, right?

@splashx
Copy link
Author

splashx commented Jul 20, 2018

So Hugo has no context of where (in code block? in text?) those emoji strings appear.. and it does a blanket search/replace, right?

If that鈥檚 true then any attemp to use unformatted text in the page is doomed. Clearly not the way most apps behave.

GitHub for example won鈥檛 replace it:

:laughing:

Which should not be rendered as: 馃槅

@stale
Copy link

stale bot commented Nov 17, 2018

This issue has been automatically marked as stale because it has not had recent activity. The resources of the Hugo team are limited, and so we are asking for your help.
If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.
If this is a feature request, and you feel that it is still relevant and valuable, please tell us why.
This issue will automatically be closed in the near future if no further activity occurs. Thank you for all your contributions.

@stale stale bot added the Stale label Nov 17, 2018
@stale stale bot closed this as completed Dec 18, 2018
@tschinz
Copy link

tschinz commented Apr 30, 2019

reopen, still the case. Hugo should not replace emoji in code blocks. Should work as in github
:smile:
馃槃

@anup92k
Copy link

anup92k commented Mar 16, 2020

Same problem here, still on Hugo v0.67.1 (extended)...
image

@dillonzq
Copy link

dillonzq commented May 2, 2020

Same problem here, still on Hugo v0.67.1 (extended)...
image

@anup92k LoveIt theme uses a special syntax to escape what you want to display.
https://hugoloveit.com/theme-documentation-content/#escape-character

@anup92k
Copy link

anup92k commented May 5, 2020

Thanks ! I didn't understand this part last time.

@angristan
Copy link

angristan commented Aug 11, 2021

馃憢 Bumping this issue. I don't think it should be closed?

screenshot_2021-08-12_00-07-39

@github-actions
Copy link

github-actions bot commented Jan 17, 2022

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 17, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants