Skip to content

Quarto cpp code cells not getting syntax highlighting #12275

@bryevdv

Description

@bryevdv

As a completely new user, I have run into something that seems unexpected to me (i.e. seems like a bug), but it's possible that it is expected behavior. I was not able to find anything in the Quarto docs to suggest one way or the other, so apologies in advance if that is the case.

Background on what I am trying to do overall is here:

The specific technical issue I ran into is that {cpp} code blocks do not get rendered with more than "default" syntax highlighting. E.g.

```{cpp}
#include "realm.h"
#include "realm/cmdline.h"
#include "realm/network.h"

#ifdef REALM_USE_OPENMP
#include <omp.h>
#endif

using namespace Realm;

Logger log_app("app");
```

Results in output like this, with just one giant block of text inside a single <code> tag.

Image

Looking at some of the intermediate markdown outputs, it seems that {python} gets turned into something like {.python .cell-code} which Pandoc understands. But {cpp} is just left as {cpp} which presumably Pandoc does not understand, based on these Pandoc docs.

Is this difference in behavior expected? Is it possible to make it so the same transformation to {.cpp .cell-code} happen, similar to the one for Python? Or is there some configuration I could apply that would force this transformation to happen?

Note that code highlighting does work with plain ```cpp but AFAICT I need to use ```{cpp} in a .qmd file to be able to automatically extract and concatenate the code cells using quarto inspect. This is so very close to what I need for the semi-"literate programming" workflow I am trying to create for a C++ library tutorial.

Metadata

Metadata

Assignees

No one assigned

    Labels

    supporta request for support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions