summaryrefslogtreecommitdiffhomepage
path: root/gui/src
diff options
context:
space:
mode:
authorOskar Nyberg <oskar@mullvad.net>2022-10-18 16:28:59 +0200
committerOskar Nyberg <oskar@mullvad.net>2022-10-21 10:10:57 +0200
commitd667ef8b470f4749e18ac59fc2607c369215a644 (patch)
treeacc7aa159012d2cfa69602c7f1257d8734c47c20 /gui/src
parentb4bf5d95f1df339d416df7df2634dbe2bb370440 (diff)
downloadmullvadvpn-d667ef8b470f4749e18ac59fc2607c369215a644.tar.xz
mullvadvpn-d667ef8b470f4749e18ac59fc2607c369215a644.zip
Replace markdown formatter with HTML formatter
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}</>;
-}