-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix:mjs output dir building to wrong directory
- Loading branch information
1 parent
fe8d76d
commit 5762252
Showing
2 changed files
with
87 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export declare class html2mrkdwn { | ||
/** | ||
* DO NOT USE | ||
* Use {@link convert()} as it is a static method | ||
* @hideconstructor | ||
*/ | ||
constructor(); | ||
/** | ||
* Rudimentary method for converting HTML code to mrkdown | ||
* | ||
* @static | ||
* @param html HTML code | ||
* @param removeOtherTags Remove all tags that are not supported by Slack Mrkdwn | ||
* @returns converted HTML to Slack Mrkdwn | ||
*/ | ||
static convert(html: string, removeOtherTags: boolean): string; | ||
static extractImg(html: string): string[]; | ||
} |
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,69 @@ | ||
var html2mrkdwn = /** @class */ (function () { | ||
/** | ||
* DO NOT USE | ||
* Use {@link convert()} as it is a static method | ||
* @hideconstructor | ||
*/ | ||
function html2mrkdwn() { | ||
} | ||
; | ||
/** | ||
* Rudimentary method for converting HTML code to mrkdown | ||
* | ||
* @static | ||
* @param html HTML code | ||
* @param removeOtherTags Remove all tags that are not supported by Slack Mrkdwn | ||
* @returns converted HTML to Slack Mrkdwn | ||
*/ | ||
html2mrkdwn.convert = function (html, removeOtherTags) { | ||
var converted = ""; | ||
// Parse <p> tags | ||
converted = html.replace(/<p>/g, ""); | ||
converted = converted.replace(/<\/p>/g, ""); | ||
// Parse <br> tags | ||
converted = converted.replace(/<br>/g, "\n"); | ||
// Parse <b>, <strong>, and <em> tags | ||
converted = converted.replace(/<b>/g, "*"); | ||
converted = converted.replace(/<\/b>/g, "*"); | ||
converted = converted.replace(/<strong>/g, "*"); | ||
converted = converted.replace(/<\/strong>/g, "*"); | ||
converted = converted.replace(/<em>/g, "*"); | ||
converted = converted.replace(/<\/em>/g, "*"); | ||
// Parse <i> tags | ||
converted = converted.replace(/<i>/g, "_"); | ||
converted = converted.replace(/<\/i>/g, "_"); | ||
// Parse <strike> tags | ||
converted = converted.replace(/<strike>/g, "~"); | ||
converted = converted.replace(/<\/strike>/g, "~"); | ||
// Parse <blockquote> tags | ||
converted = converted.replace(/<blockquote>/g, ">"); | ||
converted = converted.replace(/<\/blockquote>/g, "\n"); | ||
// Parse <code> tags | ||
converted = converted.replace(/<code>/g, "`"); | ||
converted = converted.replace(/<\/code>/g, "`"); | ||
// Parse Lists | ||
converted = converted.replace(/<ul>/g, ""); | ||
converted = converted.replace(/<\/ul>/g, ""); | ||
converted = converted.replace(/<ol>/g, ""); | ||
converted = converted.replace(/<\/ol>/g, ""); | ||
converted = converted.replace(/<li>/g, "- "); | ||
converted = converted.replace(/<\/li>/g, "\n"); | ||
// Parse Links | ||
converted = converted.replace(/<a href="(.*)">(.*)<\/a>/g, "<$1|$2>"); | ||
if (removeOtherTags) { | ||
// Remove all other tags | ||
converted = converted.replace(/<[^>]+>/g, ""); | ||
} | ||
return converted; | ||
}; | ||
html2mrkdwn.extractImg = function (html) { | ||
var imgTags = html.match(/<img [^>]*src="[^"]*"[^>]*>/g) || []; | ||
var imgSrcs = imgTags.map(function (tag) { | ||
var match = tag.match(/src="([^"]*)"/); | ||
return match ? match[1] : ""; | ||
}); | ||
return imgSrcs; | ||
}; | ||
return html2mrkdwn; | ||
}()); | ||
export { html2mrkdwn }; |