import React, { Fragment } from "react";
import { EuiText, EuiSpacer, EuiInMemoryTable } from "@elastic/eui";
import _ from "lodash";

export const PdfParser = ({ streams }) => {
  if (!streams) {
    return <Fragment />;
  }

  const ppStats = streams.stats.map(s => {
    return <li key={s}>{s}</li>;
  });

  const ppTags = Object.keys(streams.tags).map(function(key) {
    const listItems = streams.tags[key].map(s => {
      return <li key={s}>{s}</li>;
    });
    return (
      <Fragment key={key}>
        <h6>{_.startCase(key)}</h6>
        <ul>{listItems}</ul>
      </Fragment>
    );
  });

  const renderEmbeddedFilesTable = e => {
    if (!e || !e.length) {
      return <Fragment />;
    }
    const columns = [
      {
        field: "object",
        name: "Object",
        dataType: "string",
        align: "left",
        width: "30%"
      },
      {
        field: "sha256",
        name: "SHA-256",
        dataType: "number",
        align: "left",
        width: "70%"
      }
    ];
    return (
      <Fragment>
        <EuiText>
          <h5>Embedded Files</h5>
        </EuiText>
        <EuiInMemoryTable items={e} columns={columns} />
      </Fragment>
    );
  };

  return (
    <Fragment>
      <EuiText>
        <h4>pdf-parser</h4>
        <h5>Stats</h5>
        <ul>{ppStats}</ul>
        <h5>Tags</h5>
        {ppTags}
      </EuiText>
      <EuiSpacer />
      {renderEmbeddedFilesTable(streams.embedded)}
      <EuiSpacer />
    </Fragment>
  );
};

@@ -51,16 +51,25 @@
 EuiText,
+ EuiCode,
  EuiSpac
@@ -1202,16 +1202,535 @@
 ;%0A  %7D;%0A%0A
+  const renderCarvedContent = cc =%3E %7B%0A    if (!cc %7C%7C !cc.length) %7B%0A      return %3CFragment /%3E;%0A    %7D%0A%0A    const ccItems = cc.map(c =%3E %7B%0A      return (%0A        %3CFragment key=%7Bc.key%7D%3E%0A          %3Ch6%3E%7Bc.key%7D%3C/h6%3E%0A          %3CEuiCode language=%22js%22 fontSize=%22l%22 paddingSize=%22s%22 color=%22dark%22%3E%0A            %7Bc.content%7D%0A          %3C/EuiCode%3E%0A        %3C/Fragment%3E%0A      );%0A    %7D);%0A%0A    return (%0A      %3CFragment%3E%0A        %3CEuiText%3E%0A          %3Ch5%3ECarved Content%3C/h5%3E%0A          %7BccItems%7D%0A        %3C/EuiText%3E%0A      %3C/Fragment%3E%0A    );%0A  %7D;%0A%0A
   return
@@ -1968,16 +1968,69 @@
 edded)%7D%0A
+      %7BrenderCarvedContent(streams.carved.contents)%7D%0A
       %3CE

fix pdf-parser