javalent / markdown-attributes

Add attributes to elements in Obsidian
MIT License
94 stars 7 forks source link

🐞 Matching `${...}` in shell script code blocks #35

Open ChristinWhite opened 8 months ago

ChristinWhite commented 8 months ago

Check for existing bug reports before submitting.

Expected Behavior

The expected behavior is that Markdown Attributes would not match in any code blocks and we'd see something like this:

CleanShot 2024-03-26 at 17 46 22@2x

Current behaviour

However, when Markdown Attributes is enabled it matches {TERM} and hides that section of code:

CleanShot 2024-03-26 at 17 45 11@2x

I believe this is distinct from #5 because it's contextually specific based upon the language the code block is using. Of all the languages I've tried the only time it matches the {TERM} string and hides it is using sh, bash and zsh. As you can see, it is behaving normally when no language is present, it also does not happen for JS, Python, C, Go, Rust and about a dozen other alternatives that I tried.

As far as I can tell, it also only matches if it's preceded by a $ so I suspect this might be an regex error though it's strange that it only happens in shell blocks.

This only happens in live preview mode, reading mode appears normal. I've also disabled every other plugin (including editor syntax highlighting) and snippet to rule out incompatibility with another modification.

Reproduction

  1. Enable Markdown Attributes
  2. Create a code block
  3. Set the syntax to sh
  4. Add a line that includes $ followed by { ... } anywhere in the code block, even on new lines.

Here is the specific code I used in the screenshots:

``` if [ "${TERM}" = xterm ]; then TERM=xterm-256color; fi ```

```sh if [ "${TERM}" = xterm ]; then TERM=xterm-256color; fi ```

Which Operating Systems are you using?

Obsidian Version Check

1.5.11

Plugin Version

1.2.2

Confirmation

Possible solution

No response