Skip to content

Commit

Permalink
Un problème de compilation corrigé.
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyost committed Dec 29, 2023
1 parent 95fbed5 commit d2e42ed
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions modules/nuxt-content-latex/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,29 +158,26 @@ const replaceImages = (
// Get the destination path of the image in the assets directory.
const filePath = siteContentSettings.getLatexAssetDestination(assetsDirectoryPath, directory + '/' + src + extension)

// Check if the file exists.
if (fs.existsSync(filePath)) {
// Resolve the image source.
const resolvedSrc = resolveImageSrc(
filePath,
directories.map(includedGraphicDirectory => resolver.resolve(contentDirectoryPath, includedGraphicDirectory)),
assetsDirectoryPath,
resolver.resolve(sourceDirectoryPath, siteContentSettings.previousBuildDownloadDirectory, directory)
)

// Format the resolved source as an absolute path.
if (resolvedSrc) {
// Update the image source and alt attribute.
image.setAttribute('src', resolvedSrc.src)
if (resolvedSrc.dark) {
image.setAttribute('data-src-dark', resolvedSrc.dark)
}
image.setAttribute('alt', getFileName(src))

resolved = true
logger.success(name, `Resolved image ${src} to ${resolvedSrc.src} in ${texFilePath}.`)
break
// Resolve the image source.
const resolvedSrc = resolveImageSrc(
filePath,
directories.map(includedGraphicDirectory => resolver.resolve(contentDirectoryPath, includedGraphicDirectory)),
assetsDirectoryPath,
resolver.resolve(sourceDirectoryPath, siteContentSettings.previousBuildDownloadDirectory, directory)
)

// Format the resolved source as an absolute path.
if (resolvedSrc) {
// Update the image source and alt attribute.
image.setAttribute('src', resolvedSrc.src)
if (resolvedSrc.dark) {
image.setAttribute('data-src-dark', resolvedSrc.dark)
}
image.setAttribute('alt', getFileName(src))

resolved = true
logger.success(name, `Resolved image ${src} to ${resolvedSrc.src} in ${texFilePath}.`)
break
}
}

Expand Down Expand Up @@ -212,6 +209,10 @@ const resolveImageSrc = (
// Build the image path with suffix.
const extension = path.extname(imagePath)
let imagePathWithSuffix = path.resolve(path.dirname(imagePath), getFileName(imagePath) + suffix + extension)
if (!fs.existsSync(imagePathWithSuffix)) {
result.push(null)
continue
}

// Check if the image has a PDF or a TEX extension.
if (extension === '.pdf' || extension === '.tex') {
Expand Down

0 comments on commit d2e42ed

Please sign in to comment.