PR #29 Test: format parameter & URL dedup fix Overview
This page tests two fixes from PR #29: 1. Bare URL deduplication (Bug fix in markdown-converter.ts)
2. format: "scrapbox" parameter (bypass md2sb converter)
Created with create_page using format: "scrapbox" to preserve native syntax.
Test 1: Indentation / ネスト構造
Scrapbox uses leading spaces for nesting. Previously, md2sb stripped all leading whitespace.
Level 1 indentation (1 space)
Level 2 indentation (2 spaces)
Level 3 indentation (3 spaces)
Level 4 indentation (4 spaces)
Back to level 3
Back to level 2
Back to level 1
Japanese nesting example / 日本語ネストの例
プロジェクト構造
src/
index.ts — エントリーポイント
cosense.ts — APIクライアント
routes/
handlers/
create-page.ts — ページ作成ハンドラー
insert-lines.ts — 行挿入ハンドラー
utils/
markdown-converter.ts — Markdown→Scrapbox変換
Test 2: Code blocks / コードブロック
code:typescript
// markdown-converter.ts — the URL dedup fix
export async function convertMarkdownToScrapbox(
markdown: string,
options?: ConvertOptions
): Promise<string> {
let result = md2sb(markdown);
// Fix bare URLs being doubled by md2sb: URL URL → URL result = result.replace(
/\[(https?:\/\/^\s\]+)\s+\1\]/g, );
return result;
}
code:python
# Example: batch page creation
import requests
def create_page(title, body, format="scrapbox"):
"""Create a Cosense page via MCP server."""
return mcp.call("create_page", {
"title": title,
"body": body,
"format": format # NEW: bypass md2sb
})
code:json
{
"name": "scrapbox-cosense-mcp",
"version": "0.4.3",
"tools": ["get_page", "list_pages", "search_pages",
"create_page", "insert_lines", "get_page_url"]
}
Test 3: Bare URLs (dedup fix) / URLの重複修正
These URLs were created via format: "markdown" conversion.
The regex fix ensures [URL URL] → [URL].
The following URLs were inserted via insert_lines with format: "markdown":
Test 4: Links / リンク
Test 5: Text decoration / テキスト装飾
Bold text / 太字テスト
Italic text / 斜体テスト
Bold italic / 太字斜体
Strikethrough / 取り消し線
Inline code / インラインコード
Strong link notation
Test 6: Tables / テーブル
table:test_results
Scenario format param Expected Actual Status
Bare URL (markdown) markdown URL URL ✅ Pass Indentation (scrapbox) scrapbox preserved preserved ✅ Pass
Code blocks (scrapbox) scrapbox preserved preserved ✅ Pass
Mixed syntax (scrapbox) scrapbox raw passthrough raw passthrough ✅ Pass
Test 7: Icons and images / アイコン
/icons/hr.icon
Test 8: Mathematical notation
$ e^{i\pi} + 1 = 0
$ \sum_{k=1}^{n} k = \frac{n(n+1)}{2}
$ \int_0^\infty e^{-x^2} dx = \frac{\sqrt{\pi}}{2}
Test 9: Blockquote / 引用
The best way to predict the future is to invent it. — Alan Kay
未来を予測する最善の方法は、それを発明することだ。
Environment
MCP Server: scrapbox-cosense-mcp v0.4.3 (fork with fixes)
Branch: fix/format-param-and-url-doubling
Test date: 2026-03-12
insert_lines test below ---
Test 10: insert_lines with format: "scrapbox"
This section was added via insert_lines with format: "scrapbox".
Verifies that indentation, code blocks, and nested content survive insertion.
Nested structure test / ネスト構造の挿入テスト
Item A
Sub-item A1 — details here
Sub-item A2 — more details
Deep nesting A2a
Item B
Sub-item B1
Code block insertion test
code:shell
# Verify the fix is deployed
cd scrapbox-cosense-mcp
npm run build
npm test
# Expected: 151 tests pass, 0 failures
Table insertion test
table:insert_lines_results
Operation format Indentation Code blocks URLs Status
create_page scrapbox ✅ ✅ N/A Pass
create_page markdown N/A N/A ✅ deduped Pass
insert_lines scrapbox ✅ ✅ N/A Pass
insert_lines markdown N/A N/A ✅ deduped Pass
Mixed language test / 多言語テスト
English: The quick brown fox jumps over the lazy dog.
日本語: 素早い茶色の狐が怠惰な犬を飛び越える。
Emoji: 🦊 🐕 ✅ ❌ 🔧
Conclusion / 結論
All tests passed. Both create_page and insert_lines correctly handle:
✅ format: "scrapbox" — preserves indentation, code blocks, tables, LaTeX
✅ format: "markdown" — converts correctly, bare URLs no longer doubled
✅ Backward compatible — format is optional, defaults to "markdown"