Skip to content

sagetex representation should align with sagemath CLI output, hence catch stdout #63

@meisterluk

Description

@meisterluk

Expected output

sage: print('Hello World')
Hello World

Actual output

sage: print('Hello World')
None

Proposed solution

It is annoying that the output in sagemath CLIs/cells is different from the sagemath generated output.

  • As far as I understand, eval and preparse are called to generate the output. The output is written to result. Then only result is represented, not what was written to stdout.
  • With python3, print became a function and thus the problem occurs with one of the most fundamental primitives. Thus, it is IMHO particularly annoying.
  • Simutaneously, it is easy to manipulate stdout, catch the written content and represent it in sagetex
  • Thus, I propose to replace sys.stdout during execution, represent the caught lines and skip representation of the result if it is None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions