gpoore / codebraid

Live code in Pandoc Markdown
BSD 3-Clause "New" or "Revised" License
376 stars 13 forks source link

Inline code shows up as a printed verbatim string with quotations #31

Closed amichuda closed 11 months ago

amichuda commented 4 years ago

When using inline code, the resulting text shows up in a different font and with quotation marks. Is there a way to get around this behavior? For example:

1+2{.python .cb.nb session=python} yields '3', not just 3 as a number in the text.

gpoore commented 4 years ago

If you aren't using a Jupyter kernel, you can use .cb.expr.

If you need a Jupyter kernel, there currently isn't a way to get raw inline text instead of verbatim text. A Jupyter kernel will send back the result in a case like this as rich output with format text/plain. You can specify what is shown via show=rich_output:plain, but this needs to be extended so you can do something like show=rich_output:plain:raw to specify how text output is handled.

amichuda commented 4 years ago

Just wanted to chime in again on this issue. Apparently, if you put the expression in a print statement and then change the code block to show=stdout:raw, the text comes out perfectly!

gpoore commented 4 years ago

Using print would be a solution, since that avoids the kernel's rich output and uses stdout instead. I've been working on adding support for things like show=rich_output:plain:raw, and should have that finished soon.

gpoore commented 11 months ago

It's been possible to use show=rich_output:plain:raw with Jupyter kernels since v0.5.0 (2021-02-28). Between that and .cb.expr for the built-in code execution system, all possibilities should be covered. Somehow I missed closing this issue with the v5.0.0 release.