obsidian-execute-code icon indicating copy to clipboard operation
obsidian-execute-code copied to clipboard

Better Magic Parsing

Open chlohal opened this issue 2 years ago • 2 comments

Right now, @show(...) and @html(...) use regex. This limits their applicability.

A simple contextual parser would help

  • Allow more complex dynamic calculations (e.g. @show("~/pictures/" + folder + "/img.png"))
  • Prevent a bug where strings containing the commands (e.g. console.log("@show(foo)") get replaced with the injected code
  • Allow more complex magic functions

chlohal avatar Oct 08 '22 13:10 chlohal

I think this would be really cool, but we need an efficient parser, otherwise long outputs will get really laggy

twibiral avatar Oct 08 '22 15:10 twibiral

I agree about the importance of performance. I think we would only need a single-pass parser, which shouldn't be that laggy. As long as it's aware of the current position, quote depth, etc. we wouldn't need something complex.

Once I finish #103, I can test a simple parser.

chlohal avatar Oct 08 '22 21:10 chlohal