diff --git a/.workbuddy/tools/md2pdf/md2pdf.js b/.workbuddy/tools/md2pdf/md2pdf.js index d725d1b..6678378 100644 --- a/.workbuddy/tools/md2pdf/md2pdf.js +++ b/.workbuddy/tools/md2pdf/md2pdf.js @@ -32,7 +32,7 @@ function parseArgs(argv) { } const ARGS = parseArgs(process.argv); if (!ARGS.in || !ARGS.out) { console.error('缺少 --in / --out'); process.exit(1); } -const MODE = ARGS.mode === 'answer' ? 'answer' : 'plain'; +const MODE = ARGS.mode === 'answer' ? 'answer' : (ARGS.mode === 'exam' ? 'exam' : 'plain'); /* ------------------------------ KaTeX CSS(内联字体) ------------------------------ */ function buildKatexCss() { @@ -211,6 +211,55 @@ function buildAnswerBody(rawMd) { return out.join('\n'); } +/* 模拟卷打印版:客观题不留白(答案写在括号/横线里),解答题按分值留白并独占一页 */ +function buildExamBody(rawMd) { + const lines = unlinkWikilinks(stripFrontmatter(rawMd)).split(/\r?\n/); + const blocks = []; + let buf = []; + let group = { title: '' }; + let cur = null; + const flushMd = () => { if (buf.join('\n').trim()) blocks.push({ type: 'md', text: buf.join('\n') }); buf = []; }; + const flushQ = () => { if (cur) { cur.text = cur.text.join('\n').trim(); blocks.push(cur); cur = null; } }; + + for (const line of lines) { + const gh = line.match(/^##\s+(.*)$/); + const qh = line.match(/^\*\*(\d+)\.\*\*\s*(.*)$/); + if (gh) { flushQ(); flushMd(); group = { title: gh[1] }; buf.push(line); continue; } + if (qh) { flushQ(); flushMd(); cur = { type: 'q', group: group.title, num: +qh[1], text: [line] }; continue; } + if (cur) cur.text.push(line); else buf.push(line); + } + flushQ(); flushMd(); + + const BRK = 'break-before:page;page-break-before:always;'; + const out = []; + let pendingBreak = false; + for (const b of blocks) { + const { text, store } = protectMath(b.text); + if (b.type === 'md') { + const html = mdToHtml(text, store); + // 部分边界(解答题、交卷后)另起一页;标题与紧接着的首题留在同一页 + if (/^##\s/.test(b.text.trim()) && /解答题|交卷后/.test(b.text)) { + out.push(`
${html}
`); + pendingBreak = true; + } else { + out.push(html); + } + continue; + } + const html = mdToHtml(text, store); + if (/选择题/.test(b.group)) { out.push(`
${html}
`); continue; } + if (/填空题/.test(b.group)) { out.push(`
${html}
`); continue; } + const brk = pendingBreak ? '' : BRK; + pendingBreak = false; + // 解答题:每题独占一页,留白框弹性撑满剩余高度(短题干就多给纸) + out.push( + `
${html}` + + `
` + ); + } + return out.join('\n'); +} + /* 普通版 */ function buildPlainBody(rawMd) { const { text, store } = protectMath(unlinkWikilinks(stripFrontmatter(rawMd))); @@ -224,7 +273,9 @@ function buildPlainBody(rawMd) { const raw = fs.readFileSync(inPath, 'utf8'); const title = ARGS.title || path.basename(inPath, '.md'); - const body = MODE === 'answer' ? buildAnswerBody(raw) : buildPlainBody(raw); + const body = MODE === 'answer' ? buildAnswerBody(raw) + : MODE === 'exam' ? buildExamBody(raw) + : buildPlainBody(raw); const html = htmlShell(title, body); const buildDir = path.join(__dirname, 'build'); diff --git a/.workbuddy/tools/md2pdf/prep_exam.py b/.workbuddy/tools/md2pdf/prep_exam.py new file mode 100644 index 0000000..0182915 --- /dev/null +++ b/.workbuddy/tools/md2pdf/prep_exam.py @@ -0,0 +1,98 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +"""prep_exam.py —— 模拟卷 Markdown 预处理,产出可直接打印的干净稿 + +把「第三次模拟-数学一」这类目录下的 + 01-模拟卷.md / 02a-答案与解析-客观题.md / 02b-答案与解析-解答题.md +清洗成两份: + paper.md —— 只留试卷(去掉每题末尾的考点行与 △ 预测标记,否则等于泄题) + full.md —— 试卷 + 两册解析,供对答案时通读 + +用法: + python prep_exam.py <模拟卷目录> [--outdir <输出目录>] + +默认输出到 <仓库>/.workbuddy/tools/md2pdf/build/<目录名>/ +""" + +import os +import re +import sys +import io + +FM_RE = re.compile(r'^---\r?\n[\s\S]*?\r?\n---\r?\n?') +KP_RE = re.compile(r'^>\s*\*\*考点\*\*\s*·') # 每题末尾的考点跳转行 +TRI_NOTE_RE = re.compile(r'带\s*\*\*△\*\*\s*的是[^\n]*') # △ 图例说明 +LINK_RE = re.compile(r'(?\n') + parts.append(clean(raw, drop_kp=False, drop_tri=False)) + p_full = os.path.join(outdir, 'full.md') + io.open(p_full, 'w', encoding='utf-8').write('\n'.join(parts)) + + print('OK %s' % p_paper) + print('OK %s' % p_full) + return p_paper, p_full + + +if __name__ == '__main__': + if len(sys.argv) < 2: + print(__doc__) + sys.exit(1) + args = sys.argv[1:] + outdir = None + if '--outdir' in args: + i = args.index('--outdir') + outdir = args[i + 1] + del args[i:i + 2] + build(args[0], outdir) diff --git a/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/PDF/第三次模拟-做题版.pdf b/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/PDF/第三次模拟-做题版.pdf new file mode 100644 index 0000000..64034df Binary files /dev/null and b/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/PDF/第三次模拟-做题版.pdf differ diff --git a/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/PDF/第三次模拟-题目与解析.pdf b/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/PDF/第三次模拟-题目与解析.pdf new file mode 100644 index 0000000..c64ec52 Binary files /dev/null and b/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/PDF/第三次模拟-题目与解析.pdf differ diff --git a/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/README.md b/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/README.md index 94dd4ce..656482f 100644 --- a/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/README.md +++ b/基于考研的学习/数学一/模拟卷/第三次模拟-数学一/README.md @@ -33,6 +33,10 @@ tags: [数学一, 模拟卷, 说明] | | [04 线代](04-考点手册-线性代数.md) | L01—L06 | | | [05 概率](05-考点手册-概率论与数理统计.md) | P01—P06 | | **依据** | [06-考点预测与分布](06-考点预测与分布.md) | 十年统计、逐题来源、四条规律、空缺、三卷互补表 | +| **打印** | [做题版 PDF](PDF/第三次模拟-做题版.pdf) | 10 页。选择题/填空题连排(答案写在括号与横线里),解答题**每题独占一页**,留白框撑满纸面 | +| | [题目与解析 PDF](PDF/第三次模拟-题目与解析.pdf) | 16 页。试卷 + 两册解析合订,平板通读用 | + +> 做题版 PDF 已去掉每题的"考点"行与 △ 标记——纸上做题不该被提示。要考点跳转,回网页版。 ## 三、三轮用法 @@ -70,3 +74,4 @@ tags: [数学一, 模拟卷, 说明] | 日期 | 变更 | |---|---| | 2026-10-31 | 建文件夹,8 个文件(README + 试卷 + 客观题解析 + 解答题解析 + 三册手册 + 预测),22 题 150 分 | +| 2026-10-31 | 出 PDF 两版:做题版 10 页(解答题每题一页留白)、题目与解析合订 16 页 |