File tree 5 files changed +63
-5
lines changed
5 files changed +63
-5
lines changed Original file line number Diff line number Diff line change 45
45
46
46
contents = [
47
47
pkgs . lighttpd
48
+ pkgs . pandoc
49
+ pkgs . poppler_utils
50
+ ( pkgs . texlive . combine {
51
+ inherit ( pkgs . texlive ) scheme-basic algorithmicx xcolor standalone preview ;
52
+ } )
48
53
( pkgs . writeShellScriptBin "python-wrapper" ''
49
54
export PYTHONPATH=${ pkgs . runCommand "pandocode-module" { } ''
50
55
mkdir -p $out
51
56
cp -r ${ ./. } /. $out/pandocode
52
57
'' }
53
- exec ${ python } /bin/python3 "$@"
58
+ exec ${ pkgs . python3 . withPackages ( pypi : with pypi ; [
59
+ panflute
60
+ pdf2image
61
+ pillow
62
+ ] ) } /bin/python3 "$@"
54
63
'' )
55
64
( pkgs . runCommand "content" { } ''
56
- mkdir -p $out/var/www/cgi-bin
65
+ mkdir -p $out/var/www
57
66
cp -vr ${ pandocode-live-frontend } /. $out/var/www/
58
67
cp -vr ${ ./live/cgi-bin } /. $out/var/www/cgi-bin
68
+ cp -vr ${ ./live/etc } /. $out/etc
59
69
'' )
60
70
] ;
61
71
72
+ enableFakechroot = true ;
73
+ fakeRootCommands = ''
74
+ mkdir -p /root /etc /tmp
75
+ echo 'root:x:0:0::/root:/noshell' > /etc/passwd
76
+ '' ;
77
+
62
78
config = {
63
- Cmd = [ "/bin/lighttpd" "-D" "-f" "${ ./live /lighttpd.conf} " ] ;
79
+ Cmd = [ "/bin/lighttpd" "-D" "-f" "/etc /lighttpd.conf" ] ;
64
80
Env = [ "" ] ;
65
81
ExposedPorts = {
66
82
"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
2
1
import sys
3
2
from pandocode .codeprocessor import process_code
4
3
5
4
print ("Content-type: text/plain" )
6
5
print ("Access-Control-Allow-Origin: *" )
7
6
print ("" )
7
+ sys .stdout .flush ()
8
8
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