@qnroa/qtype 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DgHvnMV9.js","assets/index-1XXyxiQO.js","assets/index-BLryk3W4.css"])))=>i.map(i=>d[i]);
2
- import{r as l,_ as h,u as g,j as f,C as p,M as m,T as y,a as w}from"./index-1XXyxiQO.js";let o=null,c=null;async function L(){return o||c||(c=h(()=>import("./index-DgHvnMV9.js"),__vite__mapDeps([0,1,2])).then(async e=>(o=await e.createHighlighter({themes:["github-dark","github-light"],langs:[]}),o)),c)}async function _(e,t){if(!e.getLoadedLanguages().includes(t))try{await e.loadLanguage(t)}catch{}}function x(e){const[t,n]=l.useState(o);return l.useEffect(()=>{if(!e)return;let r=!1;return(async()=>{const s=await L();await _(s,e),r||n(s)})(),()=>{r=!0}},[e]),t}const A=/```(\w+)/;function E(e){const t=e.toLowerCase();return t.includes("typescript")||t.endsWith(".ts")?"typescript":t.includes("python")||t.endsWith(".py")?"python":t.includes("cpp")||t.includes("c++")?"cpp":t.includes("java")&&!t.includes("script")?"java":t.includes("go")?"go":t.includes("rust")||t.endsWith(".rs")?"rust":t.includes("code-c")||t.endsWith(".c")?"c":"javascript"}function j(e,t){if(e){const n=e.match(A);if(n)return n[1]}return E(t)}function k(e,t,n,r){if(!r||!r.getLoadedLanguages().includes(t))return new Array(Array.from(e).length).fill(null);try{const s=r.codeToTokens(e,{lang:t,theme:n}),i=[];for(const u of s.tokens){for(const a of u)for(const d of a.content)i.push(a.color??null);i.push(null)}return!e.endsWith(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BM7BgXjn.js","assets/index-C1KzsLUa.js","assets/index-BLryk3W4.css"])))=>i.map(i=>d[i]);
2
+ import{r as l,_ as h,u as g,j as f,C as p,M as m,T as y,a as w}from"./index-C1KzsLUa.js";let o=null,c=null;async function L(){return o||c||(c=h(()=>import("./index-BM7BgXjn.js"),__vite__mapDeps([0,1,2])).then(async e=>(o=await e.createHighlighter({themes:["github-dark","github-light"],langs:[]}),o)),c)}async function _(e,t){if(!e.getLoadedLanguages().includes(t))try{await e.loadLanguage(t)}catch{}}function x(e){const[t,n]=l.useState(o);return l.useEffect(()=>{if(!e)return;let r=!1;return(async()=>{const s=await L();await _(s,e),r||n(s)})(),()=>{r=!0}},[e]),t}const A=/```(\w+)/;function E(e){const t=e.toLowerCase();return t.includes("typescript")||t.endsWith(".ts")?"typescript":t.includes("python")||t.endsWith(".py")?"python":t.includes("cpp")||t.includes("c++")?"cpp":t.includes("java")&&!t.includes("script")?"java":t.includes("go")?"go":t.includes("rust")||t.endsWith(".rs")?"rust":t.includes("code-c")||t.endsWith(".c")?"c":"javascript"}function j(e,t){if(e){const n=e.match(A);if(n)return n[1]}return E(t)}function k(e,t,n,r){if(!r||!r.getLoadedLanguages().includes(t))return new Array(Array.from(e).length).fill(null);try{const s=r.codeToTokens(e,{lang:t,theme:n}),i=[];for(const u of s.tokens){for(const a of u)for(const d of a.content)i.push(a.color??null);i.push(null)}return!e.endsWith(`
3
3
  `)&&i.length>Array.from(e).length&&i.pop(),i}catch{return new Array(Array.from(e).length).fill(null)}}function v(e){var d;const{material:t,card:n}=e,[r]=g(),s=l.useMemo(()=>r?j(n.question,t.filePath):"",[n.question,t.filePath,r]),i=typeof document<"u"&&((d=document.documentElement.getAttribute("data-theme"))!=null&&d.includes("latte"))?"github-light":"github-dark",u=x(r?s:""),a=l.useMemo(()=>r?k(n.answer,s,i,u):void 0,[n.answer,s,i,u,r]);return f.jsx(p,{type:"code",variant:"flow",slots:[{role:"title",content:n.title},n.question?{role:"question",content:f.jsx(m,{source:n.question})}:{role:"question",content:null},{role:"arena",content:f.jsx(y,{...w(e),charColors:a},n.id)}]})}export{v as CodeCard};
