Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

```
Expand Down
5 changes: 5 additions & 0 deletions lib/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
Expand Down Expand Up @@ -636,6 +640,7 @@ module.exports = {
MarkdownToMarkdown,
PDFToMMD,
PDFToDOCX,
PDFToXLSX,
PDFToTEX,
PDFToHTML,
ImageToMMD,
Expand Down
7 changes: 5 additions & 2 deletions lib/mpx.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ program

program
.command("convert <source.ext> <destination.ext>")
.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 <type>", "choose to make pdf from latex or html")
.choices(["latex", "html"])
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;
Expand Down