Repository navigation
Description
Stage 4 — Readable, configurable exports
Synopsis
Add an optional total logical-line count at the bottom-left of exported code blocks and define the shared source-line contract used by per-line numbering.
End goal
PDF and DOCX show the same correct count for the same authored code while preserving all source content.
Start after
- Add configurable code-language label placement in PDF and DOCX #35 — Add configurable code-language label placement in PDF and DOCX
Start implementation only after every prerequisite is merged into main or has a maintainer-accepted technical freeze recorded in its linked issue. A freeze must identify the exact source/prototype commit and settled contracts; an open draft PR alone is insufficient. For an investigation prerequisite, acceptance must identify the approved design/report revision and prototype commit if one exists.
Fetch current origin/main before branching. If using a freeze, record an integration base containing all required prerequisite changes and link the freeze decisions in the PR. Validate the combined result again after the final prerequisite changes are integrated. The recorded freeze governs any agreed early start while a prerequisite issue remains open.
Agreed scope
- Default the count to off and control it independently of code-language visibility and individual line numbering.
- Place the count at bottom-left using the prerequisite metadata layout; a label choosing the same corner must not overlap it.
- Count authored logical code lines, including intentional leading, internal, and trailing blank lines. Visual wrapping, fence syntax, and editor-only placeholders/sentinels must not create extra lines.
- Do not use trimming or whitespace normalization to simplify counting. Preserve every authored line even when it is blank.
- Make the shared line model and fixture expectations available to both PDF and DOCX numbering implementations.
Acceptance criteria
- The same code payload produces matching counts across PDF and DOCX, regardless of visual wrapping, font choice, highlighting, or pagination.
- Fixture expectations explicitly distinguish an empty block, a normal closing-fence separator, and intentional authored blank lines; no phantom line is introduced by editor DOM placeholders.
- Enabling/disabling counts changes only presentation, not the code payload, source Markdown, or saved revision.
- Counts remain associated with their blocks and do not overlap labels at any supported position; counts work when language labels are hidden.
- The setting is initially off, independent, captured for the export job, localized, and documented.
Verification
- Cover empty, single-line, leading/internal/trailing-blank-line, Unicode, long-line, and multi-page code with explicit expected counts and exact content preservation.
- Use actual PDF/DOCX converters and inspect target readers; record count placement and pagination evidence.
- Test the shared line model directly and assert that the export-only metadata never enters source or editor code-copy text.
Source pointers
src/export/controller.tssrc/export/types.tssrc/export/pdf.tssrc/export/pandoc.tssrc/export/code-language.tssrc/webview/editor.jspackage.jsonmedia/export-help.md
Delivery contract
Use the existing supported export host and saved-revision capture; do not add standalone Electron export. Preserve authored Markdown and all code whitespace. Capture presentation settings consistently for each job, update supported translations/documentation, and distinguish structural/converter checks from actual target-reader observations.
Work from the repository root using the Node version in .node-version and the maintained instructions in CONTRIBUTING.md, docs/building.md, and docs/testing/README.md; export changes also follow docs/export-verification.md. Run full compilation after webview JavaScript/CSS, shared-module, or translation changes, plus checks that exercise the changed behavior. Rebuild and reinstall for installed-extension evidence. Report failures/skips honestly; follow required CI and review gates. Update affected documentation and review any committed Markdown in source and rendered form.
Link the PR or investigation to this issue. Keep remediation on the same focused work item where practical. Completion requires the stated evidence and accepted outcome; opening a draft PR does not complete the issue. No deadline or assignee is imposed by this issue.
Activity