@@ -13,7 +13,7 @@
13
13
  <meta name="referrer" content="no-referrer" />
14
14
  <link rel="icon" type="image/svg+xml" href="/qtype-mark.svg" />
15
15
  <title>qtype — 打字复习</title>
16
- <script type="module" crossorigin src="/assets/index-1XXyxiQO.js"></script>
16
+ <script type="module" crossorigin src="/assets/index-C1KzsLUa.js"></script>
17
17
  <link rel="stylesheet" crossorigin href="/assets/index-BLryk3W4.css">
18
18
  </head>
19
19
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qnroa/qtype",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Turn Markdown notes into typing practice — CLI + review + static-site publisher",
5
5
  "keywords": [
6
6
  "typing",
@@ -71,13 +71,58 @@ updated: YYYY-MM-DD
71
71
  ```
72
72
 
73
73
  - `title`: human-readable
74
- - `type`: **required**. Decides how every card is parsed and rendered
75
- - `tags`: array or space-separated
74
+ - `type`: **default** for every card in the file. Individual cards can
75
+ override via card-level frontmatter (see below).
76
+ - `tags`: default tag set for every card. Card-level tags are unioned
77
+ with these (deduped).
76
78
  - `created` / `updated`: dates. Bump `updated` on any content change
77
79
 
78
- **One material, one type. All cards in a file share the same shape.**
80
+ **Material-level fields set defaults; cards can override.** A single
81
+ file can mix qa / code / article / etc. by giving each card its own
82
+ `type` in card-level frontmatter.
79
83
 
80
- There is **no card-level frontmatter**. All per-card info lives in markdown structure.
84
+ ### Card-level frontmatter (optional)
85
+
86
+ Immediately after an H1, you may open a second YAML block. It uses the
87
+ same `---\n...\n---` syntax as the file-level frontmatter:
88
+
89
+ ```md
90
+ ---
91
+ title: 704 Binary search
92
+ type: qa
93
+ tags: [algo]
94
+ ---
95
+
96
+ # Principle
97
+ ---
98
+ type: qa
99
+ tags: [L1]
100
+ ---
101
+
102
+ ## Q
103
+ Which invariant do I keep for the closed interval version?
104
+
105
+ ## A
106
+ Loop while lo <= hi; update `lo = mid+1` / `hi = mid-1`.
107
+
108
+ # C++ implementation
109
+ ---
110
+ type: code
111
+ tags: [cpp, L1]
112
+ ---
113
+
114
+ ## Q
115
+ Write the closed-interval binary search in C++.
116
+
117
+ ## A
118
+ ​```cpp
119
+ int search(vector<int>& nums, int target) { ... }
120
+ ​```
121
+ ```
122
+
123
+ - `type` (if present) overrides the material default for this one card.
124
+ - `tags` (if present) are unioned with material tags and deduped.
125
+ - Omit the block entirely and the card inherits both fields as-is.
81
126
 
82
127
  ### Card structure
83
128
 
@@ -269,7 +314,9 @@ Ingest, Update, Quiz-gen, Cascade, Check, Level-up — semantics as before. Key
269
314
  - Concept questions, interviews → **qa**
270
315
  - Coding problems, snippets → **code**
271
316
 
272
- **One material, one type.** Mixed content multiple materials.
317
+ **Material-level `type` is the default for its cards.** Cards can
318
+ override with card-level frontmatter, so one file can mix shapes
319
+ (e.g. one qa "principle" card + four code cards for cpp/py/go/java).
273
320
 
274
321
  ---
275
322
 
@@ -287,5 +334,5 @@ Ingest, Update, Quiz-gen, Cascade, Check, Level-up — semantics as before. Key
287
334
  8. **Never `git commit` / `push`** — the user commits
288
335
  9. **No unspec'd directories** — only `material/` (may contain category subfolders, see "Grouping by folder"), `material/assets/`, and `raw/` are allowed at the repo root
289
336
  10. **Never fabricate IPA / gloss / translation** — leave blank, report in log
290
- 11. **One `type` per material** — no mixing
291
- 12. **No card-level frontmatter** per-card info lives in markdown structure
337
+ 11. **Material-level `type` is a default** — cards can override via
338
+ card-level frontmatter (see "Card-level frontmatter (optional)")
@@ -76,12 +76,55 @@ updated: YYYY-MM-DD
76
76
  **规则**:
77
77
 
78
78
  - `title`:素材标题,人看的
79
- - `type`:**必填**,决定所有卡片的解析规则和渲染样式
80
- - `tags`:数组或空格分隔,至少一个
79
+ - `type`:**默认值**,决定每张卡的解析规则和渲染样式。单卡可通过
80
+ card-level frontmatter 覆盖(见下)。
81
+ - `tags`:素材级 tag 集,和 card-level tag 合并去重
81
82
  - `created` / `updated`:日期。内容变化时 bump `updated`
82
- - **一个 material 只有一个 type**,一个文件的所有卡片形态一致
83
83
 
84
- **没有 card-level frontmatter**。所有卡片信息都由 markdown 结构表达。
84
+ **素材级 type 是默认值,卡片可以 override。** 一个文件里可以混合
85
+ qa / code / article 等多种卡型 —— 只需要给对应的卡加卡级 frontmatter。
86
+
87
+ ### 卡级 frontmatter(可选)
88
+
89
+ H1 之后可以再写一段 YAML,和文件顶部一样用 `---\n...\n---` 包起来:
90
+
91
+ ```md
92
+ ---
93
+ title: 704 二分查找
94
+ type: qa
95
+ tags: [algo]
96
+ ---
97
+
98
+ # 原理
99
+ ---
100
+ type: qa
101
+ tags: [L1]
102
+ ---
103
+
104
+ ## Q
105
+ 左闭右闭需要保持什么循环不变量?
106
+
107
+ ## A
108
+ while lo <= hi;更新 `lo = mid+1` 或 `hi = mid-1`。
109
+
110
+ # C++ 实现
111
+ ---
112
+ type: code
113
+ tags: [cpp, L1]
114
+ ---
115
+
116
+ ## Q
117
+ 用 C++ 写左闭右闭版本。
118
+
119
+ ## A
120
+ ​```cpp
121
+ int search(vector<int>& nums, int target) { ... }
122
+ ​```
123
+ ```
124
+
125
+ - 卡级 `type` 存在则覆盖素材默认
126
+ - 卡级 `tags` 存在则和素材 tags 并集(去重)
127
+ - 卡级 frontmatter 完全省略则继承素材默认
85
128
 
86
129
  ### Card 结构
87
130
 
@@ -326,7 +369,8 @@ updated: YYYY-MM-DD
326
369
  - 问答、面试题、概念解释 → **qa**
327
370
  - 代码题、算法题、片段 → **code**
328
371
 
329
- **一个 material 只有一个 type**。混合内容拆成多个 material。
372
+ **素材级 `type` 是默认值。** 一个文件里可以混合多种卡型 —— 靠卡级
373
+ frontmatter 覆盖(比如 1 张 qa 原理卡 + 4 张不同语言的 code 实现卡)。
330
374
 
331
375
  ---
332
376
 
@@ -344,5 +388,5 @@ updated: YYYY-MM-DD
344
388
  8. **不主动 git commit / push**
345
389
  9. **不建规则外的目录**:仓库根下只允许 `material/`(内部可按分类开子目录,见"按分类分子目录")、`material/assets/`、`raw/`
346
390
  10. **不凭空造 IPA / 释义 / 翻译**:不确定的宁可空着
347
- 11. **一个 material 只有一个 type**:不能混
348
- 12. **没有 card-level frontmatter**:所有 per-card 信息都用 markdown 结构表达
391
+ 11. **素材级 `type` 是默认值**:卡片可以通过卡级 frontmatter 覆盖
392
+ (见"卡级 frontmatter(可选)"章节)