diff --git a/src/features/sicp/parser/ParseJson.tsx b/src/features/sicp/parser/ParseJson.tsx index c9b587b27e..70931a43d8 100644 --- a/src/features/sicp/parser/ParseJson.tsx +++ b/src/features/sicp/parser/ParseJson.tsx @@ -175,6 +175,10 @@ const handleContainer = (obj: JsonType, refs: React.MutableRefObject<{}>) => { ); }; +const handleReference = (obj: JsonType, refs: React.MutableRefObject<{}>) => { + return
{parseArr(obj['child']!, refs)}
; +}; + const handleText = (text: string) => { return

{text}

; }; @@ -221,19 +225,13 @@ export const processingFunctions = { LaTeX: (_obj: JsonType, _refs: React.MutableRefObject<{}>) => handleText('LaTeX'), - MATTER: handleContainer, - META: (obj: JsonType, _refs: React.MutableRefObject<{}>) => {obj['body']}, - METAPHRASE: (obj: JsonType, _refs: React.MutableRefObject<{}>) => handleText(obj['body']!), - OL: (obj: JsonType, refs: React.MutableRefObject<{}>) =>
    {parseArr(obj['child']!, refs)}
, REF: handleRef, - REFERENCE: handleContainer, - - REFERENCES: handleContainer, + REFERENCE: handleReference, SECTION: handleContainer, @@ -245,8 +243,6 @@ export const processingFunctions = { ), - SUBSECTION: handleContainer, - SUBSUBHEADING: (obj: JsonType, refs: React.MutableRefObject<{}>) => (

(refs.current[obj['id']!] = ref)}>
@@ -254,8 +250,6 @@ export const processingFunctions = {

), - SUBSUBSECTION: handleContainer, - TABLE: (obj: JsonType, refs: React.MutableRefObject<{}>) => ( {obj['child']!.map((x, index) => handleTR(x, refs, index))} diff --git a/src/features/sicp/parser/__tests__/ParseJson.tsx b/src/features/sicp/parser/__tests__/ParseJson.tsx index f494d79e85..c9864ae112 100644 --- a/src/features/sicp/parser/__tests__/ParseJson.tsx +++ b/src/features/sicp/parser/__tests__/ParseJson.tsx @@ -7,16 +7,16 @@ import { JsonType, parseArr, ParseJsonError, parseObj, processingFunctions } fro // Tags to process const headingTags = ['SUBHEADING', 'SUBSUBHEADING']; -const sectionTags = ['SECTION', 'SUBSECTION', 'SUBSUBSECTION', 'MATTER', 'CHAPTER', 'REFERENCES']; const listTags = ['OL', 'UL']; const symbolTags = ['BR', 'LaTeX', 'TeX']; -const stylingTags = ['B', 'EM', 'JAVASCRIPTINLINE', 'TT', 'METAPHRASE', 'META']; +const stylingTags = ['B', 'EM', 'JAVASCRIPTINLINE', 'TT', 'META']; const latexTags = ['LATEX', 'LATEXINLINE']; const linkTags = ['LINK', 'REF', 'FOOTNOTE_REF']; const epigraphTag = 'EPIGRAPH'; const tableTag = 'TABLE'; const exerciseTag = 'EXERCISE'; +const sectionTag = 'SECTION'; const snippetTag = 'SNIPPET'; const figureTag = 'FIGURE'; const displayFootnoteTag = 'DISPLAYFOOTNOTE'; @@ -79,12 +79,12 @@ describe('Parse heading', () => { }); describe('Parse section', () => { - const tags = sectionTags; + const tag = sectionTag; const text = { tag: 'TEXT', child: [mockData['text'], mockData['text']] }; const content = [text, text]; const obj = { body: 'Title', child: content }; - tags.forEach(x => testTagSuccessful(obj, x)); + testTagSuccessful(obj, tag); }); describe('Parse list', () => { diff --git a/src/features/sicp/parser/__tests__/__snapshots__/ParseJson.tsx.snap b/src/features/sicp/parser/__tests__/__snapshots__/ParseJson.tsx.snap index e5e2c84abc..379346bc6d 100644 --- a/src/features/sicp/parser/__tests__/__snapshots__/ParseJson.tsx.snap +++ b/src/features/sicp/parser/__tests__/__snapshots__/ParseJson.tsx.snap @@ -352,133 +352,11 @@ exports[`Parse object successful 1`] = ` exports[`Parse reference REFERENCE successful 1`] = ` "
-
- -

- Mock Text -

-
-
-
" -`; - -exports[`Parse section CHAPTER successful 1`] = ` -"
- - Title - -
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
-
-
" -`; - -exports[`Parse section MATTER successful 1`] = ` -"
- - Title - -
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
-
-
" -`; - -exports[`Parse section REFERENCES successful 1`] = ` -"
- - Title - -
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
-
+ +

+ Mock Text +

+
" `; @@ -522,86 +400,6 @@ exports[`Parse section SECTION successful 1`] = ` " `; -exports[`Parse section SUBSECTION successful 1`] = ` -"
- - Title - -
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
-
-
" -`; - -exports[`Parse section SUBSUBSECTION successful 1`] = ` -"
- - Title - -
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
- -
- -

- Mock Text -

-
- -

- Mock Text -

-
-
-
-
-
-
" -`; - exports[`Parse snippet SNIPPET no eval successful 1`] = ` " @@ -660,8 +458,6 @@ exports[`Parse styling JAVASCRIPTINLINE successful 1`] = `""`; -exports[`Parse styling METAPHRASE successful 1`] = `"

"`; - exports[`Parse styling TT successful 1`] = ` "