Don't Execute DataView in Code Block

Is there a way to have Dataview or really any plugin not interfere with a code block and take what I entered as is?

=repeat(‘|’, 100)

This is an example of an Excel function I want to document. However, the DataView plugin is trying to execute the code block.

I attempted to escape the = with =. However, the \ is displayed when I am in reading mode.

My real question is how I can put anything in a code block without any plugins getting in the way.

Thanks, Scott.

I think this is happening because Dataview considers anything that starts with an equals sign to be an “inline query”. You could turn off inline queries, or change the prefix in your Dataview settings:

Also pro-tip: you can prefix your code with " excel" and Obsidian will add syntax highlighting:

@webinspect Thanks for the tip on changing the prefix. I wish either DataView would only evaluate if the language syntax is set to dataview. Even better if Obsidian had a way to just take the content as is without any plugin processing.

1 Like

Escaping the opening backtick appears to work (doesn’t show in reading mode).

\`=repeat ('|', 100`

Any use?

That second part will effectively disable a lot of plugin functionality. The occasional conflicting syntax issue like you’ve experienced here is the result of our opportunity to have this great possibility to enhance Obsidian to be an even better tool.

So you’ve got two options given that you want your Excel formula to show as code, change the prefix as indicated above, or disable “Enable Inline Queries” from Settings > Dataview. The latter will of course remove the possibility to do just the inline queries, but that might not be something you’d miss anyways?

If changing the prefix, I would suggest doing a search for "`=" first, just to verify that you’re not using it anywhere. And if you find it somewhere, then change it to whatever you choose for your new prefix.

Some more esoteric options

I tried doing a <code> around the text, but that didn’t work. You could possibly add some of the unicode space characters to trip the syntax detector from Dataview.

Or maybe remove the = in front?! Or you could replace the equal sign, with a different unicode equal sign, if there exists such a thing, but then copy-pasting the example code could become an issue.

If you’re ready to type a little more, you could consider doing <kbd>= repeat(‘|’, 100</kbd>, which will produce a similar style in reading view, but in live-preview the HTML tags will show.

All in all, changing the prefix or disabling the inline queries, are most likely the best options.


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