@@ -79,39 +79,50 @@ def latex2pdf(options: argparse.Namespace) -> bool:
79
79
problembase = os .path .splitext (os .path .basename (problem_root ))[0 ]
80
80
destfile = string .Template (options .destfile ).safe_substitute (problem = problembase )
81
81
82
- # We skip PDF check when verifying problems with markdown statements
83
- if os .path .isfile (os .path .join (problem , "problem_statement" , "problem.%s.md" % options .language )) and ignore_markdown :
84
- return True
82
+ if statement_common .find_statement_extension (problem_root , language = options .language ) == "md" :
83
+ statement_path = statement_common .find_statement (problem_root , extension = "md" , language = options .language )
85
84
86
85
# Set up template if necessary
87
86
with template .Template (problem_root , language = options .language ) as templ :
88
87
texfile = templ .get_file_name ()
89
88
90
- origcwd = os .getcwd ()
89
+ statement_md += samples_md
90
+ with tempfile .NamedTemporaryFile (mode = 'w' , suffix = ".md" ) as temp_file :
91
+ temp_file .write (statement_md )
92
+ temp_file .flush ()
93
+ # Do .read so that the file isn't deleted until pandoc is done
94
+ os .popen (f"pandoc { temp_file .name } -o { problembase } .pdf --resource-path={ statement_dir } " ).read ()
95
+
96
+ else :
97
+ # Set up template if necessary
98
+ with template .Template (problem_root , language = options .language ) as templ :
99
+ texfile = templ .get_file_name ()
100
+
101
+ origcwd = os .getcwd ()
91
102
92
- os .chdir (os .path .dirname (texfile ))
93
- params = ['pdflatex' , '-interaction=nonstopmode' ]
94
- output = None
95
- if options .quiet :
96
- output = open (os .devnull , 'w' )
97
- if options .nopdf :
98
- params .append ('-draftmode' )
103
+ os .chdir (os .path .dirname (texfile ))
104
+ params = ['pdflatex' , '-interaction=nonstopmode' ]
105
+ output = None
106
+ if options .quiet :
107
+ output = open (os .devnull , 'w' )
108
+ if options .nopdf :
109
+ params .append ('-draftmode' )
99
110
100
- params .append (texfile )
111
+ params .append (texfile )
101
112
102
- status = subprocess .call (params , stdout = output )
103
- if status == 0 :
104
113
status = subprocess .call (params , stdout = output )
114
+ if status == 0 :
115
+ status = subprocess .call (params , stdout = output )
105
116
106
- if output is not None :
107
- output .close ()
117
+ if output is not None :
118
+ output .close ()
108
119
109
- os .chdir (origcwd )
120
+ os .chdir (origcwd )
110
121
111
- if status == 0 and not options .nopdf :
112
- shutil .move (os .path .splitext (texfile )[0 ] + '.pdf' , destfile )
122
+ if status == 0 and not options .nopdf :
123
+ shutil .move (os .path .splitext (texfile )[0 ] + '.pdf' , destfile )
113
124
114
- return status == 0
125
+ return status == 0
115
126
116
127
117
128
def get_parser () -> argparse .ArgumentParser :
0 commit comments