obsidian-markdown-attributes icon indicating copy to clipboard operation
obsidian-markdown-attributes copied to clipboard

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

Open ChristinWhite opened this issue 10 months ago • 0 comments

Check for existing bug reports before submitting.

  • [X] I searched for existing Bug Reports and found no similar reports.

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?

  • [ ] Android
  • [ ] iPhone/iPad
  • [ ] Linux
  • [X] macOS
  • [ ] Windows

Obsidian Version Check

1.5.11

Plugin Version

1.2.2

Confirmation

  • [X] I have disabled all other plugins and the issue still persists.

Possible solution

No response

ChristinWhite avatar Mar 27 '24 01:03 ChristinWhite