copy to clipboard
This commit is contained in:
parent
f077a800f9
commit
6f49462d70
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
node_modules/
|
node_modules/
|
||||||
temp/
|
temp/
|
||||||
output/
|
output/
|
||||||
|
.env
|
||||||
|
.sh
|
8
app.js
8
app.js
@ -86,6 +86,7 @@ conversionRouter.post('/convert', async (req, res) => {
|
|||||||
await fsPromises.writeFile(`${tempDir}/${id}/equation.tex`, getLatexTemplate(equation));
|
await fsPromises.writeFile(`${tempDir}/${id}/equation.tex`, getLatexTemplate(equation));
|
||||||
|
|
||||||
// Run the LaTeX compiler and generate a .svg file
|
// Run the LaTeX compiler and generate a .svg file
|
||||||
|
console.log(getDockerCommand(id, outputScale))
|
||||||
await execAsync(getDockerCommand(id, outputScale));
|
await execAsync(getDockerCommand(id, outputScale));
|
||||||
|
|
||||||
const inputSvgFileName = `${tempDir}/${id}/equation.svg`;
|
const inputSvgFileName = `${tempDir}/${id}/equation.svg`;
|
||||||
@ -163,11 +164,12 @@ function getDockerCommand(id, output_scale) {
|
|||||||
timeout 5 dvisvgm --no-fonts --scale=${output_scale} --exact equation.dvi`;
|
timeout 5 dvisvgm --no-fonts --scale=${output_scale} --exact equation.dvi`;
|
||||||
|
|
||||||
// Start the container in the appropriate directory and run commands within it.
|
// Start the container in the appropriate directory and run commands within it.
|
||||||
|
// Default WORKDIR in blang/latex is /data
|
||||||
// Files in this directory will be accessible under /data within the container.
|
// Files in this directory will be accessible under /data within the container.
|
||||||
|
|
||||||
return `
|
return `
|
||||||
cd ${tempDir}/${id}
|
docker run --user="$(id -u):$(id -g)" \
|
||||||
docker run --rm -i --user="$(id -u):$(id -g)" \
|
--net=none -v $PWD/${tempDir}/${id}:/data "blang/latex:ubuntu" \
|
||||||
--net=none -v "$PWD":/data "blang/latex:ubuntu" \
|
|
||||||
/bin/bash -c "${containerCmds}"`;
|
/bin/bash -c "${containerCmds}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
home/howard/la_temp/31b21413817bbb01/texput.log
Normal file
18
home/howard/la_temp/31b21413817bbb01/texput.log
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=latex 2018.1.22) 15 AUG 2022 16:21
|
||||||
|
entering extended mode
|
||||||
|
%&-line parsing enabled.
|
||||||
|
**equation.tex
|
||||||
|
|
||||||
|
! Emergency stop.
|
||||||
|
<*> equation.tex
|
||||||
|
|
||||||
|
Here is how much of TeX's memory you used:
|
||||||
|
2 strings out of 493030
|
||||||
|
102 string characters out of 6136260
|
||||||
|
53057 words of memory out of 5000000
|
||||||
|
3641 multiletter control sequences out of 15000+600000
|
||||||
|
3640 words of font info for 14 fonts, out of 8000000 for 9000
|
||||||
|
1141 hyphenation exceptions out of 8191
|
||||||
|
0i,0n,0p,1b,6s stack positions out of 5000i,500n,10000p,200000b,80000s
|
||||||
|
|
||||||
|
No pages of output.
|
18
home/howard/la_temp/bdbacdd09db668c0/texput.log
Normal file
18
home/howard/la_temp/bdbacdd09db668c0/texput.log
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=latex 2018.1.22) 15 AUG 2022 16:22
|
||||||
|
entering extended mode
|
||||||
|
%&-line parsing enabled.
|
||||||
|
**equation.tex
|
||||||
|
|
||||||
|
! Emergency stop.
|
||||||
|
<*> equation.tex
|
||||||
|
|
||||||
|
Here is how much of TeX's memory you used:
|
||||||
|
2 strings out of 493030
|
||||||
|
102 string characters out of 6136260
|
||||||
|
53057 words of memory out of 5000000
|
||||||
|
3641 multiletter control sequences out of 15000+600000
|
||||||
|
3640 words of font info for 14 fonts, out of 8000000 for 9000
|
||||||
|
1141 hyphenation exceptions out of 8191
|
||||||
|
0i,0n,0p,1b,6s stack positions out of 5000i,500n,10000p,200000b,80000s
|
||||||
|
|
||||||
|
No pages of output.
|
1
package-lock.json
generated
1
package-lock.json
generated
@ -5,6 +5,7 @@
|
|||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
|
"name": "latex2image-web",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -51,8 +51,8 @@
|
|||||||
<option>50%</option>
|
<option>50%</option>
|
||||||
<option>75%</option>
|
<option>75%</option>
|
||||||
<option>100%</option>
|
<option>100%</option>
|
||||||
<option selected>125%</option>
|
<option>125%</option>
|
||||||
<option>150%</option>
|
<option selected>150%</option>
|
||||||
<option>200%</option>
|
<option>200%</option>
|
||||||
<option>500%</option>
|
<option>500%</option>
|
||||||
<option>1000%</option>
|
<option>1000%</option>
|
||||||
@ -87,6 +87,7 @@
|
|||||||
<img id="resultImage" />
|
<img id="resultImage" />
|
||||||
<br><br>
|
<br><br>
|
||||||
<a href="#" class="btn btn-primary" role="button" id="downloadButton" target="_blank" download>Save Image</a>
|
<a href="#" class="btn btn-primary" role="button" id="downloadButton" target="_blank" download>Save Image</a>
|
||||||
|
<a href="#" class="btn btn-outline-primary" role="button" id="clipboardButton" target="_blank" download>Copy clipboard</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="alert alert-danger initiallyHidden" id="errorAlert"></div>
|
<div class="alert alert-danger initiallyHidden" id="errorAlert"></div>
|
||||||
|
@ -3,6 +3,15 @@ var hasShownBefore = false;
|
|||||||
|
|
||||||
var ENDPOINT = '/convert';
|
var ENDPOINT = '/convert';
|
||||||
|
|
||||||
|
const copyImage = async (src) => {
|
||||||
|
const response = await fetch(src);
|
||||||
|
const blob = await response.blob();
|
||||||
|
await navigator.clipboard.write([
|
||||||
|
new ClipboardItem({"image/png": blob}),
|
||||||
|
]);
|
||||||
|
alert("Copied!")
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
function show(resultData) {
|
function show(resultData) {
|
||||||
function afterSlideUp() {
|
function afterSlideUp() {
|
||||||
@ -10,6 +19,10 @@ $(document).ready(function() {
|
|||||||
if ((resultDataJSON = JSON.parse(resultData)) && !resultDataJSON.error) {
|
if ((resultDataJSON = JSON.parse(resultData)) && !resultDataJSON.error) {
|
||||||
$('#resultImage').attr('src', resultDataJSON.imageURL);
|
$('#resultImage').attr('src', resultDataJSON.imageURL);
|
||||||
$('#downloadButton').attr('href', resultDataJSON.imageURL);
|
$('#downloadButton').attr('href', resultDataJSON.imageURL);
|
||||||
|
$('#clipboardButton').off("click").on("click", (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
copyImage(resultDataJSON.imageURL);
|
||||||
|
})
|
||||||
$('#resultCard').show();
|
$('#resultCard').show();
|
||||||
$('#errorAlert').hide();
|
$('#errorAlert').hide();
|
||||||
} else {
|
} else {
|
||||||
@ -64,6 +77,7 @@ $(document).ready(function() {
|
|||||||
$('#exampleButton').prop('disabled', false);
|
$('#exampleButton').prop('disabled', false);
|
||||||
$('#convertButtonText').html('Convert');
|
$('#convertButtonText').html('Convert');
|
||||||
$('#convertSpinner').addClass('d-none');
|
$('#convertSpinner').addClass('d-none');
|
||||||
|
|
||||||
show(data);
|
show(data);
|
||||||
},
|
},
|
||||||
error: function() {
|
error: function() {
|
||||||
@ -79,7 +93,7 @@ $(document).ready(function() {
|
|||||||
// Show and convert a sample equation
|
// Show and convert a sample equation
|
||||||
$('#exampleButton').click(function() {
|
$('#exampleButton').click(function() {
|
||||||
$('#latexInputTextArea').val(sampleEquation);
|
$('#latexInputTextArea').val(sampleEquation);
|
||||||
$('#autoAlignCheckbox').prop('checked', true);
|
// $('#autoAlignCheckbox').prop('checked', true);
|
||||||
$('#convertButton').click();
|
$('#convertButton').click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user