Square brackets incorrectly render as link

Testing version: 0.1 (2595)

What were you doing: I was editing quotes from a book and using the common convention of square brackets to indicate text added/changed from the original. For example, “[Merry] loved mountains, or he had loved the thought of them marching on the edge of stories brought from far away”.

What feature did you use: Just writing.

What happened: The text in the square brackets (“Merry” in the above example) was rendered as a link (to nowhere).

What did you expect to happen: The text in brackets should have rendered as plain text with the brackets included. If I’m reading the CommonMark spec correctly, text in square brackets that is not followed by parentheses or square brackets should only render as a link if there is a matching link reference definition elsewhere in the document (this was not the case).


Hi Janne - I suspect this is a bug introduced into the latest version of Panda. Prior to this release, putting single square-brackets around text did not result in a link - it functioned exactly as you’d expect. It looks like this current version is interpreting [bracketed text] as something akin to a footnote. If you click the link, you’ll see a new footnote created at the end of your text. Proper markdown footnote syntax is [^1]. So as I say, I suspect what you are experiencing with [Merry] is a bug that will soon be fixed.

@TedwardBear ^

I’m seeing this as well.

If I understand the vision for Pandas correctly, then it will be a fully common-mark compliant editor with some Github flavour. The [foo] turning into a link is expected behaviour given the spec see (GitHub Flavored Markdown Spec). It is different from the [^foo] syntax because the former is a hyptertext link that will open a browser (or a the relative url-handler) whereas the latter is a footnote, it will navigate to the position where the footnote is specified.

If you want a simple bracketed you may do \[foo]. See GitHub Flavored Markdown Spec for reference.

According to the spec, bracketed text should only render as a link if there is a matching reference link definition elsewhere in the document.

For example, try the following in the Commonmark reference implementation:

[This one] is a link because it has a reference definition below.

[This] is not a link because it doesn’t have a reference definition.

[This one]: https://beta.bear.app

Good observation.
I would still argue that it is expected.

  1. Bear and Pandas are editors not a viewer.
  2. currently the [^foo] footnote syntax turns immediately into a link and upon clicking creates the corresponding [^foo]: footnote
  3. By analogy [foo] is rendered as a link, which has not yet been populated (as Panda is an editor).
  4. To make the two equivalent the current behaviour I would argue is expected. And makes the feature more discoverable.

I would argue that if is ok for [^foo] to autogenerate a footnote then so should [foo].

Note I am a random user on the Internet and not the Bear design team. :slight_smile:

I think you’re right that it comes down to expected UI behavior, rather than spec conformance. Personally, I would prefer square brackets to be left alone unless followed by parenthesis for two reasons:

  • By default, Bear does not use the reference link notation in its Markdown output, opting instead for inline link notation
  • Unlike footnote notation ([^…]), reference link notation ([…]) sees frequent legitimate use outside its use in links