# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

if [[ ${PV} != 9999 ]]; then
	DIST_AUTHOR=BRMILLER
	DIST_NAME=LaTeXML
	inherit perl-module
else
	EGIT_REPO_URI="https://github.com/brucemiller/LaTeXML.git"
	EGIT_BRANCH="master"
	inherit perl-module git-r3
fi

DESCRIPTION="LaTeXML: TeX & LaTeX to XML/HTML/MathML/ePub converter"

LICENSE="Artistic"
SLOT="0"
KEYWORDS="amd64"

RDEPEND="
	dev-perl/XML-LibXML
	dev-perl/XML-LibXSLT
	dev-perl/Parse-RecDescent
	media-gfx/imagemagick[perl]
	dev-perl/Text-Unidecode
	virtual/perl-DB_File
	dev-perl/Image-Size
	dev-texlive/texlive-basic
	dev-texlive/texlive-latex
"

BDEPEND="${RDEPEND}
	virtual/perl-ExtUtils-MakeMaker
"

src_compile() {
	perl-module_src_compile
	# Preprocess plain.tex and latex.ltx from texlive for LaTeX 3 usage.
	# It may take 10-ish minutes to complete, but after this any use of the
	# LaTeX 3 kernel will complete in reasonable(ish) time.
	# https://github.com/brucemiller/LaTeXML/issues/2064
	make formats
}