Text replacement to generate a language specific code block doesn't always format code

  • Bear Version: 2.6.7
  • OS Version: 15.7.4
  • What were you doing: text replacement to insert empty code block
  • What feature did you use: text replacement (macOS settings)
  • What happened: resulting code block didn’t always format code
  • What did you expect to happen: nicely formatted code as usual

I just created two macOS text replacements:

  1. “.ca”

```applescript

```

  1. “.cj”

```javascript

```

These text replacements always work, in the sense that the empty code block is generated in the text, with the language specified, as shown above.

However, the code block may or may not format code subsequently pasted into the block, depending on how the replacement text was inserted.

  • Entering the text to be replaced (.ca or .cj), and pausing will bring up the suggested replacement text (and an x to cancel) in a “pop over” below the line.
  1. If I click on this, then everything works as expected: the code block is generated and subsequently entered code is formatted according to the language.

  2. However, if I enter the text, then follow it with a space, the code block is inserted but, in this case, it doesn’t work as expected. When I copy code into the block, it isn’t formatted. :pensive_face:

It appears to always not work on iOS, but I haven’t tested that as thoroughly.

Doesn’t look like a text replacement issue. Adding a space after the closing ``` *before* typing in code into the code block will result in missing syntax highlighting. You can then end up with a code block that’s half-highlighted, half- not:

My suggestion: add a blank line to the end of your replacement snippet. That way you won’t accidentally add a space to the end of the code block but rather on the next blank line.

Yes, that’s a bug. Thanks to both of you for reporting this problem. We’ll provide a fix with next update.