docs icon indicating copy to clipboard operation
docs copied to clipboard

Document how to use emoji in mermaid diagrams

Open jsoref opened this issue 1 year ago โ€ข 3 comments
trafficstars

Code of Conduct

What article on docs.github.com is affected?

https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-diagrams

What part(s) of the article would you like to see updated?

Add a section explaining how to use emoji

Additional information

The first hit of https://www.google.com/search?q=mermaid+diagram+emoji&ie=UTF-8 is:

https://github.com/mermaid-js/mermaid/issues/625

the first suggestion ... https://github.com/mermaid-js/mermaid/issues/625#issuecomment-378441698 does not work in GitHub:

graph TD
A---foo[&amp#x1F619]
image

a later suggestion ... https://github.com/mermaid-js/mermaid/issues/625#issuecomment-558295512 does work:

graph TD
A-->B("hello ๐Ÿฅฐ")
image

Note: there is no documentation on the mermaid website at this time ...

  • https://github.com/mermaid-js/mermaid/issues/5308

jsoref avatar Feb 22 '24 05:02 jsoref

@jsoref Thanks for opening this issue! I'll get this triaged for review โœจ

nguyenalex836 avatar Feb 22 '24 17:02 nguyenalex836

EmeฤŸinize saฤŸlฤฑk

gsosm0760 avatar Feb 26 '24 20:02 gsosm0760

Ben

suleymanay avatar Feb 26 '24 20:02 suleymanay

graph TD; A[Start] --> B[Process ๐Ÿ› ๏ธ]; B --> C{Decision โœ…}; C -->|Yes| D[Result ๐Ÿ˜Š]; C -->|No| E[Result ๐Ÿ˜ž]; B --> F(Sub-process ๐Ÿ’ผ); F --> G(Another process ๐Ÿ“); G -->|Done| H[End ๐Ÿ];

rishusam avatar Mar 21 '24 04:03 rishusam

emoji_mermaid.py

def replace_emojis(mermaid_code): # Define mappings of placeholders to emoji Unicode characters emoji_map = { ':smile:': '๐Ÿ˜Š', ':rocket:': '๐Ÿš€', ':heart:': 'โค๏ธ', }

# Replace placeholders with emojis
for placeholder, emoji in emoji_map.items():
    mermaid_code = mermaid_code.replace(placeholder, emoji)

return mermaid_code

Example Mermaid code with placeholders

mermaid_code = """ graph TD; A[Start] --> B[Process :rocket:]; B --> C{Decision :smile:}; C -->|Yes| D[Result :heart:]; C -->|No| E[Result :heart:]; B --> F(Sub-process); F --> G(Another process); G -->|Done| H[End]; """

Pre-process Mermaid code

processed_mermaid_code = replace_emojis(mermaid_code) print(processed_mermaid_code)

rishusam avatar Mar 21 '24 04:03 rishusam

@jsoref Thank you for your patience while our team reviewed this! Given the solution to this issue is to paste in the emoji, we don't feel it it necessary to document this. Thank you for your contribution ๐Ÿ’› I'll go ahead and close out this issue.

nguyenalex836 avatar Mar 21 '24 23:03 nguyenalex836