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

[Tutorials] Consistently use LaTeX delimiter for Docusaurus #2752

Closed
wants to merge 1 commit into from

Conversation

CristianLara
Copy link
Contributor

Docusaurus 3 requires math to be wrapped in $ delimiters. We were trying to be backwards compatible with our existing tutorials by wrapping math blocks in $ delimiters while converting to MDX but properly handling every type of math block (which this was failing to do) is beyond the scope of this script.

Since these tutorials are intended to be consumed by Docusaurus lets just enforce the $ delimiters when writing tutorials.

@facebook-github-bot facebook-github-bot added the CLA Signed Do not delete this pull request or issue due to inactivity. label Feb 20, 2025
@facebook-github-bot
Copy link
Contributor

@CristianLara has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

Copy link

codecov bot commented Feb 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.99%. Comparing base (094e3ef) to head (606487f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #2752   +/-   ##
=======================================
  Coverage   99.99%   99.99%           
=======================================
  Files         203      203           
  Lines       18705    18705           
=======================================
  Hits        18704    18704           
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@saitcakmak saitcakmak left a comment

Choose a reason for hiding this comment

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

Thanks! Enforcing correct formatting from start makes sense

@facebook-github-bot
Copy link
Contributor

@CristianLara has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

CristianLara added a commit to facebook/Ax that referenced this pull request Feb 21, 2025
This is a duplicate of the same code change in botorch: pytorch/botorch#2752

Docusaurus 3 requires math to be wrapped in $ delimiters. We were trying to be backwards compatible with our existing tutorials by wrapping math blocks in $ delimiters while converting to MDX but properly handling every type of math block (which this was failing to do) is beyond the scope of this script.

Since  these tutorials are intended to be consumed by Docusaurus lets just enforce the $ delimiters when writing tutorials.
CristianLara added a commit to facebook/Ax that referenced this pull request Feb 21, 2025
This is a duplicate of the same code change in botorch: pytorch/botorch#2752

I was noticing that sometimes (depending on a variety of factors like the editor used to modify the tutorial, whether they had been executed) the conversion script would fail because the cell source would be stored as a list of strings instead of a multi-line string.

From the official nbformat documentation:

> Some fields, such as code input and text output, are characteristically multi-line strings. When these fields are written to disk, they may be written as a list of strings, which should be joined with '' when reading back into memory. In programmatic APIs for working with notebooks (Python, Javascript), these are always re-joined into the original multi-line string. If you intend to work with notebook files directly, you must allow multi-line string fields to be either a string or list of strings.

https://ipython.readthedocs.io/en/3.x/notebook/nbformat.html
facebook-github-bot pushed a commit to facebook/Ax that referenced this pull request Mar 11, 2025
Summary:
This is a duplicate of the same code change in botorch: pytorch/botorch#2752

# LaTeX in Tutorials

Docusaurus 3 requires math to be wrapped in $ delimiters. We were trying to be backwards compatible with our existing tutorials by wrapping math blocks in $ delimiters while converting to MDX but properly handling every type of math block (which this was failing to do) is beyond the scope of this script.

Since  these tutorials are intended to be consumed by Docusaurus lets just enforce the $ delimiters when writing tutorials.

Before:
<img width="1711" alt="image" src="https://github.com/user-attachments/assets/1d710d83-038b-4f81-907d-d2a93d1eba37" />

After:
<img width="1711" alt="image" src="https://github.com/user-attachments/assets/21f4bc0a-9c52-49b7-88dd-5eef98606050" />

# Tutorial cell source

I was noticing that sometimes (depending on a variety of factors like the editor used to modify the tutorial, whether they had been executed) the conversion script would fail because the cell source would be stored as a list of strings instead of a multi-line string.

From the official nbformat documentation:

> Some fields, such as code input and text output, are characteristically multi-line strings. When these fields are written to disk, they may be written as a list of strings, which should be joined with '' when reading back into memory. In programmatic APIs for working with notebooks (Python, Javascript), these are always re-joined into the original multi-line string. If you intend to work with notebook files directly, you must allow multi-line string fields to be either a string or list of strings.

https://ipython.readthedocs.io/en/3.x/notebook/nbformat.html

Pull Request resolved: #3401

Reviewed By: mpolson64

Differential Revision: D70990589

Pulled By: CristianLara

fbshipit-source-id: ac189c938bfc24e39dc88a4f5861945b8ddcd6fb
Summary:
Docusaurus 3 requires math to be wrapped in $ delimiters. We were trying to be backwards compatible with our existing tutorials by wrapping math blocks in $ delimiters while converting to MDX but properly handling every type of math block (which this was failing to do) is beyond the scope of this script.

Since  these tutorials are intended to be consumed by Docusaurus lets just enforce the $ delimiters when writing tutorials.


Reviewed By: saitcakmak

Differential Revision: D69947509

Pulled By: CristianLara
@facebook-github-bot facebook-github-bot force-pushed the docusaurus-tutorials-simplify-katex branch from d984183 to 606487f Compare March 11, 2025 21:57
@facebook-github-bot
Copy link
Contributor

This pull request was exported from Phabricator. Differential Revision: D69947509

@facebook-github-bot
Copy link
Contributor

@CristianLara merged this pull request in 307cf04.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Do not delete this pull request or issue due to inactivity. fb-exported Merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants