diff --git a/.changeset/spicy-coins-own.md b/.changeset/spicy-coins-own.md new file mode 100644 index 0000000000..a8ca8fd566 --- /dev/null +++ b/.changeset/spicy-coins-own.md @@ -0,0 +1,6 @@ +--- +"gitbook-docs": patch +"nextjs-website": patch +--- + +Fix br parsing diff --git a/apps/nextjs-website/src/components/organisms/GitBookContent/GitBookContent.tsx b/apps/nextjs-website/src/components/organisms/GitBookContent/GitBookContent.tsx index 08ef7b7ebb..a147e1bf59 100644 --- a/apps/nextjs-website/src/components/organisms/GitBookContent/GitBookContent.tsx +++ b/apps/nextjs-website/src/components/organisms/GitBookContent/GitBookContent.tsx @@ -64,6 +64,7 @@ const components: RenderingComponents = { Card: Card, CardItem: CardItem, PageLink: PageLink, + Br: () =>
, }; const GitBookContent = ({ content, config }: GitBookContentProps) => diff --git a/apps/nextjs-website/src/components/organisms/GitBookContent/components/Table.tsx b/apps/nextjs-website/src/components/organisms/GitBookContent/components/Table.tsx index c17b10a444..342277fc68 100644 --- a/apps/nextjs-website/src/components/organisms/GitBookContent/components/Table.tsx +++ b/apps/nextjs-website/src/components/organisms/GitBookContent/components/Table.tsx @@ -81,10 +81,7 @@ export const TableD = (props: TableCellProps) => { > {Array.isArray(props.children) ? props.children.map((children, index) => ( - - {children} -
-
+ {children} )) : props.children} diff --git a/packages/gitbook-docs/src/__tests__/parseContent.test.ts b/packages/gitbook-docs/src/__tests__/parseContent.test.ts index 44f4ad60c0..11ec7e99cf 100644 --- a/packages/gitbook-docs/src/__tests__/parseContent.test.ts +++ b/packages/gitbook-docs/src/__tests__/parseContent.test.ts @@ -145,6 +145,16 @@ describe('parseContent', () => { ]); }); + it('should parse br correctly', () => { + expect(parseContent('Hello
there', config)).toStrictEqual([ + new Markdoc.Tag('Paragraph', {}, [ + 'Hello', + new Markdoc.Tag('Br', {}), + 'there', + ]), + ]); + }); + it('should convert href as expected given a link with an anchor', () => { expect( parseContent( diff --git a/packages/gitbook-docs/src/markdoc/schema/br.ts b/packages/gitbook-docs/src/markdoc/schema/br.ts new file mode 100644 index 0000000000..2291ef518a --- /dev/null +++ b/packages/gitbook-docs/src/markdoc/schema/br.ts @@ -0,0 +1,5 @@ +import { Schema } from '@markdoc/markdoc'; + +export const br: Schema = { + render: 'Br', +}; diff --git a/packages/gitbook-docs/src/parseContent.ts b/packages/gitbook-docs/src/parseContent.ts index 66b030269b..10ead481bc 100644 --- a/packages/gitbook-docs/src/parseContent.ts +++ b/packages/gitbook-docs/src/parseContent.ts @@ -15,6 +15,7 @@ import { blockquote } from './markdoc/schema/blockquote'; import { tabs } from './markdoc/schema/tabs'; import { details } from './markdoc/schema/details'; import { embed } from './markdoc/schema/embed'; +import { br } from './markdoc/schema/br'; import { table } from './markdoc/schema/table'; import { pageLink } from './markdoc/schema/pageLink'; import { processHtmlTokens } from './markdoc/tokenProcessor'; @@ -70,6 +71,7 @@ const schema: ConfigType = { htmlli: item, htmltable: table, htmla: link, + htmlbr: br, htmlstrong: styled.strong, }, nodes: { diff --git a/packages/gitbook-docs/src/renderContent.ts b/packages/gitbook-docs/src/renderContent.ts index 8fecc2d8a3..490d1a69e1 100644 --- a/packages/gitbook-docs/src/renderContent.ts +++ b/packages/gitbook-docs/src/renderContent.ts @@ -61,6 +61,7 @@ export type RenderingComponents = { readonly ExpandableDetails: (props: ExpandableDetailsProps) => A; readonly Swagger: (props: SwaggerProps) => A; readonly PageLink: (props: PageLinkProps) => A; + readonly Br: () => A; }; export const renderContent = (