microsoft / microsoft/qdk

LaTeX in EstimatorResult._repr_html_() is not rendered correctly

Open
#1,958 1 comment 0 reactions 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
1k
Forks
212
Avg merge
3d 8h
Merged PRs (30d)
65

Description

In fixing #1880, I noticed that many of our notebooks (e.g. `estimation-hardcoded-circuit`, `estimation-random-circuit` and others) don't render resource estimation details using the widget, but just directly using a pattern such as:

```python
result = qsharp.estimate("RunHardcodedCircuit()")
result
```

This shows a table where the markdown isn't rendered correctly even with the linked fix in place (as that only applies to widgets), e.g.

![Image](https://github.com/user-attachments/assets/a0785064-d925-49e8-9fca-4a52fc84472c)

In investigating the root cause for this, there are two issues to address:

Firstly, we have the below code in our pip package, but nothing in our docs or samples mentions requiring these packages, and no error or output is displayed to tell users to install them. We should document or provide output on this requirement if needed.

```python
try:
# Both markdown and mdx_math (from python-markdown-math) must be present for our markdown
# rendering logic to work. If either is missing, we'll fall back to plain text.
import markdown
import mdx_math

has_markdown = True
except ImportError:
has_markdown = False

```

Secondly, even installing those packages didn't resolve the markdown rending in the table as shown in the screen shot above, so that needs to be fixed anyway.

CC @msoeken and @ivanbasov

Contributor guide

Open the contributing guide

Research direction

Start at EstimatorResult._repr_html_() and compare its output with the rendering path used by widgets. Reproduce the table in estimation-hardcoded-circuit or estimation-random-circuit with markdown and mdx_math installed; done means LaTeX and markdown render correctly and the dependency requirement is documented or surfaced to users.

Written by the indexing model from the issue text.

Assessment

Tech stack
jupyter, latex, markdown, python
Domain
data-visualization, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.