Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ changes.
### Fixed

- Fix app crash on unhandled wallet error [Issue 3123](https://github.com/IntersectMBO/govtool/issues/3123)
- Preserve new lines in markdown text [Issue 2712](https://github.com/IntersectMBO/govtool/issues/2712)

### Changed

Expand Down
1 change: 0 additions & 1 deletion govtool/frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion govtool/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"react-query": "^3.39.3",
"react-router-dom": "^6.13.0",
"rehype-katex": "^7.0.1",
"remark-breaks": "^4.0.0",
"remark-gfm": "^4.0.1",
"remark-math": "^6.0.0",
"storybook-addon-manual-mocks": "^1.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Markdown from "react-markdown";
import remarkMath from "remark-math";
import remarkGfm from "remark-gfm";
import rehypeKatex from "rehype-katex";
import remarkBreaks from "remark-breaks";
import "katex/dist/katex.min.css";
import "./tableMarkdown.css";

Expand Down Expand Up @@ -120,29 +119,42 @@ export const GovernanceActionCardElement = ({
fontWeight: 400,
lineHeight: "24px",
maxWidth: "auto",
whiteSpace: "pre-wrap",
}}
>
{children}
</Typography>
);

const markdownComponents = {
p: (props: PropsWithChildren) => {
const { children } = props;
return renderMarkdownText({ children });
},
p: ({ children }: PropsWithChildren) => renderMarkdownText({ children }),
br: () => <br />,
};

const renderMarkdown = () => (
<Markdown
components={markdownComponents}
remarkPlugins={[remarkMath, remarkBreaks, remarkGfm]}
rehypePlugins={[rehypeKatex]}
>
{text.toString()}
</Markdown>
);
const renderMarkdown = () => {
const formattedText = text
.toString()
.replace(/\r\n|\r/g, "\n")
.replace(
/\n\n+/g,
(match) =>
`\n\n${Array(match.length - 1)
.fill("&nbsp; \n")
.join("")}\n`,
)
.split("\n")
.map((line) => `${line} `)
.join("\n");

return (
<Markdown
components={markdownComponents}
remarkPlugins={[remarkMath, remarkGfm]}
rehypePlugins={[rehypeKatex]}
>
{formattedText}
</Markdown>
);
};

const renderCopyButton = () =>
isCopyButton && (
Expand Down
Loading