zimbatm / mdsh

`$ mdsh` # a markdown shell pre-processor
https://zimbatm.github.io/mdsh/
MIT License
123 stars 11 forks source link

Unfenced code with backticks being interpreted as command? #67

Open diegonehab opened 5 months ago

diegonehab commented 5 months ago

Thank you for your work and I apologize if this is an obvious mistake on my part. I was expecting mdsh to leave unfenced code alone.

For example, in a file containing

`leave-me-alone`

`$ echo 1`

I would expect the output to be

`leave-me-alone`
`$ echo 1`

```
1
```

Instead, I get

Using input=File("input.md") output=StdHandle work_dir=Parent("/tmp") clean=false frozen=false
`leave-me-alone`
thread 'main' panicked at src/main.rs:414:25:
WTF, not supported
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

This panic!("WTF, not supported") is there becasue mdsh expects leave-me-alone to be a RE_MATCH_FENCE_COMMAND, a RE_MATCH_MD_COMMAND, or a RE_MATCH_VAR_COMMAND, which of course it isn't. Instead of panicking, shouldn't the code simply leave the original_line.to_string() in place undisturbed? After all, there was no fence there.

zimbatm commented 5 months ago

It's not you, this is a bug!