6.10 Extensions
6.10.1 Color Text
Create a filter to apply blue text color to fenced div.
- Created a minimal local color-text filter:
- Added
_quiz/_extensions/color-text/color-text.lua - It supports the
.blueclass for both blocks and inline spans:- HTML: adds
style="color: blue;" - PDF: wraps with LaTeX xcolor; automatically injects
\usepackage{xcolor}
- HTML: adds
- Added
- Updated the
qmdfile YAML to reference this local filter:- filters:
_extensions/color-text/color-text.lua
- filters:
- You can use fenced divs and inline spans with
.blue.
Use example
In the yaml header of your
qmdfile, add the following line to reference the local filter:Use the
.blueclass in your markdown content:
6.10.2 Emoji
In the yaml, add the emoji extension to the from option in document metadata.
For markdown formats that support text representations of emojis 😁 (e.g. :grinning:), the text version will be written. For other formats the literal emoji character will be written. Currently, the gfm and hugo (with enableEmoji = true in the site config) formats both support text representation of emojis.
Note: This does NOT work for quarto pdf. Use the twemoji approach instead. See below.
Four steps to add more emojis in the future:
Open
twemoji_manifest.jsonand append new code points to the emoji object- Example:
"1f44d": ["👍", ":thumbsup:"]
How to find the code points of an emoji:
- Example:
Run the fetcher again:
Within the project directory:
From anywhere:
$'/Users/menghan/Documents/language/norsk/norskprøver/B2/exam notes/emoji/fetch_twemoji.sh' Exists: 1f4a1.png Exists: 1f4c8.png Exists: 1f4dd.png Exists: 1f539.png Exists: 1f600.png Exists: 1f604.png Exists: 1f680.png Exists: 26a0.png Downloading: 2705.png Done. Files saved in ~/Documents/language/norsk/norskprøver/B2/exam notes/emoji. Map to filter names as needed (already matching).The script downloads only missing PNGs. If you add more codes to
twemoji_manifest.json, just run it again.To refresh files, delete specific PNGs (or all) in emoji and rerun.
Add to
unicode_mapinemoji.luato point to the same filename.- Example:
["⚠️"] = "26a0.png",
This ensures when you use the emoji directly, it maps to the correct image file.
- Example:
Optionally add a shortcode mapping in
emoji.lua’semoji_mapto point to the same filename.- Example:
[":warning:"] = "26a0.png",
This allows you to use the shortcode
:warning:in addition to the direct emoji.- Example:
🎯 Usage Examples
You can now use emojis in your QMD files in two ways:
- Direct Unicode: Great job! 👍 This is amazing! 🎉
- Shortcodes: Great job!
:thumbsup:This is amazing!:tada:
ref: