Skip to content

inline R in blog yaml isn't executed on listing page #1505

Open

Description

@harrig12

I have a blog post with a description that contains inline r (to estimate reading time)

it renders nicely for the post itself
image

but not in the listing page!
image

here's the yml of my post's index.qmd:

---
draft: false
title: A nice blog post
description: |
  Reading time: `r ifelse(file.size("index.qmd")/2000 <= 1, '<1 minute', paste0(round(file.size("index.qmd")/2000), ' minutes'))`
---

Any idea of how I can fix the listing?

Activity

  1. harrig12 commented on Jul 23, 2022

    @harrig12
    Author

    Similarly, adding today's date via inline r seems to have some funky output
    (I know this is not recommended for blogs, but it still seems to be undesirable behaviour)

    yml

    ---
    draft: false
    title: A nice blog post
    date: "`r date()`"
    image: thumbnail.jpg
    ---
    

    post result
    image

    listing result
    image

  2. dragonstyle commented on Jul 23, 2022

    @dragonstyle
    Collaborator

    I have a blog post with a description that contains inline r (to estimate reading time)

    I'll have a look - agree that this isn't desirable. Side note - we do compute reading and can display that in the blog listing:

    listing:
      type: default
      fields: [title, subtitle, author, description, date, image, reading-time]

    Similarly, adding today's date via inline r seems to have some funky output

    For this we would definitely prefer that you use the built in functionality that does the same thing (though in a language agnostic way). More about the options here:

    https://quarto.org/docs/reference/dates.html

    Agree that ideally this would work, but date is a use case that we could discourage and hope the built in support offers functionality sufficient to replace it.

  3. self-assigned this
    on Jul 23, 2022
  4. added this to the Future milestone on Jul 23, 2022
  5. mcanouil commented on Jul 23, 2022

    @mcanouil
    Collaborator

    @dragonstyle is this listing preview issue related to Font Awesome icons not showing up (quarto-ext/fontawesome#7)?

  6. dragonstyle commented on Jul 23, 2022

    @dragonstyle
    Collaborator

    I think this one may be different - I have a theory that the font awesome issue is that we're actually a little 'too smart' (by my recommendation :( ) in that LUA filter - we only inject the fontaweome CSS / fonts when we see that a shortcode was used on the page. I think the listing page isn't getting that CSS / font because we bring fully rendered HTML into the page in a post processor, and so LUA never sees the shortcode.

    I haven't had time to test this yet, but I think if you add a FA element to a listing page itself, the ones in posts will start working (or alternatively you could just see if the listing contents include properly rendered FA HTML that we just aren't styling).

    There are very fancy fixes for this in the long run (pages noting their dependencies and listing pages merging them) but in the short run we could also just make the font awesome dependency injection a little less smart :).

  7. mcanouil commented on Jul 23, 2022

    @mcanouil
    Collaborator

    Thanks, I assumed this was something related to how CSS was injected (quarto-ext/fontawesome#7 (comment)), but was wondering with this issue if it was only that.

  8. dragonstyle commented on Jul 23, 2022

    @dragonstyle
    Collaborator

    Nice you completely nailed it! I'm not totally confident that is the only issue but I think it will be the big one...

  9. modified the milestones: Future, v1.1 on Aug 2, 2022
  10. modified the milestones: v1.1, v1.2 on Aug 16, 2022
  11. modified the milestones: v1.2, v1.3 on Sep 22, 2022
  12. modified the milestones: v1.3, Future on Feb 20, 2023
  13. mcanouil commented on Apr 28, 2024

    @mcanouil
    Collaborator

    Note that inline R code in YAML is not really supported in Quarto.
    It works mostly as a side effect via knitr.

    With current version, the R code is no longer evaluated anywhere in the example.

    Note also that Quarto listing does include reading-time, see https://quarto.org/docs/websites/website-listings.html#listing-fields.

    I am going to close this based on the above.

  14. cscheid commented on Apr 28, 2024

    @cscheid
    Member

    It is still a bug, though, even if it's not one that we can easily fix in the near future. I'm reopening this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions