Verified Owner
Top Description Fields Constructors Methods
org.jabref.logic.openoffice.bst

public Class PandocLatexConverter

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.io.IOException, .OutputStream, java.nio.charset.StandardCharsets, java.util.List, .Optional, java.util.concurrent.TimeUnit, java.util.stream.Stream, org.jabref.logic.os.OS, org.jabref.logic.util.HeadlessExecutorService, .StreamGobbler, com.google.common.annotations.VisibleForTesting, org.jspecify.annotations.NullMarked, org.slf4j.Logger, .LoggerFactory

Converts LaTeX fragments to HTML by shelling out to pandoc.

The path to pandoc is read from OpenOfficePreferences and can be changed by the user in Preferences > OpenOffice/LibreOffice. Use autoDetect to find pandoc automatically.

Field Summary

Modifier and TypeField and Description
private static final List<String>
private static final Logger
private static final List<String>
private static final String
private final String
private static final List<String>
WINDOWS_CANDIDATES

Candidate commands tried by autoDetect on Windows, in priority order.

private static final List<String>
WINDOWS_INSTALL_DIRECTORY_HINTS

Additional Windows install-directory hints resolved at runtime to absolute paths such as C:\\Program Files\\Pandoc\\pandoc.exe.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static Optional<String>
autoDetect()

Returns the first pandoc executable found in the OS-specific candidate list, or Optional.empty if none responds to --version within 5 seconds.

pack-priv static List<String>
getAutoDetectCandidates(boolean windows, boolean osX)

public boolean
public String
latexToHtml(String latex)

Converts a LaTeX fragment to HTML via pandoc stdin/stdout (no temp files).

private static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LINUX_CANDIDATESback to summary
private static final List<String> LINUX_CANDIDATES
LOGGERback to summary
private static final Logger LOGGER
MACOS_CANDIDATESback to summary
private static final List<String> MACOS_CANDIDATES
PANDOC_EXECUTABLEback to summary
private static final String PANDOC_EXECUTABLE
pandocPathback to summary
private final String pandocPath
WINDOWS_CANDIDATESback to summary
private static final List<String> WINDOWS_CANDIDATES

Candidate commands tried by autoDetect on Windows, in priority order.

WINDOWS_INSTALL_DIRECTORY_HINTSback to summary
private static final List<String> WINDOWS_INSTALL_DIRECTORY_HINTS

Additional Windows install-directory hints resolved at runtime to absolute paths such as C:\\Program Files\\Pandoc\\pandoc.exe.

Constructor Detail

PandocLatexConverterback to summary
public PandocLatexConverter(String pandocPath)

Method Detail

autoDetectback to summary
public static Optional<String> autoDetect()

Returns the first pandoc executable found in the OS-specific candidate list, or Optional.empty if none responds to --version within 5 seconds.

getAutoDetectCandidatesback to summary
pack-priv static List<String> getAutoDetectCandidates(boolean windows, boolean osX)
Annotations
@VisibleForTesting
isAvailableback to summary
public boolean isAvailable()
latexToHtmlback to summary
public String latexToHtml(String latex) throws IOException, InterruptedException

Converts a LaTeX fragment to HTML via pandoc stdin/stdout (no temp files). Both stdout and stderr are drained to prevent pipe-buffer deadlock. Throws IOException if pandoc exits non-zero, surfacing the real error message.

probeCandidateback to summary
private static boolean probeCandidate(String candidate)