diff --git a/cypress/integration/documentTitle.spec.ts b/cypress/integration/documentTitle.spec.ts index a23f4104d..424bf1c1e 100644 --- a/cypress/integration/documentTitle.spec.ts +++ b/cypress/integration/documentTitle.spec.ts @@ -95,11 +95,21 @@ describe('Document Title', () => { }) it('markdown syntax removed third', () => { - cy.get('a') - .get('@codeinput') + cy.get('@codeinput') .fill(`# ${title} _asd_`) cy.title() .should('eq', `${title} asd - HedgeDoc @ ${branding.name}`) }) + + it('katex code looks right', () => { + cy.get('@codeinput') + .fill(`# $\\alpha$-foo`) + cy.get('.markdown-body > h1') + .should('contain', 'α') + cy.get('@codeinput') + .type('\n\ntest\n') + cy.title() + .should('eq', `α-foo - HedgeDoc @ ${branding.name}`) + }) }) }) diff --git a/src/components/markdown-renderer/hooks/use-extract-first-headline.ts b/src/components/markdown-renderer/hooks/use-extract-first-headline.ts index 828e384fd..11e29128b 100644 --- a/src/components/markdown-renderer/hooks/use-extract-first-headline.ts +++ b/src/components/markdown-renderer/hooks/use-extract-first-headline.ts @@ -9,6 +9,11 @@ import React, { useCallback, useEffect } from 'react' export const useExtractFirstHeadline = (documentElement: React.RefObject, content: string, onFirstHeadingChange?: (firstHeading: string | undefined) => void): void => { const extractInnerText = useCallback((node: ChildNode): string => { let innerText = '' + + if ((node as HTMLElement).classList?.contains("katex-mathml")) { + return '' + } + if (node.childNodes && node.childNodes.length > 0) { node.childNodes.forEach((child) => { innerText += extractInnerText(child) }) } else if (node.nodeName === 'IMG') {