1111 https://github.com/maxulysse/compile-latex
1212--------------------------------------------------------------------------------
1313 @Documentation
14- https://github.com/maxulysse/compile-latex/blob/master /README.md
14+ https://github.com/maxulysse/compile-latex/blob/main /README.md
1515--------------------------------------------------------------------------------
1616 @Licence
17- https://github.com/maxulysse/compile-latex/blob/master /LICENSE
17+ https://github.com/maxulysse/compile-latex/blob/main /LICENSE
1818--------------------------------------------------------------------------------
1919 Process overview
20- - RunXelatex
20+ - RUNXELATEX
2121 Run xelatex, optionally biber and xelatex and finally xelatex again
22- ================================================================================
23- = C O N F I G U R A T I O N =
24- ================================================================================
2522*/
2623
27- if (params. help) exit 0 , helpMessage()
28- if (! params. tex) exit 1 , ' No tex file, see --help for more information'
29-
30- biblio = file(params. biblio)
31- pictures = file(params. pictures)
32- tex = Channel . fromPath(params. tex)
33-
34- /*
35- ================================================================================
36- = P R O C E S S =
37- ================================================================================
38- */
39-
40- startMessage()
41-
42- process RunXelatex {
43- tag {tex}
24+ process RUNXELATEX {
25+ tag { tex }
4426
4527 publishDir params. outdir, mode: ' link'
4628
4729 input:
48- file biblio
49- file pictures
50- file tex
30+ path biblio
31+ path pictures
32+ path tex
5133
5234 output:
53- file( " *.pdf" ) into pdf
35+ path " *.pdf" , emit: pdf
5436
5537 script:
56- notes = params. notes == ' ' ? " " : " \"\\ PassOptionsToClass{notes}{beamer}\\ input{$tex }\ ""
57- notes = params. notes_only == ' ' ? notes : " \"\\ PassOptionsToClass{notes=only}{beamer}\\ input{$tex }\" "
58- xelatexScript = notes == ' ' ? " xelatex -shell-escape ${ tex} " : " xelatex -shell-escape ${ notes} "
59- biberScript = biblio. exists() ? " biber ${ tex.baseName} .bcf ; ${ xelatexScript} " : " "
60- renameScript = params. outname == ' ' ? " " : " cp ${ tex.baseName} .pdf ${ params.outname} "
38+ notes = params. notes ? " \"\\ PassOptionsToClass{notes}{beamer}\\ input{${ tex} } \" " : " "
39+ notes = params. notes_only ? notes : " \"\\ PassOptionsToClass{notes=only}{beamer}\\ input{${ tex} }\" "
40+ xelatexScript = notes ? " xelatex -shell-escape ${ tex} " : " xelatex -shell-escape ${ notes} "
41+ biberScript = biblio. exists() ? " biber ${ tex.baseName} .bcf ; ${ xelatexScript} " : " "
42+ renameScript = params. outname ? " cp ${ tex.baseName} .pdf ${ params.outname} " : " "
6143
6244 """
6345 ${ xelatexScript}
@@ -67,98 +49,84 @@ process RunXelatex {
6749 """
6850}
6951
52+ workflow {
53+ if (params. help) {
54+ log. info(helpMessage())
55+ exit(0 )
56+ }
57+ if (! params. tex) {
58+ log. error(' No tex file, see --help for more information' )
59+ exit(1 )
60+ }
61+
62+ // Display start message
63+ compileLatex_ascii()
64+ minimalInformationMessage()
65+
66+ // Create input channels
67+ biblio_ch = Channel . fromPath(params. biblio)
68+ pictures_ch = Channel . fromPath(params. pictures)
69+ tex_ch = Channel . fromPath(params. tex)
70+
71+ // Run the main process
72+ RUNXELATEX (biblio_ch, pictures_ch, tex_ch)
73+ }
74+
7075/*
7176================================================================================
7277= F U N C T I O N S =
7378================================================================================
7479*/
7580
7681def compileLatex_ascii() {
77- println " "
78- println " _.-´`-._ _ _ _ _"
79- println " _.-´ T X `-._ (_) | | | | |"
80- println " |`-._ E _.-´| ___ ___ _ __ ___ _ __ _| | ___ | | __ _| |_ _____ __"
81- println " |--. `-.__.-´ . | / __/ _ \\ | '_ ` _ \\ | '_ \\ | | |/ _ \\ ___| |/ _` | __/ _ \\ \\ / /"
82- println " | \\ .---| . | | | | (_| (_) | | | | | | |_) | | | __/___| | (_| | || __/> <"
83- println " |---´\\ | | | | | \\ ___\\ ___/|_| |_| |_| .__/|_|_|\\ ___| |_|\\ __,_|\\ __\\ ___/_/\\ _\\ "
84- println " `-._ `--| | '_.-´ | |"
85- println " `-._|_.-´ |_|"
86- println " "
87- }
88-
89- def compileLatexMessage() {
90- // Display compile-latex message
91- log. info " compile-latex ~ ${ workflow.manifest.version} - " + this . grabRevision() + (workflow. commitId ? " [$workflow . commitId ]" : " " )
92- }
93-
94- def grabRevision() {
95- // Return the same string executed from github or not
96- return workflow. revision ?: workflow. commitId ?: workflow. scriptId. substring(0 ,10 )
82+ println (" " )
83+ println (" _.-´`-._ _ _ _ _" )
84+ println (" _.-´ T X `-._ (_) | | | | |" )
85+ println (" |`-._ E _.-´| ___ ___ _ __ ___ _ __ _| | ___ | | __ _| |_ _____ __" )
86+ println (" |--. `-.__.-´ . | / __/ _ \\ | '_ ` _ \\ | '_ \\ | | |/ _ \\ ___| |/ _` | __/ _ \\ \\ / /" )
87+ println (" | \\ .---| . | | | | (_| (_) | | | | | | |_) | | | __/___| | (_| | || __/> <" )
88+ println (" |---´\\ | | | | | \\ ___\\ ___/|_| |_| |_| .__/|_|_|\\ ___| |_|\\ __,_|\\ __\\ ___/_/\\ _\\ " )
89+ println (" `-._ `--| | '_.-´ | |" )
90+ println (" `-._|_.-´ |_|" )
91+ println (" " )
92+ println (" compile-latex ~ ${ workflow.manifest.version} " )
9793}
9894
9995def helpMessage() {
10096 // Display help message
101- this . compileLatexMessage()
102- log. info " Usage:"
103- log. info " nextflow run maxulysse/compile-latex --tex <input.tex>"
104- log. info " --tex"
105- log. info " Compile the given tex file"
106- log. info " --biblio"
107- log. info " Specify the bibliography"
108- log. info " Default: biblio.bib"
109- log. info " --notes"
110- log. info " Generate notes with presentation"
111- log. info " --pictures"
112- log. info " Specify in which directory are the pictures"
113- log. info " Default: pictures/"
114- log. info " --tag"
115- log. info " Specify with tag to use for the docker container"
116- log. info " --outname"
117- log. info " Specify output name"
118- log. info " --outdir"
119- log. info " Specify output directory"
120- log. info " --help"
121- log. info " You're reading it"
97+ log. info(" Usage:" )
98+ log. info(" nextflow run maxulysse/compile-latex --tex <input.tex>" )
99+ log. info(" --tex" )
100+ log. info(" Compile the given tex file" )
101+ log. info(" --biblio" )
102+ log. info(" Specify the bibliography" )
103+ log. info(" Default: biblio.bib" )
104+ log. info(" --notes" )
105+ log. info(" Generate notes with presentation" )
106+ log. info(" --pictures" )
107+ log. info(" Specify in which directory are the pictures" )
108+ log. info(" Default: pictures/" )
109+ log. info(" --tag" )
110+ log. info(" Specify with tag to use for the docker container" )
111+ log. info(" --outname" )
112+ log. info(" Specify output name" )
113+ log. info(" --outdir" )
114+ log. info(" Specify output directory" )
115+ log. info(" --help" )
116+ log. info(" You're reading it" )
122117}
123118
124119def minimalInformationMessage() {
125120 // Minimal information message
126- log. info " Command Line: " + workflow. commandLine
127- log. info " Launch Dir : " + workflow. launchDir
128- log. info " Work Dir : " + workflow. workDir
129- log. info " Container : " + workflow. container
130- log. info " Tex file(s) : " + params. tex
131- if (biblio. exists()) log. info " Bibliography: " + params. biblio
132- if (pictures. exists()) log. info " Pictures in : " + params. pictures
133- }
134-
135- def nextflowMessage() {
136- // Nextflow message (version + build)
137- log. info " N E X T F L O W ~ version " + workflow. nextflow. version + " " + workflow. nextflow. build
138- }
139-
140- def startMessage() {
141- // Display start message
142- this . compileLatex_ascii()
143- this . compileLatexMessage()
144- this . minimalInformationMessage()
145- }
146-
147- workflow. onComplete {
148- // Display end message
149- this . nextflowMessage()
150- this . compileLatexMessage()
151- this . minimalInformationMessage()
152- log. info " Completed at: " + workflow. complete
153- log. info " Duration : " + workflow. duration
154- log. info " Success : " + workflow. success
155- log. info " Exit status : " + workflow. exitStatus
156- log. info " Error report: " + (workflow. errorReport ?: ' -' )
157- }
158-
159- workflow. onError {
160- // Display error message
161- this . nextflowMessage()
162- this . compileLatexMessage()
163- log. info " Workflow execution stopped with the following message: " + $workflow. errorMessage
121+ log. info(" Command Line: " + workflow. commandLine)
122+ log. info(" Launch Dir : " + workflow. launchDir)
123+ log. info(" Work Dir : " + workflow. workDir)
124+ log. info(" Container : " + workflow. container)
125+ log. info(" Tex file(s) : " + params. tex)
126+ if (file(params. biblio). exists()) {
127+ log. info(" Bibliography: " + params. biblio)
128+ }
129+ if (file(params. pictures). exists()) {
130+ log. info(" Pictures in : " + params. pictures)
131+ }
164132}
0 commit comments