mirror of
https://github.com/jzillmann/pdf-to-markdown.git
synced 2024-11-22 07:43:46 +01:00
Make everything ready for deploy
This commit is contained in:
parent
1a97cef440
commit
4ce59ac062
33
.eslintrc
Normal file
33
.eslintrc
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
// Extend existing configuration
|
||||||
|
// from ESlint and eslint-plugin-react defaults.
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended", "plugin:react/recommended"
|
||||||
|
],
|
||||||
|
"parser": "babel-eslint",
|
||||||
|
// Enable ES6 support. If you want to use custom Babel
|
||||||
|
// features, you will need to enable a custom parser
|
||||||
|
// as described in a section below.
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 6,
|
||||||
|
"sourceType": "module",
|
||||||
|
"ecmaFeatures": {
|
||||||
|
"jsx": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"node": true,
|
||||||
|
"es6": true
|
||||||
|
},
|
||||||
|
// Enable custom plugin known as eslint-plugin-react
|
||||||
|
"plugins": [
|
||||||
|
"react"
|
||||||
|
],
|
||||||
|
"rules": {
|
||||||
|
// Disable `no-console` rule
|
||||||
|
"no-console": 1,
|
||||||
|
// Give a warning if identifiers contain underscores
|
||||||
|
"no-underscore-dangle": 1
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,9 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"watch": "webpack -d --watch",
|
"watch": "webpack -d --watch",
|
||||||
"build": "webpack",
|
"build": "webpack",
|
||||||
"lint": "eslint . --ext .js --ext .jsx --cache"
|
"lint": "eslint src --ext .js --ext .jsx --cache",
|
||||||
|
"release": "npm run lint && rm -rf build/* && NODE_ENV=production webpack -p",
|
||||||
|
"deploy": "npm run release && cp -r build/* docs/"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"PDF",
|
"PDF",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import pdfjs from 'pdfjs-dist';
|
import pdfjs from 'pdfjs-dist'; // eslint-disable-line no-unused-vars
|
||||||
import { Line } from 'rc-progress';
|
import { Line } from 'rc-progress';
|
||||||
|
|
||||||
import PdfPage from '../models/PdfPage.jsx';
|
import PdfPage from '../models/PdfPage.jsx';
|
||||||
@ -29,7 +29,7 @@ export default class LoadingView extends React.Component {
|
|||||||
|
|
||||||
anouncePageParsed(index, textItems) {
|
anouncePageParsed(index, textItems) {
|
||||||
//TODO might make problems.. concat unordered and order at the end ?
|
//TODO might make problems.. concat unordered and order at the end ?
|
||||||
this.state.pdfPages[index].textItems = textItems;
|
this.state.pdfPages[index].textItems = textItems; // eslint-disable-line react/no-direct-mutation-state
|
||||||
this.setState({
|
this.setState({
|
||||||
parsedPages: this.state.parsedPages + 1
|
parsedPages: this.state.parsedPages + 1
|
||||||
});
|
});
|
||||||
@ -39,8 +39,8 @@ export default class LoadingView extends React.Component {
|
|||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
const anounceInitialParseFunction = this.anounceInitialParse.bind(this);
|
const anounceInitialParseFunction = this.anounceInitialParse.bind(this);
|
||||||
const anouncePageParsedFunction = this.anouncePageParsed.bind(this);
|
const anouncePageParsedFunction = this.anouncePageParsed.bind(this);
|
||||||
PDFJS.getDocument(this.props.fileBuffer).then(function(pdfDocument) {
|
PDFJS.getDocument(this.props.fileBuffer).then(function(pdfDocument) { // eslint-disable-line no-undef
|
||||||
console.log('Number of pages: ' + pdfDocument.numPages);
|
// console.log('Number of pages: ' + pdfDocument.numPages);
|
||||||
// console.debug(pdfDocument);
|
// console.debug(pdfDocument);
|
||||||
const numPages = pdfDocument.numPages;
|
const numPages = pdfDocument.numPages;
|
||||||
// const numPages = 4; // hack
|
// const numPages = 4; // hack
|
||||||
@ -51,8 +51,8 @@ export default class LoadingView extends React.Component {
|
|||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
anounceInitialParseFunction(pdfPages);
|
anounceInitialParseFunction(pdfPages);
|
||||||
for (var i = 1; i <= numPages; i++) {
|
for (var j = 1; j <= numPages; j++) {
|
||||||
pdfDocument.getPage(i).then(function(page) {
|
pdfDocument.getPage(j).then(function(page) {
|
||||||
page.getTextContent().then(function(textContent) {
|
page.getTextContent().then(function(textContent) {
|
||||||
// console.debug(textContent);
|
// console.debug(textContent);
|
||||||
const textItems = textContent.items.map(function(item) {
|
const textItems = textContent.items.map(function(item) {
|
||||||
|
@ -17,7 +17,6 @@ export default class PdfUploadView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onDrop(files) {
|
onDrop(files) {
|
||||||
console.debug(files.length);
|
|
||||||
if (files.length > 1) {
|
if (files.length > 1) {
|
||||||
alert(`Maximum one file allowed to upload, but not ${files.length}!`)
|
alert(`Maximum one file allowed to upload, but not ${files.length}!`)
|
||||||
return
|
return
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import Badge from 'react-bootstrap/lib/Badge'
|
|
||||||
import ButtonToolbar from 'react-bootstrap/lib/ButtonToolbar'
|
import ButtonToolbar from 'react-bootstrap/lib/ButtonToolbar'
|
||||||
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup'
|
import ButtonGroup from 'react-bootstrap/lib/ButtonGroup'
|
||||||
import Button from 'react-bootstrap/lib/Button'
|
import Button from 'react-bootstrap/lib/Button'
|
||||||
@ -54,8 +53,6 @@ export default class PdfView extends React.Component {
|
|||||||
const {currentTransformation, pageNr} = this.state;
|
const {currentTransformation, pageNr} = this.state;
|
||||||
const {pdfPages, transformations} = this.props;
|
const {pdfPages, transformations} = this.props;
|
||||||
|
|
||||||
const header = "Parsed " + pdfPages.length + " pages!"
|
|
||||||
|
|
||||||
const currentTransformationName = transformations[currentTransformation].name;
|
const currentTransformationName = transformations[currentTransformation].name;
|
||||||
|
|
||||||
const transformedPdfPages = pdfPages.filter((elem, i) => pageNr == -1 || i == pageNr).map(pdfPage => {
|
const transformedPdfPages = pdfPages.filter((elem, i) => pageNr == -1 || i == pageNr).map(pdfPage => {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import Transformation from './Transformation.jsx';
|
import Transformation from './Transformation.jsx';
|
||||||
import TextItem from '../TextItem.jsx';
|
import TextItem from '../TextItem.jsx';
|
||||||
|
import PdfPage from '../PdfPage.jsx';
|
||||||
|
|
||||||
export default class CombineSameYTransformation extends Transformation {
|
export default class CombineSameYTransformation extends Transformation {
|
||||||
|
|
||||||
@ -18,9 +19,9 @@ export default class CombineSameYTransformation extends Transformation {
|
|||||||
if (textItem.y == lastTextItem.y) {
|
if (textItem.y == lastTextItem.y) {
|
||||||
//combine
|
//combine
|
||||||
|
|
||||||
console.debug("last=" + lastTextItem.text + ", x=" + lastTextItem.x + ", width=" + lastTextItem.width);
|
// console.debug("last=" + lastTextItem.text + ", x=" + lastTextItem.x + ", width=" + lastTextItem.width);
|
||||||
console.debug("new=" + textItem.text + ", x=" + textItem.x + ", width=" + textItem.width);
|
// console.debug("new=" + textItem.text + ", x=" + textItem.x + ", width=" + textItem.width);
|
||||||
console.debug("diff=" + (textItem.x - lastTextItem.x - lastTextItem.width));
|
// console.debug("diff=" + (textItem.x - lastTextItem.x - lastTextItem.width));
|
||||||
|
|
||||||
var combinedText = lastTextItem.text;
|
var combinedText = lastTextItem.text;
|
||||||
//TODO make 5 dependent on text size or biggest gap?
|
//TODO make 5 dependent on text size or biggest gap?
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Transformation from './Transformation.jsx';
|
import Transformation from './Transformation.jsx';
|
||||||
|
import PdfPage from '../PdfPage.jsx';
|
||||||
|
|
||||||
export default class NoOpTransformation extends Transformation {
|
export default class NoOpTransformation extends Transformation {
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Transformation from './Transformation.jsx';
|
import Transformation from './Transformation.jsx';
|
||||||
|
import PdfPage from '../PdfPage.jsx';
|
||||||
|
|
||||||
export default class RoundCoordinatesTransformation extends Transformation {
|
export default class RoundCoordinatesTransformation extends Transformation {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import AppState from '../PdfPage.jsx';
|
import PdfPage from '../PdfPage.jsx';
|
||||||
|
|
||||||
// A transformation from an PdfPage to an PdfPage
|
// A transformation from an PdfPage to an PdfPage
|
||||||
export default class Transformation {
|
export default class Transformation {
|
||||||
@ -13,7 +13,7 @@ export default class Transformation {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
transform(pdfPage:PdfPage) {
|
transform(pdfPage:PdfPage) { // eslint-disable-line no-unused-vars
|
||||||
throw new TypeError("Do not call abstract method foo from child.");
|
throw new TypeError("Do not call abstract method foo from child.");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,7 +30,7 @@ export default {
|
|||||||
var lineY;
|
var lineY;
|
||||||
// console.debug("Page " + rawPage.index + "-------");
|
// console.debug("Page " + rawPage.index + "-------");
|
||||||
rawPage.textItems.forEach(textItem => {
|
rawPage.textItems.forEach(textItem => {
|
||||||
console.debug(textItem);
|
// console.debug(textItem);
|
||||||
const yRounded = Math.round(textItem.y);
|
const yRounded = Math.round(textItem.y);
|
||||||
if (!line) {
|
if (!line) {
|
||||||
// console.debug("First line: " + textItem.text);
|
// console.debug("First line: " + textItem.text);
|
||||||
@ -57,7 +57,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
upload: function(pages) {
|
upload: function(pages) {
|
||||||
console.debug("Store: upload");
|
// console.debug("Store: upload");
|
||||||
this.state.uploaded = true;
|
this.state.uploaded = true;
|
||||||
this.state.pages = pages;
|
this.state.pages = pages;
|
||||||
},
|
},
|
||||||
|
@ -76,6 +76,12 @@ module.exports = {
|
|||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: SOURCE_DIR + '/index.html'
|
template: SOURCE_DIR + '/index.html'
|
||||||
}),
|
}),
|
||||||
|
new webpack.DefinePlugin({
|
||||||
|
'process.env': {
|
||||||
|
'version': JSON.stringify(process.env.npm_package_version),
|
||||||
|
NODE_ENV: JSON.stringify(process.env.NODE_ENV || 'development')
|
||||||
|
}
|
||||||
|
}),
|
||||||
new CopyWebpackPlugin([
|
new CopyWebpackPlugin([
|
||||||
{
|
{
|
||||||
from: NODEMODULES_DIR + '/pdfjs-dist/build/pdf.worker.js',
|
from: NODEMODULES_DIR + '/pdfjs-dist/build/pdf.worker.js',
|
||||||
|
Loading…
Reference in New Issue
Block a user