diff --git a/README.md b/README.md index 58812c5..7370f03 100644 --- a/README.md +++ b/README.md @@ -31,15 +31,19 @@ mpx set-api-key ... # C:\Users\USERNAME\.mpx\config on Windows ``` -To digitize PDF's to editable Mathpix Markdown, docx, html or tex.zip: +To digitize PDF's to editable Mathpix Markdown, docx, xlsx, html or tex.zip: ``` mpx convert input-file.pdf output-file.mmd mpx convert input-file.pdf output-file.docx +mpx convert input-file.pdf output-file.xlsx mpx convert input-file.pdf output-file.tex mpx convert input-file.pdf output-file.html ``` +`xlsx` extracts tabular content (one worksheet per detected table) and is +currently supported for PDF sources only. + To digitize images to editable Mathpix Markdown, docx, html or tex.zip: ``` diff --git a/lib/convert.js b/lib/convert.js index ed0c324..76d63f9 100644 --- a/lib/convert.js +++ b/lib/convert.js @@ -432,6 +432,10 @@ async function PDFToDOCX(source, destination) { await ConvertPDF("docx", source, destination); } +async function PDFToXLSX(source, destination) { + await ConvertPDF("xlsx", source, destination); +} + async function PDFToTEX(source, destination) { await ConvertPDF("tex", source, `${destination}.zip`); } @@ -636,6 +640,7 @@ module.exports = { MarkdownToMarkdown, PDFToMMD, PDFToDOCX, + PDFToXLSX, PDFToTEX, PDFToHTML, ImageToMMD, diff --git a/lib/mpx.js b/lib/mpx.js index 2c7808f..66c55e1 100755 --- a/lib/mpx.js +++ b/lib/mpx.js @@ -103,7 +103,7 @@ program program .command("convert ") - .description("convert files between markdown, mathpix markdown, docx, latex and pdf formats") + .description("convert files between markdown, mathpix markdown, docx, xlsx, latex and pdf formats") .addOption( new commander.Option("-p, --pdf-method ", "choose to make pdf from latex or html") .choices(["latex", "html"]) @@ -133,7 +133,7 @@ program return process.exit(1); } - const validDestinationExtensions = [".mmd", ".md", ".pdf", ".tex", ".html", ".docx"]; + const validDestinationExtensions = [".mmd", ".md", ".pdf", ".tex", ".html", ".docx", ".xlsx"]; if (!validDestinationExtensions.includes(destinationExt)) { console.log( `Invalid destination extension, must be one of: ${JSON.stringify( @@ -163,6 +163,9 @@ program case sourceExt === ".pdf" && destinationExt === ".docx": await convert.PDFToDOCX(source, destination); break; + case sourceExt === ".pdf" && destinationExt === ".xlsx": + await convert.PDFToXLSX(source, destination); + break; case sourceExt === ".pdf" && destinationExt === ".tex": await convert.PDFToTEX(source, destination); break;