Having icons rendered within code blocks. #4771
-
Is it possible to display icons within code blocks. It would be useful especially when you show a directory like structure. Right now, something like this doesn't work.
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 7 replies
-
Hmm, interesting idea. Theoretically, it should be possible, albeit I'm not sure at which stage this would need to be implemented, as those short codes might interfere with highlighting. @facelessuser could this be done somehow prior to lexing, i.e. by taking the shortcodes out and inserting them back in after highlighting, or does it mandate an extra lexer for each and every language? |
Beta Was this translation helpful? Give feedback.
-
这是来自QQ邮箱的假期自动回复邮件。 您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。
|
Beta Was this translation helpful? Give feedback.
-
So, I managed to render icons in code blocks, but not the way it was asked here. I've done it for Markdown-Exec, specifically for Before, it added a "file" emoji (or whatever its name is) in front of files. Now it finds the relevant icon (in Simple Icons provided by Material for MkDocs) depending on the file name and/or extension, and add a unique text ID that corresponds to this icon in front of it. After converting the transformed tree into HTML, it regex-replaces the unique IDs with the final svg (obtained again from Material for MkDocs files), wrapping it into The end result: I'll probably release this as an Insiders feature of Markdown-Exec 😎 |
Beta Was this translation helpful? Give feedback.
Hmm, interesting idea. Theoretically, it should be possible, albeit I'm not sure at which stage this would need to be implemented, as those short codes might interfere with highlighting. @facelessuser could this be done somehow prior to lexing, i.e. by taking the shortcodes out and inserting them back in after highlighting, or does it mandate an extra lexer for each and every language?