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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@hakulex/litexml

v0.4.1

Published

Convert hakulex documents to and from LiteXML, a compact XML format for documents

Readme

@hakulex/litexml

在文件 JSON 和 LiteXML 之間轉換,LiteXML 是給 AI 讀寫的精簡 XML 格式。

hakulex 的一部分:給 Vue 3 的富文本編輯器,建立在 Lexical 上。這個套件的說明和可以操作的範例在 hakulex.dev/packages/litexml。

安裝

pnpm add @hakulex/litexml lexical

使用

範例裡的 ./documents 是你自己的文件 JSON,也就是編輯器的 v-model 存下來的內容。

<script setup lang="ts">
import { createDefaultRegistry, serializeToXml } from '@hakulex/litexml'
import { article } from './documents'

const xml = serializeToXml(article, createDefaultRegistry())
</script>

<template>
  <pre>{{ xml }}</pre>
</template>

圖片的檔案編號

圖片和圖庫裡的圖片如果有 fileId(應用程式自己的檔案編號,見 @hakulex/editor 的說明),會寫成 img 的 file-id 屬性,讀回來時還原成 fileId。空的屬性會被略過。

讀取時不會檢查這個編號和 src 是不是原本的那一對:LiteXML 手上只有這一段文字,沒有可以比對的文件。讓模型改寫文件時,這項檢查由 @hakulex/agent-core 負責。

檢查

deserializeFromXml 和 deserializeNodesFromXml 讀取時很寬鬆:格式有錯會盡量讀,不認得的標籤會略過,不會報錯。要知道一段 LiteXML 哪裡寫錯(例如檢查程式或模型產生的內容),用 checkXml:

import { checkXml, createDefaultRegistry } from '@hakulex/litexml'

const problems = checkXml('<p>沒有關<b>粗體</p>', createDefaultRegistry())
// [{ kind: 'malformed', tag: 'b', message: '<b> is never closed. Add </b>.', index: 7 }]

回傳空陣列表示沒有找到問題。kind 有三種:malformed(標籤沒有成對、屬性的引號沒有關、文字裡有沒跳脫的 <)、unknown-tag(不是 LiteXML 的標籤)、empty(沒有內容)。自己註冊的讀取函式如果會處理內層的標籤,用第三個參數 { knownTags: ['…'] } 告訴它。

授權

MIT。部分程式碼改寫自 haklex,詳見 NOTICE。