Skip to content
Open
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
11 changes: 11 additions & 0 deletions src/archivist/extract/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export default async function extract(sourceDocument) {
if (sourceDocument.mimeType == mime.getType('pdf')) {
return await extractFromPDF(sourceDocument);
}
if (sourceDocument.mimeType == mime.getType('txt') || sourceDocument.mimeType == mime.getType('md')) {
return await extractFromMd(sourceDocument);
}

return await extractFromHTML(sourceDocument);
} catch (error) {
Expand Down Expand Up @@ -126,6 +129,14 @@ export async function extractFromPDF({ location, content: pdfBuffer }) {
return markdownContent;
}

export async function extractFromMd({ location, content: markdownContent }) {
if (!markdownContent) {
throw new Error(`The markdown file at '${location}' contains no text`);
}

return markdownContent;
}

function selectRange(webPageDOM, rangeSelector) {
const { startBefore, startAfter, endBefore, endAfter } = rangeSelector;

Expand Down