better implementation
This commit is contained in:
parent
5d999b01b2
commit
f2a0b1701e
4 changed files with 26 additions and 30 deletions
18
index.php
Normal file
18
index.php
Normal file
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
$type = $_POST['type'];
|
||||
|
||||
if ($type == "tex") {
|
||||
move_uploaded_file($_FILES["file"]["tmp_name"], "tmp.tex");
|
||||
$output = shell_exec("latex -interaction nonstopmode tmp.tex");
|
||||
echo "http://$host/tmp.dvi";
|
||||
}
|
||||
|
||||
if ($type == "dvi") {
|
||||
$dpi = isset($_POST['dpi']) ? intval($_POST['dpi']) : 200;
|
||||
move_uploaded_file($_FILES["file"]["tmp_name"], "tmp.dvi");
|
||||
shell_exec("dvipng -D $dpi -T tight -bg Transparent -o tmp.png tmp.dvi");
|
||||
echo "http://$host/tmp.png";
|
||||
}
|
||||
|
||||
?>
|
|
@ -1,10 +0,0 @@
|
|||
<?php
|
||||
move_uploaded_file($_FILES["file"]["tmp_name"], "tmp.tex");
|
||||
$dpi = isset($_POST['dpi']) ? intval($_POST['dpi']) : 200;
|
||||
$output = shell_exec("./tex2png.sh tmp.tex $dpi");
|
||||
|
||||
if ($output !== null) {
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
echo "http://$host/$output";
|
||||
}
|
||||
?>
|
|
@ -1,12 +0,0 @@
|
|||
#!/bin/sh
|
||||
file="$1"
|
||||
dpi="$2"
|
||||
[ "$file" ] || exit 1
|
||||
out="${file%.tex}.png"
|
||||
|
||||
makepng() {
|
||||
latex -interaction nonstopmode "$file" >/dev/null 2>&1 || return 1
|
||||
dvipng -D "$dpi" -T tight -bg Transparent -o "$out" "${file%.tex}.dvi" >/dev/null 2>&1 || return 1
|
||||
}
|
||||
|
||||
makepng && echo "$out" || exit 1
|
16
texpngweb.el
16
texpngweb.el
|
@ -3,13 +3,13 @@
|
|||
(if (eq system-type 'android)
|
||||
(progn ;; Android custom org-latex-preview
|
||||
(setq org-preview-latex-process-alist
|
||||
'((texpngweb
|
||||
:programs ("curl")
|
||||
:description "tex > png"
|
||||
:message "you need to install curl."
|
||||
:image-input-type "tex"
|
||||
'((dvipngweb
|
||||
:programs ("latex" "dvipng")
|
||||
:description "dvi > png"
|
||||
:message "you need to install the programs: latex and dvipng."
|
||||
:image-input-type "dvi"
|
||||
:image-output-type "png"
|
||||
:image-size-adjust (1.0 . 1.0)
|
||||
:latex-compiler ("")
|
||||
:image-converter ("curl -F \"file=@%f\" -F \"dpi=%D\" http://0.0.0.0:8000 && curl http://0.0.0.0:8000/tmp.png -o %O"))))
|
||||
(setq org-latex-create-formula-image-program 'texpngweb)))
|
||||
:latex-compiler ("curl -F \"file=@%f\" -F \"type=tex\" 0.0.0.0:8000 && curl 0.0.0.0:8000/tmp.dvi -o %O")
|
||||
:image-converter ("curl -F \"file=@%f\" -F \"type=dvi\" -F \"dpi=%D\" -o %O 0.0.0.0:8000 && curl 0.0.0.0:8000/tmp.png -o %O"))))
|
||||
(setq org-latex-create-formula-image-program 'dvipngweb)))
|
||||
|
|
Loading…
Reference in a new issue