mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-13 22:54:42 -04:00
![renovate[bot]](/assets/img/avatar_default.png)
* Update dependency eslint-plugin-import to v2.25.2 Signed-off-by: Renovate Bot <bot@renovateapp.com> Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Make type imports more explicit Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Enforce use of type imports Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
32 lines
912 B
TypeScript
32 lines
912 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import type { Element } from 'domhandler'
|
|
import React from 'react'
|
|
import { ComponentReplacer } from '../ComponentReplacer'
|
|
import { FlowChart } from './flowchart/flowchart'
|
|
|
|
/**
|
|
* Detects code blocks with "flow" as language and renders them as flow chart.
|
|
*/
|
|
export class FlowchartReplacer extends ComponentReplacer {
|
|
public getReplacement(codeNode: Element): React.ReactElement | undefined {
|
|
if (
|
|
codeNode.name !== 'code' ||
|
|
!codeNode.attribs ||
|
|
!codeNode.attribs['data-highlight-language'] ||
|
|
codeNode.attribs['data-highlight-language'] !== 'flow' ||
|
|
!codeNode.children ||
|
|
!codeNode.children[0]
|
|
) {
|
|
return
|
|
}
|
|
|
|
const code = ComponentReplacer.extractTextChildContent(codeNode)
|
|
|
|
return <FlowChart code={code} />
|
|
}
|
|
}
|