diff --git a/src/javascript/components/DebugView.jsx b/src/javascript/components/DebugView.jsx
index 5878972..b0df149 100644
--- a/src/javascript/components/DebugView.jsx
+++ b/src/javascript/components/DebugView.jsx
@@ -92,7 +92,7 @@ export default class DebugView extends React.Component {
const showModificationCheckbox = lastTransformation.showModificationCheckbox();
const statisticsAsList = Object.keys(parseResult.globals).map((key, i) => {
return
- { key + ': ' + parseResult.globals[key] }
+ { key + ': ' + JSON.stringify(parseResult.globals[key]) }
});
const messagesAsList = parseResult.messages.map((message, i) => {
diff --git a/src/javascript/models/AppState.jsx b/src/javascript/models/AppState.jsx
index 759a82f..d9462dd 100644
--- a/src/javascript/models/AppState.jsx
+++ b/src/javascript/models/AppState.jsx
@@ -25,26 +25,8 @@ export default class AppState {
this.mainView = View.UPLOAD;
this.fileBuffer;
this.metadata;
- this.fontMap;
this.pages = [];
- this.transformations = [
- new CalculateGlobalStats(),
- new CompactLines(),
- new RemoveRepetitiveElements(),
- new VerticalToHorizontal(),
- new PostprocessLines(),
- new DetectTOC(),
- new DetectListItems(),
- new DetectHeaders(),
-
- new GatherBlocks(),
- new DetectCodeQuoteBlocks(),
- new DetectListLevels(),
-
- // new DetectFormats(),
- // new HeadlineToUppercase(),
- new ToTextBlocks(),
- new ToMarkdown()];
+ this.transformations ;
//bind functions
this.render = this.render.bind(this);
@@ -66,11 +48,31 @@ export default class AppState {
storePdfPages(metadata, fontMap, pages) {
this.metadata = metadata;
- this.fontMap = fontMap;
this.pages = pages;
this.fileBuffer = null;
this.mainView = View.RESULT;
+
+ this.transformations = [
+ new CalculateGlobalStats(fontMap),
+ new CompactLines(),
+ new RemoveRepetitiveElements(),
+ new VerticalToHorizontal(),
+ new PostprocessLines(),
+ new DetectTOC(),
+ new DetectListItems(),
+ new DetectHeaders(),
+
+ new GatherBlocks(),
+ new DetectCodeQuoteBlocks(),
+ new DetectListLevels(),
+
+ // new DetectFormats(),
+ // new HeadlineToUppercase(),
+ new ToTextBlocks(),
+ new ToMarkdown()];
+
this.render();
+
}
switchMainView(view) {
diff --git a/src/javascript/models/ElementType.jsx b/src/javascript/models/ElementType.jsx
index c855d15..3817708 100644
--- a/src/javascript/models/ElementType.jsx
+++ b/src/javascript/models/ElementType.jsx
@@ -2,6 +2,7 @@ import { Enum } from 'enumify';
import TextItem from './TextItem.jsx';
import TextItemBlock from './TextItemBlock.jsx';
+// An Markdown element
export default class ElementType extends Enum {
}
diff --git a/src/javascript/models/StringFormat.jsx b/src/javascript/models/StringFormat.jsx
new file mode 100644
index 0000000..be112bb
--- /dev/null
+++ b/src/javascript/models/StringFormat.jsx
@@ -0,0 +1,6 @@
+import { Enum } from 'enumify';
+
+export default class StringFormat extends Enum {
+}
+
+StringFormat.initEnum(['STANDARD', 'BOLD', 'OBLIQUE', 'BOLD_OBLIQUE'])
\ No newline at end of file
diff --git a/src/javascript/models/transformations/textitem/CalculateGlobalStats.jsx b/src/javascript/models/transformations/textitem/CalculateGlobalStats.jsx
index c9dc3d6..4abe622 100644
--- a/src/javascript/models/transformations/textitem/CalculateGlobalStats.jsx
+++ b/src/javascript/models/transformations/textitem/CalculateGlobalStats.jsx
@@ -1,14 +1,15 @@
import ToTextItemTransformation from '../ToTextItemTransformation.jsx';
import ParseResult from '../../ParseResult.jsx';
+import StringFormat from '../../StringFormat.jsx';
export default class CalculateGlobalStats extends ToTextItemTransformation {
- constructor() {
+ constructor(fontMap) {
super("Calculate Statistics");
+ this.fontMap = fontMap;
}
transform(parseResult:ParseResult) {
-
// Parse heights
const heightToOccurrence = {};
const fontToOccurrence = {};
@@ -48,6 +49,31 @@ export default class CalculateGlobalStats extends ToTextItemTransformation {
const mostUsedDistance = parseInt(getMostUsedKey(distanceToOccurrence));
+ const fontIdToName = [];
+ const fontToFormats = new Map();
+ this.fontMap.forEach(function(value, key) {
+ fontIdToName.push(key + " = " + value.name)
+ const fontName = value.name.toLowerCase();
+ var format;
+ if (key == mostUsedFont) {
+ format = StringFormat.STANDARD;
+ } else if (fontName.includes('bold') && fontName.includes('bold')) {
+ format = StringFormat.BOLD_OBLIQUE;
+ } else if (fontName.includes('bold')) {
+ format = StringFormat.BOLD;
+ } else if (fontName.includes('oblique')) {
+ format = StringFormat.OBLIQUE;
+ } else if (fontName === maxHeightFont) {
+ format = StringFormat.BOLD;
+ } else {
+ format = StringFormat.STANDARD;
+ }
+ fontToFormats.set(key, format);
+ });
+ fontIdToName.sort();
+
+
+
//Make a copy of the originals so all following transformation don't modify them
const newPages = parseResult.pages.map(page => {
return {
@@ -68,11 +94,13 @@ export default class CalculateGlobalStats extends ToTextItemTransformation {
mostUsedDistance: mostUsedDistance,
maxHeight: maxHeight,
maxHeightFont: maxHeightFont,
+ fontToFormats: fontToFormats
},
messages: [
'Items per height: ' + JSON.stringify(heightToOccurrence),
'Items per font: ' + JSON.stringify(fontToOccurrence),
- 'Items per distance: ' + JSON.stringify(distanceToOccurrence)
+ 'Items per distance: ' + JSON.stringify(distanceToOccurrence),
+ 'Fonts:' + JSON.stringify(fontIdToName)
]
});
}