silverbulletmd / silverbullet

The hackable notebook
https://silverbullet.md
MIT License
2.06k stars 146 forks source link

Some code widget buttons break for empty fenced code #749

Open Maarrk opened 4 months ago

Maarrk commented 4 months ago

This is a result of fix for #734:

https://github.com/silverbulletmd/silverbullet/blob/cfd1e53f621b8ad435054fb755d7b4026a810bcb/plugs/query/widget.ts#L55-L57

Both "Edit" and "Bake" buttons break, but "Reload" or baking the whole page work.

Indeed unlikely, except for Table of Contents added manually 😄

```toc
```

Workaround: Write anything inside, which will be ignored by toc anyway.


Proposal: Make the main header of manually added ToC contain the text inside, like this for current behaviour:

```toc
Table of Contents
```

But it would also allow self-translation

```toc
Spis treści
```

To not worsen the UX for English speakers, the first snippet could be available as /toc

PS: I feel a bit guilty to derive features based on implementation details

zefhemel commented 4 months ago

Right, this is an edge case I didn't think of as part of my "fix" won't affect a lot of people, but still a bit silly.