generated from ubiquity-os/plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added cols markdown and plaintext, adds code for conversion fro…
…m markdown to plaintext
- Loading branch information
1 parent
8d25ce1
commit 1a15997
Showing
9 changed files
with
67 additions
and
27 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
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,20 @@ | ||
/** | ||
* Converts a Markdown string to plain text. | ||
* @param markdown | ||
* @returns | ||
*/ | ||
export function markdownToPlainText(markdown: string): string { | ||
let text = markdown.replace(/^#{1,6}\s+/gm, ""); // Remove headers | ||
text = text.replace(/\[([^\]]+)\]\([^\)]+\)/g, "$1"); // Inline links | ||
text = text.replace(/!\[([^\]]*)\]\([^\)]+\)/g, "$1"); // Inline images | ||
text = text.replace(/```[\s\S]*?```/g, (match) => match.replace(/```/g, "").trim()); // Code blocks | ||
text = text.replace(/`([^`]+)`/g, "$1"); // Inline code | ||
text = text.replace(/(\*\*|__)(.*?)\1/g, "$2"); // Bold | ||
text = text.replace(/(\*|_)(.*?)\1/g, "$2"); // Italic | ||
text = text.replace(/~~(.*?)~~/g, "$1"); // Strikethrough | ||
text = text.replace(/^>\s+/gm, ""); // Block quotes | ||
text = text.replace(/^\s*[-*]{3,}\s*$/gm, ""); // Horizontal rules | ||
text = text.replace(/\n{3,}/g, "\n\n"); // Remove extra newlines | ||
text = text.replace(/\s+/g, " ").trim(); // Remove extra spaces | ||
return text; | ||
} |
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
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 @@ | ||
ALTER TABLE issue_comments | ||
ADD COLUMN markdown TEXT; | ||
|
||
ALTER TABLE issues | ||
ADD COLUMN markdown TEXT; |