Skip to content

Commit

Permalink
MOM improvements and legacy executables fix (#799)
Browse files Browse the repository at this point in the history
* fix legacy types to not require unneeded pdfsvg and pdfpng

* remove stray comment

* format
  • Loading branch information
oscarlevin authored Jul 18, 2024
1 parent 8d6fd12 commit bc67f70
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ Instructions: Add a subsection under `[UNRELEASED]` for additions, fixes, change

## [UNRELEASED]

### Changed

- Updated the process for generating latex-image to use pyMuPDF instead of pdf2svg

### Fixed

- Only generate myopenmath problems when actually needed.

## [2.5.2] - 2024-07-17

### Fixed
Expand Down
20 changes: 7 additions & 13 deletions pretext/project/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ def save_asset_table(self, asset_table: pt.AssetTable) -> None:

def ensure_myopenmath_xml(self) -> None:
"""
Ensures that the myopenmath xml files are present if the source contains myopenmath exercises. Needed to build or generate other "static" assets and targets.
Ensures that the myopenmath xml files are present if the source contains myopenmath exercises. Needed to generate other "static" assets and targets.
"""
if self.source_element().xpath(".//myopenmath/@problem"):
mom_prob_nums = self.source_element().xpath(".//myopenmath/@problem")
Expand Down Expand Up @@ -575,9 +575,6 @@ def build(
# verify that a webwork_representations.xml file exists if it is needed; generated if needed.
self.ensure_webwork_reps()

# verify that a myopenmath xml files exist if it is needed; generated if needed.
self.ensure_myopenmath_xml()

# Generate needed assets unless requested not to.
if generate:
self.generate_assets(xmlid=xmlid)
Expand Down Expand Up @@ -746,17 +743,14 @@ def generate_assets(
- xmlid: optional string to specify the root of the subtree of the xml document to generate assets within.
- non_pymupdf: temporary boolean to revert to legacy alternative image generation without pymupdf (and use old external programs).
"""
# If generate was not called for just webwork, ensure that the webwork representations file is present.
if requested_asset_types != ["webwork"] and requested_asset_types != [
"myopenmath"
]:
# Two "ensure" functions call generate to get just a single asset. Every generation step other than webwork must have webwork generated, so unless we are "ensuring" webwork, we will need to call ensure webwork. Note if this function was called with just webwork, then we would move down and actually build webwork.
if requested_asset_types != ["webwork"]:
log.debug("Ensuring webwork representations file is present.")
self.ensure_webwork_reps()
self.ensure_myopenmath_xml()
# If generate was not called for just myopenmath, ensure that the myopenmath xml files are present.
# if requested_asset_types != ["myopenmath"]:
# log.debug("Ensuring MyOpenMath XML files are present.")
# self.ensure_myopenmath_xml()
# We also need to ensure myopenmath for all assets except webwork. However, if we are generating only myopenmath, we should not ensure myopenmath again.
if requested_asset_types != ["myopenmath"]:
log.debug("Ensuring MyOpenMath XML files are present.")
self.ensure_myopenmath_xml()

# Start by getting the assets that need to be generated for the particular target. This will either be all of them, or just the asset type that was specifically requested.
if requested_asset_types is None or "ALL" in requested_asset_types:
Expand Down
4 changes: 2 additions & 2 deletions pretext/project/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ class LegacyExecutables(
latex: str = pxml.element()
pdflatex: str = pxml.element()
xelatex: str = pxml.element()
pdfsvg: str = pxml.element()
pdfsvg: t.Optional[str] = pxml.element(default=None)
asy: str = pxml.element()
sage: str = pxml.element()
pdfpng: str = pxml.element()
pdfpng: t.Optional[str] = pxml.element(default=None)
pdfeps: str = pxml.element()
node: str = pxml.element()
liblouis: str = pxml.element()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<executables>
<pdflatex>pdflatex</pdflatex>
<xelatex>xelatex</xelatex>
<pdfsvg>pdf2svg</pdfsvg>
<asy>asy</asy>
<sage>sage</sage>
<pdfpng>convert</pdfpng>
Expand Down

0 comments on commit bc67f70

Please sign in to comment.