|
@@ -4,6 +4,8 @@
|
|
|
global $preamble;
|
|
global $preamble;
|
|
|
global $sloppy_begin;
|
|
global $sloppy_begin;
|
|
|
global $sloppy_end;
|
|
global $sloppy_end;
|
|
|
|
|
+ $sloppy_begin = "";
|
|
|
|
|
+ $sloppy_end = "";
|
|
|
$preamble = "";
|
|
$preamble = "";
|
|
|
global $kpsefiles;
|
|
global $kpsefiles;
|
|
|
$kpsefiles = [];
|
|
$kpsefiles = [];
|
|
@@ -40,13 +42,15 @@
|
|
|
function user_prompt($msg,$default)
|
|
function user_prompt($msg,$default)
|
|
|
{
|
|
{
|
|
|
global $options;
|
|
global $options;
|
|
|
- echo "$msg [Default: $default]\n";
|
|
|
|
|
|
|
+ if (!isset($options["-n"]))
|
|
|
|
|
+ echo "$msg [Default: $default]\n";
|
|
|
$response = "";
|
|
$response = "";
|
|
|
if (!isset($options["-n"]))
|
|
if (!isset($options["-n"]))
|
|
|
$response = rtrim(fgets(STDIN));
|
|
$response = rtrim(fgets(STDIN));
|
|
|
if ($response == "")
|
|
if ($response == "")
|
|
|
$response = $default;
|
|
$response = $default;
|
|
|
- echo "You entered: '$response'\n";
|
|
|
|
|
|
|
+ if (!isset($options["-n"]))
|
|
|
|
|
+ echo "You entered: '$response'\n";
|
|
|
return $response;
|
|
return $response;
|
|
|
}
|
|
}
|
|
|
function print_help()
|
|
function print_help()
|
|
@@ -63,6 +67,8 @@ The absolute minimum for a cumulative thesis is currently 3 papers first-authore
|
|
|
--no-compile-check do not perform a compile check
|
|
--no-compile-check do not perform a compile check
|
|
|
--use-backups restore backups before making changes
|
|
--use-backups restore backups before making changes
|
|
|
--no-cover do not generate book cover pdf files
|
|
--no-cover do not generate book cover pdf files
|
|
|
|
|
+--use-subimport use \subimport for your papers / chapters
|
|
|
|
|
+--use-include use \include for your papers / chapters
|
|
|
--compile run latexmk on the resulting main.tex of your generated thesis
|
|
--compile run latexmk on the resulting main.tex of your generated thesis
|
|
|
--not-sloppy disable use of sloppypar around places that struggle without
|
|
--not-sloppy disable use of sloppypar around places that struggle without
|
|
|
(mainly the bibliographies)
|
|
(mainly the bibliographies)
|
|
@@ -276,11 +282,11 @@ END;
|
|
|
$tex = file_get_and_backup($file);
|
|
$tex = file_get_and_backup($file);
|
|
|
// labels of lstlistings etc
|
|
// labels of lstlistings etc
|
|
|
$lstlistings = [];
|
|
$lstlistings = [];
|
|
|
- preg_match_all("/\\\\begin{lstlisting}.*?\\\\end{lstlisting}/sim",$tex,$lstlistings);
|
|
|
|
|
|
|
+ preg_match_all("/(\\\\begin{lstlisting}.*?\\\\end{lstlisting}|\\\\lstset\s*(?<R>{((?:[^{}]+|(?&R))*)}))/sim",$tex,$lstlistings);
|
|
|
if (count($lstlistings[0]) > 0)
|
|
if (count($lstlistings[0]) > 0)
|
|
|
foreach ($lstlistings[0] as $l)
|
|
foreach ($lstlistings[0] as $l)
|
|
|
{
|
|
{
|
|
|
- $l2 = preg_replace("/(label\s*=\s*)(?!$d)/i",'${1}'.$d.':',$l);
|
|
|
|
|
|
|
+ $l2 = preg_replace("/(label\s*=\s*\{?)(?!$d)/i",'${1}'.$d.':',$l);
|
|
|
$tex = str_replace($l,$l2,$tex);
|
|
$tex = str_replace($l,$l2,$tex);
|
|
|
}
|
|
}
|
|
|
// normal labels
|
|
// normal labels
|
|
@@ -482,10 +488,17 @@ TODO
|
|
|
{\Large \bfseries
|
|
{\Large \bfseries
|
|
|
|
|
|
|
|
$paper_fulltitle
|
|
$paper_fulltitle
|
|
|
-}\\vspace{0.6cm}
|
|
|
|
|
-{\large $authors%
|
|
|
|
|
|
|
+
|
|
|
|
|
+\\vspace{0.6cm}}
|
|
|
|
|
+{\large
|
|
|
|
|
+
|
|
|
|
|
+$authors
|
|
|
|
|
+
|
|
|
} % TODO: check author list
|
|
} % TODO: check author list
|
|
|
-{\large $institute%
|
|
|
|
|
|
|
+{\large
|
|
|
|
|
+
|
|
|
|
|
+$institute
|
|
|
|
|
+
|
|
|
} % TODO: check institutes
|
|
} % TODO: check institutes
|
|
|
\\end{center}
|
|
\\end{center}
|
|
|
END;
|
|
END;
|
|
@@ -515,42 +528,56 @@ END;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
- $tex = preg_replace("/\\\documentclass.*\\n/i","
|
|
|
|
|
|
|
+ $tex = preg_replace("/\\\\documentclass{iacrtrans}/i","\declarecommand{\inst}[1]{\\textsuperscript{#1}}",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\documentclass.*\\n/i","
|
|
|
",$tex);
|
|
",$tex);
|
|
|
- if (preg_match("/\\\begin{document}/i",$tex) == 1)
|
|
|
|
|
|
|
+ if (preg_match("/\\\\begin{abstract}/i",$tex) == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ $tex = preg_replace("/\\\\begin{abstract}/i",$header."\n\section*{Abstract}",$tex);
|
|
|
|
|
+ $header = "";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (preg_match("/\\\\maketitle/i",$tex) == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ $tex = preg_replace("/\\\\maketitle/i",$header,$tex);
|
|
|
|
|
+ $header = "";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (preg_match("/\\\\begin{document}/i",$tex) == 1)
|
|
|
{
|
|
{
|
|
|
- $tex = preg_replace("/\\\begin{document}/i",$header,$tex);
|
|
|
|
|
|
|
+ $tex = preg_replace("/\\\\begin{document}/i",$header,$tex);
|
|
|
$header = "";
|
|
$header = "";
|
|
|
}
|
|
}
|
|
|
- $tex = preg_replace("/\\\begin{abstract}/i",'\section*{Abstract}',$tex);
|
|
|
|
|
- $tex = preg_replace("/\\\\newcommand/i",'\declarecommand',$tex);
|
|
|
|
|
- $tex = preg_replace("/\\\\renewcommand/i",'\declarecommand',$tex);
|
|
|
|
|
|
|
+ $tex = preg_replace("/\\\\begin{acks}/i","\section*{Acknowledgements}",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\end{acks}/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\(re)?newcommand/i",'\declarecommand',$tex);
|
|
|
$tex = preg_replace("/\\\\DeclareRobustCommand\s*(?<R>{((?:[^{}]+|(?&R))*)})\s*(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'',$tex);
|
|
$tex = preg_replace("/\\\\DeclareRobustCommand\s*(?<R>{((?:[^{}]+|(?&R))*)})\s*(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'',$tex);
|
|
|
- $tex = preg_replace("/\\\\newenvironment/i",'\declareenvironment',$tex);
|
|
|
|
|
- $tex = preg_replace("/\\\\renewenvironment/i",'\declareenvironment',$tex);
|
|
|
|
|
- $tex = preg_replace("/\\\\NewDocumentEnvironment/i",'\DeclareDocumentEnvironment',$tex);
|
|
|
|
|
- $tex = preg_replace("/\\\\ReNewDocumentEnvironment/i",'\DeclareDocumentEnvironment',$tex);
|
|
|
|
|
|
|
+ $tex = preg_replace("/\\\\(re)?newenvironment/i",'\declareenvironment',$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\(Re)?NewDocumentEnvironment/i",'\DeclareDocumentEnvironment',$tex);
|
|
|
$tex = preg_replace("/\\\\end{abstract}/i",'',$tex);
|
|
$tex = preg_replace("/\\\\end{abstract}/i",'',$tex);
|
|
|
$tex = preg_replace("/\\\\onecolumn/i",'',$tex);
|
|
$tex = preg_replace("/\\\\onecolumn/i",'',$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\(begin|end){(IEEEkeywords|CCSXML)}/i",'\$1{comment}',$tex);
|
|
|
$tex = preg_replace("/\\\\pagenumbering\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\pagenumbering\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\special\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\special\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\DeclareMathOperator/i",'%$0',$tex);
|
|
$tex = preg_replace("/\\\\DeclareMathOperator/i",'%$0',$tex);
|
|
|
$tex = preg_replace("/\\\\DeclareMathAlphabet/i",'%$0',$tex);
|
|
$tex = preg_replace("/\\\\DeclareMathAlphabet/i",'%$0',$tex);
|
|
|
- $tex = preg_replace("/\\\\usepackage[cache=false]{minted}/i",'\usepackage{minted}',$tex);
|
|
|
|
|
|
|
+ $tex = preg_replace("/\\\\usepackage\s*(\[[^\[\]]*\])?\s*{minted}/i",'\usepackage{minted}',$tex);
|
|
|
$tex = preg_replace("/\\\\thispagestyle{empty}/i",'%$0',$tex);
|
|
$tex = preg_replace("/\\\\thispagestyle{empty}/i",'%$0',$tex);
|
|
|
$tex = preg_replace("/\\\\PassOptionsToPackage\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'',$tex);
|
|
$tex = preg_replace("/\\\\PassOptionsToPackage\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'',$tex);
|
|
|
$tex = preg_replace("/(\\\\csvautobooktabular\s*([^{}]*)\s*)(?<R>{((?:[^{}]+|(?&R))*)})/i","\\1{{$d}/\\4}",$tex);
|
|
$tex = preg_replace("/(\\\\csvautobooktabular\s*([^{}]*)\s*)(?<R>{((?:[^{}]+|(?&R))*)})/i","\\1{{$d}/\\4}",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\AtBeginDocument\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",'',$tex);
|
|
|
$tex = preg_replace("/\\\\bibliographystyle\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",'%$0',$tex);
|
|
$tex = preg_replace("/\\\\bibliographystyle\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",'%$0',$tex);
|
|
|
$tex = preg_replace("/\\\\usetikzlibrary\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",'%$0',$tex);
|
|
$tex = preg_replace("/\\\\usetikzlibrary\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",'%$0',$tex);
|
|
|
$tex = preg_replace("/\\\\DeclareFloatFont\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\DeclareFloatFont\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\captionsetup\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])?(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\captionsetup\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])?(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\RequirePackage\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])?(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\RequirePackage\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])?(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\ccsdesc\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])?(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\tikzexternalize\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])/i","",$tex);
|
|
$tex = preg_replace("/\\\\tikzexternalize\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\floatsetup\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\floatsetup\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])(?<Q>{((?:[^{}]+|(?&Q))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\newfloat\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})(?<P>{((?:[^{}]+|(?&P))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\newfloat\s*(?<R>{((?:[^{}]+|(?&R))*)})(?<Q>{((?:[^{}]+|(?&Q))*)})(?<P>{((?:[^{}]+|(?&P))*)})/i","",$tex);
|
|
|
- $tex = preg_replace("/\s*\\\\bibliography\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","\n".'\begin{sloppypar}
|
|
|
|
|
|
|
+ global $sloppy_begin;
|
|
|
|
|
+ global $sloppy_end;
|
|
|
|
|
+ $tex = preg_replace("/\s*\\\\bibliography\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","\n".$sloppy_begin.'
|
|
|
\printbibliography[title={References}, heading=subbibliography]
|
|
\printbibliography[title={References}, heading=subbibliography]
|
|
|
-\end{sloppypar}',$tex);
|
|
|
|
|
|
|
+'.$sloppy_end,$tex);
|
|
|
$tex = preg_replace("/\\\\end{document}/i",'',$tex);
|
|
$tex = preg_replace("/\\\\end{document}/i",'',$tex);
|
|
|
$tex = preg_replace("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\n\s*\\\\author\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\tag\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\tag\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
@@ -558,16 +585,29 @@ END;
|
|
|
$tex = preg_replace("/\n\s*\\\\institute\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\n\s*\\\\institute\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\n\s*\\\\title\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\n\s*\\\\date\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\n\s*\\\\date\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
- $tex = preg_replace("/\\\\includegraphics\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'\includegraphics${1}{'.$d.'/${4}}',$tex);
|
|
|
|
|
- if (preg_match("/\\\\maketitle/i",$tex) == 1)
|
|
|
|
|
- {
|
|
|
|
|
- $tex = preg_replace("/\\\\maketitle/i",$header,$tex);
|
|
|
|
|
- $header = "";
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ $graphicspath = "";
|
|
|
|
|
+ preg_match("/\\\\graphicspath\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$tex,$matches);
|
|
|
|
|
+ if (count($matches) > 3)
|
|
|
|
|
+ preg_match("/(?<R>{((?:[^{}]+|(?&R))*)})*/i",$matches[2],$matches);
|
|
|
|
|
+ if (count($matches) > 3)
|
|
|
|
|
+ $graphicspath = $matches[2];
|
|
|
|
|
+ $tex = preg_replace("/\\\\includegraphics\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])(?<Q>{((?:[^{}]+|(?&Q))*)})/i",'\includegraphics${1}{'.$d."/".$graphicspath.'${4}}',$tex);
|
|
|
$tex = preg_replace("/\\\\IEEEoverridecommandlockouts/i","",$tex);
|
|
$tex = preg_replace("/\\\\IEEEoverridecommandlockouts/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\IEEEauthorblock[AN]/i","",$tex);
|
|
$tex = preg_replace("/\\\\IEEEauthorblock[AN]/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\IEEEauthorrefmark/i","\\textsuperscript",$tex);
|
|
$tex = preg_replace("/\\\\IEEEauthorrefmark/i","\\textsuperscript",$tex);
|
|
|
$tex = preg_replace("/\\\\twocolumn/i","",$tex);
|
|
$tex = preg_replace("/\\\\twocolumn/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\copyrightyear\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\setcopyright\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\settopmatter\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\acmYear\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\email\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\acmBooktitle\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\acmPrice\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\acmDOI\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\acmISBN\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\fancyhead\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\affiliation\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/\\\\acmConference\s*(?<R>\[((?:[^\[\]]+|(?&R))*)\])?\s*(?<Q>{((?:[^{}]+|(?&Q))*)})\s*(?<X>{((?:[^{}]+|(?&X))*)})\s*(?<Y>{((?:[^{}]+|(?&Y))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\SetWatermarkText\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\SetWatermarkText\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\ProvidesPackage\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\ProvidesPackage\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
$tex = preg_replace("/\\\\SetWatermarkScale\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
$tex = preg_replace("/\\\\SetWatermarkScale\s*(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
@@ -577,22 +617,28 @@ END;
|
|
|
global $ignore_packages;
|
|
global $ignore_packages;
|
|
|
global $included_usepackages;
|
|
global $included_usepackages;
|
|
|
global $additional_usepackages;
|
|
global $additional_usepackages;
|
|
|
- foreach (array_diff($ps,$included_usepackages) as $k => $v) {
|
|
|
|
|
- if (in_array($v,['minted']))
|
|
|
|
|
- {
|
|
|
|
|
- $additional_usepackages[] = "\usepackage{minted}";
|
|
|
|
|
- $included_usepackages[] = $v;
|
|
|
|
|
- }
|
|
|
|
|
- else if (!in_array($v,$ignore_packages) && !($v == 'floatrow' && in_array('float',$included_usepackages)))
|
|
|
|
|
|
|
+ foreach (array_diff($ps,$included_usepackages) as $k => $packagelist) {
|
|
|
|
|
+ $packagelist = explode(",",$packagelist);
|
|
|
|
|
+ foreach ($packagelist as $v)
|
|
|
{
|
|
{
|
|
|
- $additional_usepackages[] = $ups[$k];
|
|
|
|
|
- $included_usepackages[] = $v;
|
|
|
|
|
|
|
+ // if (in_array($v,['minted']))
|
|
|
|
|
+ // {
|
|
|
|
|
+ // $additional_usepackages[] = "\usepackage{minted}";
|
|
|
|
|
+ // $included_usepackages[] = $v;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // else
|
|
|
|
|
+ if (!in_array($v,$ignore_packages) && !($v == 'floatrow' && in_array('float',$included_usepackages)))
|
|
|
|
|
+ {
|
|
|
|
|
+ if (preg_match("/\\\\usepackage\s*(\[[^\[\]]*\])?\s*(?<R>{((?:[^{}]+|(?&R))*)})/i",$ups[$k]) > 0)
|
|
|
|
|
+ $additional_usepackages[] = $ups[$k];
|
|
|
|
|
+ $included_usepackages[] = $v;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
array_unique($additional_usepackages);
|
|
array_unique($additional_usepackages);
|
|
|
- $tex = preg_replace("/\n\s*\\\\usepackage([^{}]*)(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
- $tex = preg_replace("/^\s*\\\\usepackage([^{}]*)(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ $tex = preg_replace("/\n\s*\\\\usepackage([^{}]*?)(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+ $tex = preg_replace("/^\s*\\\\usepackage([^{}]*?)(?<R>{((?:[^{}]+|(?&R))*)})/i","",$tex);
|
|
|
|
|
+
|
|
|
$tex = preg_replace("/\n\s*\\\\setlength{\s*\\\marginparwidth.*\n/i","\n",$tex);
|
|
$tex = preg_replace("/\n\s*\\\\setlength{\s*\\\marginparwidth.*\n/i","\n",$tex);
|
|
|
|
|
|
|
|
if (stripos($tex,"\appendices") !== false || stripos($tex,"\appendix") !== false)
|
|
if (stripos($tex,"\appendices") !== false || stripos($tex,"\appendix") !== false)
|
|
@@ -650,15 +696,18 @@ END;
|
|
|
$failed = false;
|
|
$failed = false;
|
|
|
foreach($lines as $l)
|
|
foreach($lines as $l)
|
|
|
{
|
|
{
|
|
|
- if (str_starts_with($l,"Latexmk: ====List of undefined refs and citations:"))
|
|
|
|
|
|
|
+ if (str_starts_with($l,"Latexmk: ====List of undefined refs and citations:") || strpos($l,"LaTeX Error:") !== false)
|
|
|
|
|
+ {
|
|
|
$skip = false;
|
|
$skip = false;
|
|
|
|
|
+ $failed = true;
|
|
|
|
|
+ }
|
|
|
if ($skip)
|
|
if ($skip)
|
|
|
continue;
|
|
continue;
|
|
|
if (stripos($l,"fail") !== false)
|
|
if (stripos($l,"fail") !== false)
|
|
|
$failed = true;
|
|
$failed = true;
|
|
|
echo "$l\n";
|
|
echo "$l\n";
|
|
|
}
|
|
}
|
|
|
- if ($failed || user_consent("Please check the PDF file. Are there any problems with invalid references to figures, tables or with the bibliography?","--","--no-overwrite"))
|
|
|
|
|
|
|
+ if ($failed || user_consent("Please check the PDF file. Are there any problems with invalid references to figures, tables or with the bibliography?","","-n"))
|
|
|
error_exit("The paper did not compile properly, please fix the errors next before continuing.");
|
|
error_exit("The paper did not compile properly, please fix the errors next before continuing.");
|
|
|
echo "======= Paper $p -> $f END =======\n";
|
|
echo "======= Paper $p -> $f END =======\n";
|
|
|
}
|
|
}
|
|
@@ -691,8 +740,6 @@ END;
|
|
|
if (isset($options["--help"]))
|
|
if (isset($options["--help"]))
|
|
|
print_help();
|
|
print_help();
|
|
|
|
|
|
|
|
- $sloppy_begin = "";
|
|
|
|
|
- $sloppy_end = "";
|
|
|
|
|
if (!isset($options["--no-sloppy"]))
|
|
if (!isset($options["--no-sloppy"]))
|
|
|
{
|
|
{
|
|
|
$sloppy_begin = '\begin{sloppypar}';
|
|
$sloppy_begin = '\begin{sloppypar}';
|
|
@@ -723,7 +770,7 @@ END;
|
|
|
echo "\n=== Step 7/$steps: Initialize KPSE Database ===\n\n";
|
|
echo "\n=== Step 7/$steps: Initialize KPSE Database ===\n\n";
|
|
|
init_kpse();
|
|
init_kpse();
|
|
|
global $ignore_packages;
|
|
global $ignore_packages;
|
|
|
- $ignore_packages = explode(",",user_prompt("Enter a comma-separated list of packages that should be considered ignored (e.g. publisher or conference styles, as well as packages that modify font or page formats)","usenix,epsfig,endnotes,flushend,mathptmx,pslatex,fontenc,microtype,draftwatermark,usenixbadges,cite,csvenhanced,etex,filecontents"));
|
|
|
|
|
|
|
+ $ignore_packages = explode(",",user_prompt("Enter a comma-separated list of packages that should be considered ignored (e.g. publisher or conference styles, as well as packages that modify font or page formats)","a4paper,cite,csvenhanced,draftwatermark,endnotes,epsfig,etex,fdsymbol,filecontents,flushend,fontenc,mathptmx,microtype,pslatex,subfig,usenix,usenixbadges,xwatermark"));
|
|
|
echo "\n=== Step 8/$steps: Flattening Papers ===\n\n";
|
|
echo "\n=== Step 8/$steps: Flattening Papers ===\n\n";
|
|
|
foreach ($papers as $d => $f)
|
|
foreach ($papers as $d => $f)
|
|
|
flatten($d,$f);
|
|
flatten($d,$f);
|
|
@@ -761,7 +808,7 @@ END;
|
|
|
require "main.tex.php";
|
|
require "main.tex.php";
|
|
|
$maintex_content = ob_get_contents();
|
|
$maintex_content = ob_get_contents();
|
|
|
ob_end_clean();
|
|
ob_end_clean();
|
|
|
- if (!file_exists("main.tex") || user_consent("main.tex already exists. overwrite?"))
|
|
|
|
|
|
|
+ if (!file_exists("main.tex") || user_consent("main.tex already exists. overwrite?","--force-overwrite","--no-overwrite"))
|
|
|
file_put_contents("main.tex",$maintex_content);
|
|
file_put_contents("main.tex",$maintex_content);
|
|
|
|
|
|
|
|
if (!file_exists("mypreamble.sty") || user_consent("mypreamble.sty already exists... overwrite?","--force-overwrite","--no-overwrite"))
|
|
if (!file_exists("mypreamble.sty") || user_consent("mypreamble.sty already exists... overwrite?","--force-overwrite","--no-overwrite"))
|
|
@@ -795,7 +842,7 @@ END;
|
|
|
require "cover1.tex.php";
|
|
require "cover1.tex.php";
|
|
|
$covertex_content = ob_get_contents();
|
|
$covertex_content = ob_get_contents();
|
|
|
ob_end_clean();
|
|
ob_end_clean();
|
|
|
- if (!file_exists("cover1.tex") || user_consent("cover1.tex already exists. overwrite?"))
|
|
|
|
|
|
|
+ if (!file_exists("cover1.tex") || user_consent("cover1.tex already exists. overwrite?","--force-overwrite","--no-overwrite"))
|
|
|
file_put_contents("cover1.tex",$covertex_content);
|
|
file_put_contents("cover1.tex",$covertex_content);
|
|
|
|
|
|
|
|
shell_exec('latexmk -latexoption="-file-line-error -shell-escape -interaction=nonstopmode" -g -pdf cover1.tex 1>/dev/null 2>/dev/null');
|
|
shell_exec('latexmk -latexoption="-file-line-error -shell-escape -interaction=nonstopmode" -g -pdf cover1.tex 1>/dev/null 2>/dev/null');
|
|
@@ -804,7 +851,7 @@ END;
|
|
|
require "cover2.tex.php";
|
|
require "cover2.tex.php";
|
|
|
$covertex_content = ob_get_contents();
|
|
$covertex_content = ob_get_contents();
|
|
|
ob_end_clean();
|
|
ob_end_clean();
|
|
|
- if (!file_exists("cover2.tex") || user_consent("cover2.tex already exists. overwrite?"))
|
|
|
|
|
|
|
+ if (!file_exists("cover2.tex") || user_consent("cover2.tex already exists. overwrite?","--force-overwrite","--no-overwrite"))
|
|
|
file_put_contents("cover2.tex",$covertex_content);
|
|
file_put_contents("cover2.tex",$covertex_content);
|
|
|
|
|
|
|
|
shell_exec('latexmk -latexoption="-file-line-error -shell-escape -interaction=nonstopmode" -g -pdf cover2.tex 1>/dev/null 2>/dev/null');
|
|
shell_exec('latexmk -latexoption="-file-line-error -shell-escape -interaction=nonstopmode" -g -pdf cover2.tex 1>/dev/null 2>/dev/null');
|
|
@@ -815,6 +862,6 @@ END;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- echo "=== done ===\nNext step, run this command:\nlatexmk -latexoption=\"-shell-escape\" -g -pdf main.tex\n";
|
|
|
|
|
|
|
+ echo "=== done ===\nNext step, run this command:\nlatexmk -latexoption=\"-file-line-error -shell-escape -interaction=errorstopmode -halt-on-error\" -g -pdf main.tex\n";
|
|
|
}
|
|
}
|
|
|
?>
|
|
?>
|