本文整理汇总了TypeScript中escape-html类的典型用法代码示例。如果您正苦于以下问题:TypeScript escape-html类的具体用法?TypeScript escape-html怎么用?TypeScript escape-html使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了escape-html类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: InsertEmbedsPostmark
public InsertEmbedsPostmark(content: string, msg: Discord.Message): string {
for (const embed of msg.embeds) {
if (embed.title === undefined && embed.description === undefined) {
continue;
}
if (this.isEmbedInBody(msg, embed)) {
continue;
}
let embedContent = "<hr>"; // Horizontal rule. Two to make sure the content doesn't become a title.
const embedTitle = embed.url ?
`<a href="${escapeHtml(embed.url)}">${escapeHtml(embed.title)}</a>`
: escapeHtml(embed.title);
if (embedTitle) {
embedContent += `<h5>${embedTitle}</h5>`; // h5 is probably best.
}
if (embed.description) {
embedContent += markdown.toHTML(embed.description, {
discordCallback: this.getDiscordParseCallbacksHTML(msg),
embed: true,
});
}
content += embedContent;
}
return content;
}
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:25,代码来源:discordmessageprocessor.ts
示例2: InsertUser
public InsertUser(node: IDiscordNode, msg: Discord.Message, html: boolean = false): string {
const id = node.id;
const member = msg.guild.members.get(id);
const memberId = `@_discord_${id}:${this.opts.domain}`;
const memberName = member ? member.displayName : memberId;
if (!html) {
return memberName;
}
return `<a href="${MATRIX_TO_LINK}${escapeHtml(memberId)}">${escapeHtml(memberName)}</a>`;
}
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:10,代码来源:discordmessageprocessor.ts
示例3: InsertChannel
public InsertChannel(node: IDiscordNode, msg: Discord.Message, html: boolean = false): string {
const id = node.id;
const channel = msg.guild.channels.get(id);
if (!channel) {
return html ? `<#${escapeHtml(id)}>` : `<#${id}>`;
}
const channelStr = escapeHtml(channel ? "#" + channel.name : "#" + id);
if (!html) {
return channelStr;
}
const roomId = escapeHtml(`#_discord_${msg.guild.id}_${id}:${this.opts.domain}`);
return `<a href="${MATRIX_TO_LINK}${roomId}">${escapeHtml(channelStr)}</a>`;
}
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:13,代码来源:discordmessageprocessor.ts
示例4: InsertEmoji
public InsertEmoji(node: IEmojiNode): string {
// unfortunately these callbacks are sync, so we flag our url with some special stuff
// and later on grab the real url async
const FLAG = "\x01";
const name = escapeHtml(node.name);
return `${FLAG}${name}${FLAG}${node.animated ? 1 : 0}${FLAG}${node.id}${FLAG}`;
}
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:7,代码来源:discordmessageprocessor.ts
示例5: send
(error: send.SendError) => {
if (error.status === 404 && !filePathRegex.test(filePath)) {
// The static file handling middleware failed to find a file on
// disk. Serve the entry point HTML file instead of a 404.
send(req, entrypoint, {root: root}).pipe(res);
} else {
res.status(error.status || 500);
res.type('html');
res.end(escapeHtml(error.message));
}
})
开发者ID:poehlmann,项目名称:EvaluacionDiferencialDeLaMemoria,代码行数:11,代码来源:start_server.ts
示例6: InsertRole
public InsertRole(node: IDiscordNode, msg: Discord.Message, html: boolean = false): string {
const id = node.id;
const role = msg.guild.roles.get(id);
if (!role) {
return html ? `<@&${id}>` : `<@&${id}>`;
}
if (!html) {
return `@${role.name}`;
}
const color = Util.NumberToHTMLColor(role.color);
return `<span data-mx-color="${color}"><strong>@${escapeHtml(role.name)}</strong></span>`;
}
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:12,代码来源:discordmessageprocessor.ts
示例7: function
redisClient.get(escape(id), function (err, reply) {
if (err) return errorHandler.handleError(res, err);
if (!reply) {
return errorHandler.sendError(res, errorHandler.ERROR_NOT_FOUND, "No se pudo cargar la imagen " + id);
}
req.image = {
id: escape(id),
image: reply
};
next();
});
开发者ID:maticorv,项目名称:mascotas2018_foro,代码行数:13,代码来源:image.service.ts
示例8: findByID
export function findByID(req: IFindByIdRequest, res: express.Response, next: NextFunction) {
const id = req.params.imageId;
redisClient.get(escape(id), function (err, reply) {
if (err) return errorHandler.handleError(res, err);
if (!reply) {
return errorHandler.sendError(res, errorHandler.ERROR_NOT_FOUND, "No se pudo cargar la imagen " + id);
}
req.image = {
id: escape(id),
image: reply
};
next();
});
}
开发者ID:maticorv,项目名称:mascotas2018_foro,代码行数:17,代码来源:image.service.ts
示例9: fillProvinceIfPresent
export function fillProvinceIfPresent(req: IFindProvince, res: express.Response, next: NextFunction) {
// Si no viene ninguna provincia definida, no hacemos nada
if (!req.body.province) {
return next();
}
Province.findOne({
_id: escape(req.body.province),
enabled: true
},
function (err, province) {
if (err) return errorHandler.handleError(res, err);
if (!province) {
return errorHandler.sendError(res, errorHandler.ERROR_NOT_FOUND, "No se encuentra la provincia " + req.body.province);
}
req.province = province;
next();
});
}
开发者ID:maticorv,项目名称:mascotas2018_foro,代码行数:21,代码来源:profile.service.ts
示例10: FormatEdit
public async FormatEdit(
oldMsg: Discord.Message,
newMsg: Discord.Message,
link?: string,
): Promise<DiscordMessageProcessorResult> {
oldMsg.embeds = []; // we don't want embeds on old msg
const oldMsgParsed = await this.FormatMessage(oldMsg);
const newMsgParsed = await this.FormatMessage(newMsg);
const result = new DiscordMessageProcessorResult();
result.body = `*edit:* ~~${oldMsgParsed.body}~~ -> ${newMsgParsed.body}`;
result.msgtype = newMsgParsed.msgtype;
oldMsg.content = `*edit:* ~~${oldMsg.content}~~ -> ${newMsg.content}`;
const linkStart = link ? `<a href="${escapeHtml(link)}">` : "";
const linkEnd = link ? "</a>" : "";
if (oldMsg.content.includes("\n") || newMsg.content.includes("\n")
|| newMsg.content.length > MAX_EDIT_MSG_LENGTH) {
result.formattedBody = `<p>${linkStart}<em>edit:</em>${linkEnd}</p><p><del>${oldMsgParsed.formattedBody}` +
`</del></p><hr><p>${newMsgParsed.formattedBody}</p>`;
} else {
result.formattedBody = `${linkStart}<em>edit:</em>${linkEnd} <del>${oldMsgParsed.formattedBody}</del>` +
` -> ${newMsgParsed.formattedBody}`;
}
return result;
}
开发者ID:Half-Shot,项目名称:matrix-appservice-discord,代码行数:24,代码来源:discordmessageprocessor.ts
注:本文中的escape-html类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论