-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(js): Com 229 update the in app preview component in the web app …
…to (#6600) Co-authored-by: Sokratis Vidros <[email protected]>
- Loading branch information
1 parent
38e552f
commit f60aa5b
Showing
10 changed files
with
106 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"main": "../dist/cjs/internal/index.cjs", | ||
"module": "../dist/esm/internal/index.mjs", | ||
"types": "../dist/cjs/internal/index.d.ts" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './parseMarkdown'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export interface Token { | ||
type: 'bold' | 'text'; | ||
content: string; | ||
} | ||
|
||
export const parseMarkdownIntoTokens = (text: string): Token[] => { | ||
const tokens: Token[] = []; | ||
let buffer = ''; | ||
let inBold = false; | ||
|
||
for (let i = 0; i < text.length; i += 1) { | ||
// Check if it's an escaped character | ||
if (text[i] === '\\' && text[i + 1] === '*') { | ||
buffer += '*'; | ||
i += 1; | ||
} | ||
// Check for bold marker ** | ||
else if (text[i] === '*' && text[i + 1] === '*') { | ||
if (buffer) { | ||
tokens.push({ type: inBold ? 'bold' : 'text', content: buffer }); | ||
buffer = ''; | ||
} | ||
inBold = !inBold; | ||
i += 1; | ||
} else { | ||
buffer += text[i]; | ||
} | ||
} | ||
|
||
// Push any remaining buffered text as a token | ||
if (buffer) { | ||
tokens.push({ type: inBold ? 'bold' : 'text', content: buffer }); | ||
} | ||
|
||
return tokens; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.