File tree Expand file tree Collapse file tree 5 files changed +63
-5
lines changed Expand file tree Collapse file tree 5 files changed +63
-5
lines changed Original file line number Diff line number Diff line change 4545
4646 contents = [
4747 pkgs . lighttpd
48+ pkgs . pandoc
49+ pkgs . poppler_utils
50+ ( pkgs . texlive . combine {
51+ inherit ( pkgs . texlive ) scheme-basic algorithmicx xcolor standalone preview ;
52+ } )
4853 ( pkgs . writeShellScriptBin "python-wrapper" ''
4954 export PYTHONPATH=${ pkgs . runCommand "pandocode-module" { } ''
5055 mkdir -p $out
5156 cp -r ${ ./. } /. $out/pandocode
5257 '' }
53- exec ${ python } /bin/python3 "$@"
58+ exec ${ pkgs . python3 . withPackages ( pypi : with pypi ; [
59+ panflute
60+ pdf2image
61+ pillow
62+ ] ) } /bin/python3 "$@"
5463 '' )
5564 ( pkgs . runCommand "content" { } ''
56- mkdir -p $out/var/www/cgi-bin
65+ mkdir -p $out/var/www
5766 cp -vr ${ pandocode-live-frontend } /. $out/var/www/
5867 cp -vr ${ ./live/cgi-bin } /. $out/var/www/cgi-bin
68+ cp -vr ${ ./live/etc } /. $out/etc
5969 '' )
6070 ] ;
6171
72+ enableFakechroot = true ;
73+ fakeRootCommands = ''
74+ mkdir -p /root /etc /tmp
75+ echo 'root:x:0:0::/root:/noshell' > /etc/passwd
76+ '' ;
77+
6278 config = {
63- Cmd = [ "/bin/lighttpd" "-D" "-f" "${ ./live /lighttpd.conf} " ] ;
79+ Cmd = [ "/bin/lighttpd" "-D" "-f" "/etc /lighttpd.conf" ] ;
6480 Env = [ "" ] ;
6581 ExposedPorts = {
6682 "8080/tcp" = { } ;
Original file line number Diff line number Diff line change 1+ # print every line back
2+ import subprocess
3+ import sys
4+ from io import BytesIO
5+ from pdf2image import convert_from_bytes
6+ from pandocode .codeprocessor import process_code
7+
8+ print ("Content-type: image/webp" )
9+ print ("Access-Control-Allow-Origin: *" )
10+ print ("" )
11+ sys .stdout .flush ()
12+
13+ processed = process_code (sys .stdin .read ())
14+ process = subprocess .run (
15+ [
16+ 'pandoc' ,
17+ '-f' , 'markdown' ,
18+ '-t' , 'pdf' ,
19+ '--template' , '/etc/template.tex' ,
20+ '--pdf-engine' , 'pdflatex' ,
21+ '--pdf-engine-opt' , '-disable-write18' ,
22+ '-o' , '-'
23+ ],
24+ input = processed .encode ('utf-8' ),
25+ stdout = subprocess .PIPE ,
26+ )
27+ if process .returncode != 0 :
28+ exit (process .returncode )
29+
30+ images = convert_from_bytes (process .stdout )
31+ image_bytes = BytesIO ()
32+ images [0 ].save (image_bytes , format = 'WebP' )
33+ image_bytes = image_bytes .getvalue ()
34+
35+ sys .stdout .buffer .write (image_bytes )
36+ sys .stdout .flush ()
Original file line number Diff line number Diff line change 1- # print every line back
21import sys
32from pandocode .codeprocessor import process_code
43
54print ("Content-type: text/plain" )
65print ("Access-Control-Allow-Origin: *" )
76print ("" )
7+ sys .stdout .flush ()
88
9- print (process_code (sys .stdin .read ()))
9+ sys .stdout .write (process_code (sys .stdin .read ()))
10+ sys .stdout .flush ()
File renamed without changes.
Original file line number Diff line number Diff line change 1+ \documentclass [preview ]{standalone }
2+ \usepackage [noend ]{algpseudocode }
3+ \begin {document }
4+ $ body$
5+ \end {document }
You can’t perform that action at this time.
0 commit comments