generated at
scrapbox-parser
かなり高頻度にメンテナンスされている

Scrapbox記法のnative parserとはだいぶ違う


使い方
sh
deno test https://scrapbox.io/api/code/villagepump/scrapbox-parser/deno_sample_test.ts
deno_sample_test.ts
import { parse } from "https://esm.sh/@progfay/scrapbox-parser@7.2.0"; import { assertEquals } from "https://deno.land/std@0.121.0/testing/asserts.ts"; Deno.test("parse()のテスト", () => { const text = [ "scrapbox-parser", "[Scrapbox記法]の[parser] by [/progfay-pub/progfay.icon]", " [/icons/github.icon][https://github.com/progfay/scrapbox-parser progfay/scrapbox-parser]", " かなり高頻度にメンテナンスされている", "", "Scrapbox内部で使っているparserとは若干違う", ].join("\n"); const expect = [ { type: "title", text: "scrapbox-parser"}, { indent: 0, type: "line", nodes: [ { type: "link", raw: "[Scrapbox記法]", pathType: "relative", href: "Scrapbox記法", content: "" }, { type: "plain", raw: "の", text: "の" }, { type: "link", raw: "[parser]", pathType: "relative", href: "parser", content: "" }, { type: "plain", raw: " by ", text: " by " }, { path: "/progfay-pub/progfay", pathType: "root", type: "icon", raw: "[/progfay-pub/progfay.icon]" } ] }, { indent: 1, type: "line", nodes: [ { path: "/icons/github", pathType: "root", type: "icon", raw: "[/icons/github.icon]" }, { type: "link", raw: "[https://github.com/progfay/scrapbox-parser progfay/scrapbox-parser]", pathType: "absolute", href: "https://github.com/progfay/scrapbox-parser", content: "progfay/scrapbox-parser" } ] }, { indent: 1, type: "line", nodes: [ { type: "plain", raw: "かなり高頻度にメンテナンスされている", text: "かなり高頻度にメンテナンスされている" } ] }, { indent: 0, type: "line", nodes: [] }, { indent: 0, type: "line", nodes: [ { type: "plain", raw: "Scrapbox内部で使っているparserとは若干違う", text: "Scrapbox内部で使っているparserとは若干違う" } ] }, ]; assertEquals(parse(text, { hasTitle: true }), expect); });
node_sample.ts
import { parse } from "@progfay/scrapbox-parser"; import fetch from "node-fetch"; const PROJECT_NAME = "help"; const PAGE_NAME = "syntax"; fetch(`https://scrapbox.io/api/pages/${PROJECT_NAME}/${PAGE_NAME}/text`) .then((response) => response.text()) .then((text) => parse(text));