Skip to content

Commit

Permalink
Merge pull request #183 from opentofu/do-not-trim-admonition-content
Browse files Browse the repository at this point in the history
  • Loading branch information
Yantrio authored Sep 10, 2024
2 parents ca7dab8 + 509cf7d commit e9beda6
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions frontend/src/components/Markdown/P.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,28 @@ function getAdmonitionClassName(prefix: string) {
}

function getAdmonitionMatch(children: ReactNode) {
let content = "";
let text = "";

if (typeof children === "string") {
content = children;
text = children;
} else if (Array.isArray(children) && typeof children[0] === "string") {
content = children[0];
text = children[0];
}

if (!content) {
if (!text) {
return null;
}

if (
content.startsWith(WARNING_MARK) ||
content.startsWith(DANGER_MARK) ||
content.startsWith(NOTE_MARK)
text.startsWith(WARNING_MARK) ||
text.startsWith(DANGER_MARK) ||
text.startsWith(NOTE_MARK)
) {
const content = text.slice(2);

return {
prefix: content.slice(0, 2),
content: content.slice(2).trim(),
prefix: text.slice(0, 2),
content: content.trim() ? content : null,
};
}

Expand Down

0 comments on commit e9beda6

Please sign in to comment.