[add] Add core implementation.
This commit is contained in:
parent
487c0f6736
commit
6789f574b8
6
main.ts
6
main.ts
|
@ -147,15 +147,21 @@ function processLineBlock(source: string): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
function applyFormatting(text: string): string {
|
function applyFormatting(text: string): string {
|
||||||
|
if (text.includes('**')) {
|
||||||
// Replace **bold** with *bold* (with spaces)
|
// Replace **bold** with *bold* (with spaces)
|
||||||
text = text.replace(/\*\*(.*?)\*\*/g, ' *$1* ');
|
text = text.replace(/\*\*(.*?)\*\*/g, ' *$1* ');
|
||||||
|
} else if (text.includes('*')) {
|
||||||
// Replace *italic* with _italic_
|
// Replace *italic* with _italic_
|
||||||
text = text.replace(/(?<!\*)\*(?!\*)(.*?)\*(?!\*)/g, ' _$1_ ');
|
text = text.replace(/(?<!\*)\*(?!\*)(.*?)\*(?!\*)/g, ' _$1_ ');
|
||||||
|
}
|
||||||
// Replace ~~strike~~ with ~strike~
|
// Replace ~~strike~~ with ~strike~
|
||||||
text = text.replace(/~~(.*?)~~/g, ' ~$1~ ');
|
text = text.replace(/~~(.*?)~~/g, ' ~$1~ ');
|
||||||
|
if (text.includes('==')) {
|
||||||
// Replace ==emphasize== with `emphasize`
|
// Replace ==emphasize== with `emphasize`
|
||||||
text = text.replace(/==(.*?)==/g, ' `$1` ');
|
text = text.replace(/==(.*?)==/g, ' `$1` ');
|
||||||
|
} else if (text.includes('`')) {
|
||||||
// Replace `quote` with {quote}
|
// Replace `quote` with {quote}
|
||||||
text = text.replace(/`(.*?)`/g, ' {$1} ');
|
text = text.replace(/`(.*?)`/g, ' {$1} ');
|
||||||
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue