Skip to content

Commit

Permalink
🐛 fix issue with superfluous newline
Browse files Browse the repository at this point in the history
  • Loading branch information
danyx23 committed Nov 7, 2023
1 parent b84e95c commit 099c472
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("MarkdownTextWrap", () => {

it("should calculate height correctly", () => {
const element = new MarkdownTextWrap({
text: "a \nb \nc",
text: "a\nb\nc",
fontSize: 10,
lineHeight: 1.5,
})
Expand All @@ -83,7 +83,7 @@ describe("MarkdownTextWrap", () => {

it("should split on newline", () => {
const element = new MarkdownTextWrap({
text: "_test \n** \nnewline \n**_test",
text: "_test\n**\nnewlineyarn \n**_test",
fontSize: 10,
lineHeight: 1,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -541,13 +541,12 @@ export class MarkdownTextWrap extends React.Component<MarkdownTextWrapProps> {
// return baseText.replaceAll(/[^\n \\]\n[^\n]/g, (match) =>
// match.replace("\n", "\\\n")
// )
let text = baseText
text = text.replaceAll("\n\n", "@@PARAGRAPH@@")
let text = baseText.trim()
text = text.replaceAll("\n\n", "@@LINEBREAK@@")
text = text.replaceAll("\\\n", "@@LINEBREAK@@")
text = text.replaceAll(" \n", "@@LINEBREAK@@")
text = text.replaceAll("\n", "\\\n")
text = text.replaceAll("@@LINEBREAK@@", "\\\n")
text = text.replaceAll("@@PARAGRAPH@@", "\n\n")
return text
}
@computed get detailsOrderedByReference(): Set<string> {
Expand Down Expand Up @@ -864,7 +863,6 @@ function convertMarkdownNodeToIRTokens(
...item.children.flatMap((child) =>
convertMarkdownNodeToIRTokens(child, fontParams)
),
new IRLineBreak(),
]
}
)
Expand Down

0 comments on commit 099c472

Please sign in to comment.