summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
Diffstat (limited to 'gui/src')
-rw-r--r--gui/src/renderer/lib/html-formatter.tsx18
-rw-r--r--gui/src/renderer/markdown-formatter.tsx19
2 files changed, 18 insertions, 19 deletions
diff --git a/gui/src/renderer/lib/html-formatter.tsx b/gui/src/renderer/lib/html-formatter.tsx
new file mode 100644
index 0000000000..452b7fb1e8
--- /dev/null
+++ b/gui/src/renderer/lib/html-formatter.tsx
@@ -0,0 +1,18 @@
+import React from 'react';
+import styled from 'styled-components';
+
+const boldSyntax = /(<b>.*?<\/b>)/g;
+const Bold = styled.span({ fontWeight: 700 });
+
+export function formatHtml(inputString: string): React.ReactElement {
+ const formattedString = inputString.split(boldSyntax).map((value, index) => {
+ if (boldSyntax.test(value)) {
+ const valueWithoutTags = value.replaceAll(/<b>|<\/b>/g, '');
+ return <Bold key={index}>{valueWithoutTags}</Bold>;
+ } else {
+ return <React.Fragment key={index}>{value}</React.Fragment>;
+ }
+ });
+
+ return <>{formattedString}</>;
+}
diff --git a/gui/src/renderer/markdown-formatter.tsx b/gui/src/renderer/markdown-formatter.tsx
deleted file mode 100644
index b6b18c62d6..0000000000
--- a/gui/src/renderer/markdown-formatter.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import React from 'react';
-import styled from 'styled-components';
-
-const boldSyntax = '**';
-const Bold = styled.span({ fontWeight: 700 });
-
-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}</>;
-}