I also use a single text file. I have developed my own notation to give it some structure [1]. I have a parser for the notation that creates tree of the document. Then I write various programs that walk the tree and do cool things. I have been happy(didn't feel like I needed anything else) with my system for some years now.
Now if notebook program is watching the file then it will send the code block to jupyter server and write results to `#out{}` "bag". And file will look like this.
```
[x*x for x in range(10)]
```
#out{
````````````````````````````````````````````
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]
````````````````````````````````````````````}
Solved it by surrounding code with more ticks than maximum number of consecutive ticks inside its text. This allows arbitrary nesting.
Postgres solves it by using `$something$ whatever $something$` [2].
[1] https://github.com/PratikDeoghare/brashtag [2] https://www.postgresql.org/docs/current/sql-syntax-lexical.h...