bash_kernel icon indicating copy to clipboard operation
bash_kernel copied to clipboard

Terminal control characters in markdown export

Open sporksmith opened this issue 4 years ago • 2 comments

Example: https://github.com/sporksmith/dev-journal/blob/60778d5273504900051fdff4ba99f8daa9c54c35/interposing-fwrite/README.md

e.g.

4005b6:   e8 a5 fe ff ff          ESC[01;31mESC[Kcallq  400460 <fwriteESC[mESC[K@plt>

vs what I see in the jupyter gui or html export:

4005b6:	e8 a5 fe ff ff       	callq  400460 <fwrite@plt>

I tried adding the line export TERM=xterm-mono to one of the affected cells, but it doesn't seem to have any effect.

Any ideas?

sporksmith avatar May 05 '20 20:05 sporksmith

It'd be nice to fix this, but I found a workaround, using ansi2txt:

jupyter nbconvert notebook.ipynb --execute --to markdown --stdout | ansi2txt > notebook.md

sporksmith avatar May 05 '20 20:05 sporksmith

Maybe a separate issue, but on the topic of markdown-export, it's a little bit difficult to visually distinguish the cell contents and cell output when the resulting Markdown is converted to html. I hacked up an awk script to add a $ "prompt" to the cell lines so that they stand out a little more:

/^```bash/ { prefix=1; print $0; next; }
/^```$/ { prefix=0; print $0; next; }
{
    if ( prefix==1 )
        print "$ " $0
    else
        print $0
}

sporksmith avatar May 05 '20 21:05 sporksmith

I've recently taken on co-maintaining bash_kernel, and I'm currently closing all old/stale issues.

I'm closing this issue as it should have been solved in version 0.8 with PR #120. Please test with the latest bash_kernel, and reopen if you need further help.

kdm9 avatar Aug 24 '22 10:08 kdm9