-
Notifications
You must be signed in to change notification settings - Fork 415
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
base: main
Are you sure you want to change the base?
Conversation
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 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2752 +/- ##
=======================================
Coverage 99.99% 99.99%
=======================================
Files 203 203
Lines 18690 18690
=======================================
Hits 18689 18689
Misses 1 1 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this 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
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
@CristianLara has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
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.
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
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.