summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/markdown-formatter.tsx
blob: f455a882c4ce93026b8efdab8c2a321643ba8f1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import React from 'react';
import styled from 'styled-components';

const boldSyntax = '**';
const Bold = styled.span({ fontWeight: 'bold' });

export function formatMarkdown(inputString: string): React.ReactElement {
  const formattedString = inputString
    .split(boldSyntax)
    .map((value, index) =>
      index % 2 === 0 ? (
        <React.Fragment key={index}>{value}</React.Fragment>
      ) : (
        <Bold key={index}>{value}</Bold>
      ),
    );

  return <>{formattedString}</>;
}