codebraid icon indicating copy to clipboard operation
codebraid copied to clipboard

Inline code shows up as a printed verbatim string with quotations

Open amichuda opened this issue 4 years ago • 3 comments

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.

amichuda avatar Jun 09 '20 04:06 amichuda

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.

gpoore avatar Jun 09 '20 04:06 gpoore

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!

amichuda avatar Sep 01 '20 17:09 amichuda

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 avatar Sep 02 '20 01:09 gpoore

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.

gpoore avatar Oct 17 '23 17:10 gpoore