pietroppeter / nimib

nimib 🐳 - nim 👑 driven ⛵ publishing ✍
https://pietroppeter.github.io/nimib/
MIT License
181 stars 10 forks source link

incorrect code for nbTextWithCode with multiline string on same line as command #97

Closed pietroppeter closed 2 years ago

pietroppeter commented 2 years ago

Compiling and running this file:

import nimib
nbInit
nbTextWithCode: """problem
solution"""
echo "nb.blk.code: ", nb.blk.code

last line of output is (when using CodeAsInSource now default):

nb.blk.code: """problem

while it should be (as it is when using -d:nimibCodeFromAst)

nb.blk.code: """problem
solution"""

fix to be done in code in src/nimib/sources.nim

HugoGranstrom commented 2 years ago

In addition to this I think this also breaks:

nbCode: someTemplate:
  code block

so the problem in general is multi-line blocks that start on the same line as the command

HugoGranstrom commented 2 years ago

Here's a preliminary plan for how to determine the form of the code:

All branches share a lot of code so I'll try and come up with a way of splitting the logic into reusable functions more.