npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koishi-plugin-5esearch

v0.0.7

Published

search dnd5e from 5echm

Downloads

259

Readme


outline: deep

5esearch 说明文档

5esearch的说明文档,解释了代码的运作和需要注意的事情

这插件是干啥的?

5esearch是基于5e不全书github仓库的koishi插件,用于检索5e不全书中的内容——例如怪物、物品、技能、法术等。目标是可以检索所有词条,但目前还没找到匹配内容的通用方法。因此,一部分内容可能会匹配不到

用法

.search 你要搜索的东西

示例

搜索火球术

.search 火球术

插件选项

没有选项

代码解释

const regex = new RegExp(`<H. id="[^"]*">${word}[^<]*</H.>(.*?)<P>(.*?)</P>`, 'gs');

这是一个正则表达式,用于匹配包含指定单词的HTML标题和段落。它将匹配所有以指定单词开头的HTML标题,并捕获其后的内容

// 检查文件名是否与输入的单词完全匹配
  if (fileNameWithoutExt === word) {
    const body = content
      .replace(/.*true;};/gs,'')
      .replace(/<[^>]+>/gs, '')  // 去除所有 HTML 标签
      .replace(/\s+/gs, ' ')     // 去除多余的空格、换行符和制表符
      .replace(/\\n/gs, ' ')     // 去除 JSON 字符串中的 \n
      .trim();                  // 去除字符串两端的空格
    results.push(body);    

由于不全书排版的特殊性,一部分内容是单独页面的形式存在,另一部分是页面内的条目,所以需要两种匹配方式——文件名,和文件内条目。上面的代码是用于匹配文件名的。

结果

示例输入域输出

.search 卡牌喷射
卡牌喷射|SprayofCards二环咒法(吟游诗人、术士、邪术师、法师)施法时间:1动作施法距离:自身(15尺锥形)法术成分:V,S,M(一副牌组)持续时间:立即你向一处15尺锥状区域喷射卡牌,该区域内的生物必须进行一次敏捷豁免。豁免失败的生物受到2d10点力场伤害伤害并陷入目盲,持续直至其下一个回合结束。豁免成功则仅会受到一半伤害。升环施法效应:当你使用3环或更高法术位施放本法术时,你使用的法术位每比2环高一环,法术的伤害就增加1d10。

如果该搜索的内容无法被当前已经实现的内容解析方式解析,则会返回

在文件 5echm_web\topics\其他\UA\战斗风格.html 中找到单词 波涛
在文件 5echm_web\topics\城主指南\宝藏\智能魔法物品范例.htm 中找到单词 波涛
在文件 5echm_web\topics\塞洛斯之神话奥德赛\塞洛斯冒险\塔萨.htm 中找到单词 波涛
在文件 5echm_web\topics\塞洛斯之神话奥德赛\塞洛斯冒险\海上冒险.htm 中找到单词 波涛
在文件 5echm_web\topics\塞洛斯之神话奥德赛\塞洛斯冒险\神启.htm 中找到单词 波涛

这样的内容

更多

大佬们加把劲,我真不知道怎么匹配了,5echm的工程文件格式太变态了