Display Dataview Syntax in Code Block

Things I have tried

  • Tried double-code-blocking, but that messes up the rest of the page
  • searched this forum, the Dataview Github pages, and Google for an answer, no luck.

What I Need

  • I’d be fine if there was a way to add some frontmatter that says “don’t Dataview this page”, if that’s a possibility.

What I’m trying to do

I’m trying to document my Dataview queries in a single place, but they always just display as a PARSING FAILED error because Dataview is trying to build a table/list based on placeholder data.

I want to display the Dataview query code block without Dataview parsing it as a query.

Here’s an example of what doesn’t work

  • Putting the dataview codeblock within another codeblock does not display correctly. It (as expected, probably) removes the trailing “```” and shows another empty code block below.
```dataviewjs

... js code ...

1 Like

To enclose a code block within another code block you just need to increase the number of backticks.

````
```dataviewjs
   ... js code ...
```
````

You can also alternate to using ~~~ around some of the blocks. But increasing is the easiest variant. So enclose your main block with four backticks, and you’re good to go. (In order to show this example here as a forum post, I increased to five backticks to show the code block enclosing the dataviewjs code blocks… :smiley: )

1 Like

there it is. I did not know the add-more-backticks trick. thanks!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.