St.info displays text as markdown instead of plaintext?

I’m using st.info to display plaintext logs, but it seems they come out as markdown. Is there a way to force it to display plaintext instead?

Thanks in advance!

-Al

@AlCote Have you tried

st.text(logs)

I tried st.info(st.text(logs)) because I need the logs in the st.info box, but that doesn’t work. It displays the logs outside of the st.info box and then displays DeltaGenerator information inside the st.info box.

Hello. Could you post a sample of the text you’re using?

            _._
       _.-``__ ''-._
  _.-``    `.  `_.  ''-._           Redis 7.0.5 (1571907e/0) 64 bit

.- .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.-.|'_.-'| Port: 6379 | -. ._ / _.-' | PID: 76099 -._ -._ -./ .-’ .-’
|-._-.
-.__.-' _.-'_.-'| | -.
-._ _.-'_.-' | https://redis.io -._ -._-..-'.-’ .-’
|-._-.
-.__.-' _.-'_.-'| | -.
-._ _.-'_.-' | -._ -._-.
.-β€˜_.-’ _.-’
-._ -..-’ _.-’
-._ _.-' -.
.-’

Got it, what version of streamlit are you in? I cannot reproduce the issue in 1.26, Also, could you post a snippet of the code with the st.info implementation?

I’m on streamlit 1.27.

I call exp_err.info("\n".join(experiment_err_logs.get_all_log_lines())) where get_all_log_lines returns a list of strings. The strings are the lines in a log file that are written to the file system and end in \n. The log files in the file system look like


                _._
           _.-``__ ''-._
      _.-``    `.  `_.  ''-._           Redis 7.0.5 (1571907e/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 76099
  `-._    `-._  `-./  _.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |           https://redis.io
  `-._    `-._`-.__.-'_.-'    _.-'
 |`-._`-._    `-.__.-'    _.-'_.-'|
 |    `-._`-._        _.-'_.-'    |
  `-._    `-._`-.__.-'_.-'    _.-'
      `-._    `-.__.-'    _.-'
          `-._        _.-'
              `-.__.-'


while the code when sent through st.info looks like:

_._

       _.-``__ ''-._

  _.-``    `.  `_.  ''-._           Redis 7.0.5 (1571907e/0) 64 bit

.-`` .-. / ., β€˜β€™-._

( ’ , .- |, ) Running in standalone mode

|-._-…- __...-.``-._|' _.-'| Port: 6379

| -._ ._ / _.-’ | PID: 76099

-._ -._ `-./ _.-’ _.-’

|-._-._ `-.__.-’ .-'.-'|

| -._-._ .-'.-’ | https://redis.io

-._ -.`-.__.-'.-’ _.-’

|-._-._ `-.__.-’ .-'.-'|

| -._-._ .-'.-’ |

-._ -.`-.__.-'.-’ _.-’

`-._    `-.__.-'    _.-'

      `-._        _.-'

          `-.__.-'

I really want to use st.info to display the logs, but I can’t figure out how to get it look like it does in the filesystem.

You can use st.code or st.infor with markdown. See example below:

with open("file.txt", "r") as file:
    text_wapper = file.read()


st.code(
    text_wapper,
)

# or

with open("file.txt", "r") as file:
    text_wapper = file.read()


st.info(
    f"""```md 
        {text_wapper}
        """
)

However, if you use st.info, you might need to make sure you evaluate and wordwrap longer strings.

Hope it helps!

Thanks for your help! I decided to put it into st.code and it looks great! Just need to work on word wrapping now.

Awesome. St.code will mostly handle the wrapping for you. st.info won’t. Glad I could be of help.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.