pdf-to-markdown/oldSrc/javascript/models/transformations/ToMarkdown.jsx

29 lines
826 B
React
Raw Normal View History

import React from 'react';
import MarkdownPageView from '../../components/debug/MarkdownPageView.jsx';
2017-01-22 19:04:23 +01:00
import Transformation from './Transformation.jsx';
import ParseResult from '../ParseResult.jsx';
2017-01-22 19:04:23 +01:00
2017-02-06 19:13:43 +01:00
export default class ToMarkdown extends Transformation {
2017-01-22 19:04:23 +01:00
constructor() {
super("To Markdown", "String");
2017-01-22 19:04:23 +01:00
}
createPageView(page, modificationsOnly) { // eslint-disable-line no-unused-vars
return <MarkdownPageView key={ page.index } page={ page } />;
2017-01-22 19:04:23 +01:00
}
transform(parseResult:ParseResult) {
2017-03-07 21:59:15 +01:00
parseResult.pages.forEach(page => {
var text = '';
page.items.forEach(block => {
2017-02-19 14:23:35 +01:00
text += block.text + '\n';
2017-02-12 19:37:21 +01:00
});
2017-03-07 21:59:15 +01:00
page.items = [text];
2017-02-12 19:37:21 +01:00
});
return new ParseResult({
...parseResult,
});
2017-01-22 19:04:23 +01:00
}
}