Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Jupyter notebook LaTeX math tests #444

Open
wants to merge 2 commits into
base: development
Choose a base branch
from

Conversation

b0ink
Copy link

@b0ink b0ink commented Aug 18, 2024

Description

This fixes and improves the tests used in test_ipynb_to_pdf to confirm valid PDF rendering of LaTeX math in jupyter notebooks. The pdf-reader incorrectly parses a valid render of the inline math as BMI: bmi = weigh2 instead of weight.

I extended the LaTeX to ensure full words like weight and height are parsed correctly, though (kg) is still incorrectly parsed as (2g) (see below). Now, tests confirm a valid PDF render by checking for weight and height without needing to check for newlines or other notation.

I also used text{hei}text{ght} to separate the words to guarantee a reliable unit test pass if the words are detected. Below is a before/after of the inline LaTeX, the PDF render, and the output of pdf-reader.

Before

Inline math LaTeX:

$\text{bmi}=\frac{\text{weight}}{\text{height}^2}$

PDF Render

before-inline-math

pdf-reader output

BMI: bmi =		weigh2
				height

After

Inline math LaTeX:

$\text{bmi}=\frac{\text{weig}\text{ht (kg)}}{\text{hei} \text{ght (m)}^2}$

PDF Render

after-inline-math

pdf-reader output

BMI: bmi =		weight (2g)
				height (m)

Tests used to confirm math latex rendered correctly

assert reader.pages.last.text.include?("BMI: bmi =")
assert reader.pages.last.text.include?("weight")
assert reader.pages.last.text.include?("height (m)")

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

rake test

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation if appropriate
  • My changes generate no new warnings
  • I have created or extended unit tests to address my new additions
  • New and existing unit tests pass locally with my changes

Copy link
Contributor

@satikaj satikaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Thanks for fixing this test, Eliya!

@macite could you please take a look at this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants