quarto-dev / quarto-cli

Open-source scientific and technical publishing system built on Pandoc.
https://quarto.org
Other
3.99k stars 328 forks source link

Emoji shortcodes in YAML front-matter not rendered as expected #8280

Open mfisher87 opened 10 months ago

mfisher87 commented 10 months ago

Bug description

When from: "markdown+emoji" is set, emoji shortcodes work in Markdown except their behavior in front-matter is inconsistent.

A page with front-matter:

---
title: "Some title"
subtitle: ":heart:"
---

...

will display the emoji successfully on a listing page which includes this page:

image

But not on the page itself:

image

Steps to reproduce

Expected behavior

Emoji shortcodes render consistently (either they do or they don't) from YAML front-matter regardless of where the content is rendered.

Actual behavior

Emoji shortcodes in YAML front-matter do render in some context, but not in other contexts. See repro instructions :)

Your environment

Quarto check output

```bash $ quarto check [✓] Checking versions of quarto binary dependencies... Pandoc version 3.1.1: OK Dart Sass version 1.58.3: OK [✓] Checking versions of quarto dependencies......OK [✓] Checking Quarto installation......OK Version: 1.3.450 Path: /home/robatt/.local/share/miniconda3/envs/quarto/bin [✓] Checking basic markdown render....OK [✓] Checking Python 3 installation....OK Version: 3.12.0 (Conda) Path: /home/robatt/.local/share/miniconda3/envs/quarto/bin/python Jupyter: 5.3.2 Kernels: python3 (/) Checking Jupyter engine render....0.00s - Debugger warning: It seems that frozen modules are being used, which may 0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off 0.00s - to python to disable frozen modules. 0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation. 0.00s - Debugger warning: It seems that frozen modules are being used, which may 0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off 0.00s - to python to disable frozen modules. 0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation. [✓] Checking Jupyter engine render....OK [✓] Checking R installation...........(None) Unable to locate an installed version of R. Install R from https://cloud.r-project.org/ ```

Also reproduced with 1.4.510

cderv commented 10 months ago

Thanks for the report!

Some notes about the current context as I looked quickly to confirm something. Just leaving that here for future us.

Internally, we use --metadata-file to pass all the merged metadata. String scalars are parsed as Markdown, but using default extension only as we use a custom markdown reader internally. The relevant part in the doc:

--metadata-file=FILE Read metadata from the supplied YAML (or JSON) file. This option can be used with every input format, but string scalars in the metadata file will always be parsed as Markdown. (If the input format is Markdown or a Markdown variant, then the same variant will be used to parse the metadata file; if it is a non-Markdown format, pandoc’s default Markdown extensions will be used.)

So currently, I think there is a limitation where YAML field can only use markdown syntax supported by default Markdown format. +emoji is not part of the default; so it is not parsed as such when provided in YAML.

It is when provided in non-yaml part because correctly controls how the body part is read with pandoc.read()

Interesting one! Thanks again for the report.

mfisher87 commented 10 months ago

Any time! Thank you for the awesome work, all :heart:

aronatkins commented 8 months ago

Workaround (for some cases): use HTML entitles rather than emoji. For example:

---
title: "things are ♥"
---

renders the heart.

image
mfisher87 commented 8 months ago

Pasting unicode characters directly in to the Markdown file is also working great for me as a workaround!

---
title: "things are ❤️"
---
mfisher87 commented 1 week ago

Some more detail: Emoji shortcodes in title key of a document's front-matter render in the nav-bar, but do not render in the document itself.

Image

_quarto.yml:

<...>
navbar:
  left:
    - about.md
<...>
format:
  html:
    from: "markdown+emoji"

about.md:

---
title: ":question: About"
---

Foo
cscheid commented 1 week ago

This issue hinges on which parts of the YAML metadata get interpreted as Markdown vs not.

We can't interpret all metadata as Markdown. That is a source of the "reverse" bugs, notably URLs parsed as Markdown are a bad thing. I've written more about this in a related upstream Pandoc issue.