I want to programmatically generate a report using Jupyter and need to put variables inside of markdown tables. I found this related answer: Related Answer.
However, if you put the code inside a for loop, the table and list are not formatted as desired (tested in Google Colab, Pycharm and Jupyter Notebook).
from IPython.display import display_markdown
for i in range(2):
display_markdown(f'''## heading
- ordered
- list
The table below:
| id |value|
|----|-----|
| a | {i} |
| b | 2 |
''', raw=True)
Tested code in Jupyter Notebook, Pycharm and Google Colab. The code delivers properly formatted text if used outside of for loop.
Edit This question Link describes the underlying problem. However, I believe that the different context (markdown formatting) and the is helpful for future searches.