Skip to content

Commit

Permalink
Do not use formatDocumentTableCaptions function on document body, app…
Browse files Browse the repository at this point in the history
…ly table numbering
  • Loading branch information
vgeorge committed Oct 10, 2023
1 parent 57ca4dd commit 05f50d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
13 changes: 11 additions & 2 deletions app/assets/scripts/components/documents/pdf-preview/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,22 @@ function generateTocAndHeadingNumbering(content) {
// Starting from h2
generateHeading(2, tocElement, content, undefined);

const captions = content.querySelectorAll('.slate-image-block figcaption');
Array.from(captions).forEach((caption, i) => {
const imageCaptions = content.querySelectorAll(
'.slate-image-block figcaption'
);
Array.from(imageCaptions).forEach((caption, i) => {
const captionPrefix = document.createElement('span');
captionPrefix.innerText = `Figure ${i + 1}: `;
caption.prepend(captionPrefix);
});

const tableCaptions = content.querySelectorAll('.slate-table + figcaption');
Array.from(tableCaptions).forEach((caption, i) => {
const captionPrefix = document.createElement('span');
captionPrefix.innerText = `Table ${i + 1}: `;
caption.prepend(captionPrefix);
});

const equationNumbers = content.querySelectorAll(
'.slate-equation-element .equation-number'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import { isJournalPublicationIntended } from '../status';
import serializeSlateToString from '../../slate/serialize-to-string';
import { useContextualAbility } from '../../../a11n';
import { isDefined, isTruthyString } from '../../../utils/common';
import { formatDocumentTableCaptions } from '../../../utils/format-table-captions';

const PDFPreview = styled.iframe`
width: 100%;
Expand Down Expand Up @@ -1456,7 +1455,7 @@ export default function DocumentBody(props) {
);

return renderElements(getAtbdContentSections(atbd.document_type === 'PDF'), {
document: formatDocumentTableCaptions(document),
document,
referencesUseIndex,
referenceList,
atbd,
Expand Down

0 comments on commit 05f50d6

Please sign in to comment.