scrapbox-parser
かなり高頻度にメンテナンスされている
使い方
code:sh
code:deno_sample_test.ts
Deno.test("parse()のテスト", () => {
const text = [
"scrapbox-parser",
" かなり高頻度にメンテナンスされている",
"",
"Scrapbox内部で使っているparserとは若干違う",
].join("\n");
const expect = [
{ type: "title", text: "scrapbox-parser"},
{
indent: 0,
type: "line",
nodes: [
{
type: "link",
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",
pathType: "absolute",
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);
});
code: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));