Skip to content

Commit cc45ea8

Browse files
committed
format
1 parent b15b74e commit cc45ea8

5 files changed

Lines changed: 239 additions & 190 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"lint": "npm run lint -w prettier-plugin-pretext && npm run lint -w @pretextbook/visual-editor && npm run lint -w pretext-tools",
2929
"test": "npm run test -w @pretextbook/completions && npm run test -w prettier-plugin-pretext && npm run test -w @pretextbook/schema && npm run test:reliability",
3030
"test:reliability": "npm exec vitest run packages/remark-pretext/src/lib/remark-pretext.spec.ts packages/ptxast-util-to-mdast/src/lib/ptxast-util-to-mdast.spec.ts packages/latex-pretext/src/lib/latex-pretext.spec.ts",
31-
"pretest": "npm run build"
31+
"pretest": "npm run build",
32+
"format": "npx prettier -w $(git ls-files 'packages/vscode-extension/*.ts')"
3233
},
3334
"devDependencies": {
3435
"@changesets/cli": "^2.31.0",

packages/vscode-extension/src/documentOutline.ts

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ class OutlineNode {
5252
/**
5353
* Maps PreTeXt element tags to display icons and labels.
5454
*/
55-
const ELEMENT_CONFIG: Record<
56-
string,
57-
{ icon: string; label: string }
58-
> = {
55+
const ELEMENT_CONFIG: Record<string, { icon: string; label: string }> = {
5956
book: { icon: "book", label: "Book" },
6057
article: { icon: "book", label: "Article" },
6158
frontmatter: { icon: "info", label: "Front Matter" },
@@ -89,9 +86,7 @@ const CONTAINER_TAGS = new Set([
8986
* TreeDataProvider that parses a .ptx file and provides the document
9087
* structure as a tree for the VS Code sidebar.
9188
*/
92-
export class PretextDocumentOutlineProvider
93-
implements TreeDataProvider<OutlineNode>
94-
{
89+
export class PretextDocumentOutlineProvider implements TreeDataProvider<OutlineNode> {
9590
private _onDidChangeTreeData = new EventEmitter<
9691
OutlineNode | undefined | null
9792
>();
@@ -249,9 +244,7 @@ export class PretextDocumentOutlineProvider
249244

250245
// Check for opening tags
251246
for (const tag of OUTLINE_TAGS) {
252-
const openPattern = new RegExp(
253-
`<${tag}(?:\\s|>|/)`,
254-
);
247+
const openPattern = new RegExp(`<${tag}(?:\\s|>|/)`);
255248
const openMatch = openPattern.exec(line);
256249
if (!openMatch) {
257250
continue;
@@ -308,17 +301,13 @@ export class PretextDocumentOutlineProvider
308301
.join("\n");
309302

310303
// Single-line title: <title>Text Here</title>
311-
const singleLine = searchWindow.match(
312-
/<title>(.*?)<\/title>/,
313-
);
304+
const singleLine = searchWindow.match(/<title>(.*?)<\/title>/);
314305
if (singleLine) {
315306
return this.cleanText(singleLine[1]);
316307
}
317308

318309
// Multi-line title: <title>\nText Here\n</title>
319-
const multiLine = searchWindow.match(
320-
/<title>\s*([\s\S]*?)\s*<\/title>/,
321-
);
310+
const multiLine = searchWindow.match(/<title>\s*([\s\S]*?)\s*<\/title>/);
322311
if (multiLine) {
323312
return this.cleanText(multiLine[1]);
324313
}
@@ -334,9 +323,7 @@ export class PretextDocumentOutlineProvider
334323
.slice(startLine, Math.min(startLine + 10, lines.length))
335324
.join("\n");
336325

337-
const match = searchWindow.match(
338-
/<caption>([\s\S]*?)<\/caption>/,
339-
);
326+
const match = searchWindow.match(/<caption>([\s\S]*?)<\/caption>/);
340327
if (match) {
341328
const text = this.cleanText(match[1]);
342329
// Truncate long captions

packages/vscode-extension/src/extension.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,15 @@ import {
1414
cmdViewCodeChat,
1515
cmdViewVisualEditor,
1616
} from "./commands/view";
17-
import { cmdLivePreview, cmdForwardSearch, disposeLivePreview } from "./livePreview";
18-
import { PretextDocumentOutlineProvider, cmdOutlineJumpToLine } from "./documentOutline";
17+
import {
18+
cmdLivePreview,
19+
cmdForwardSearch,
20+
disposeLivePreview,
21+
} from "./livePreview";
22+
import {
23+
PretextDocumentOutlineProvider,
24+
cmdOutlineJumpToLine,
25+
} from "./documentOutline";
1926
import { cmdNew } from "./commands/new";
2027
import { cmdDeploy } from "./commands/deploy";
2128
import { cmdUpdate } from "./commands/update";
@@ -129,7 +136,10 @@ export async function activate(context: ExtensionContext) {
129136
),
130137
commands.registerCommand("pretext-tools.livePreview", cmdLivePreview),
131138
commands.registerCommand("pretext-tools.forwardSearch", cmdForwardSearch),
132-
commands.registerCommand("pretext-tools.outlineJumpToLine", cmdOutlineJumpToLine),
139+
commands.registerCommand(
140+
"pretext-tools.outlineJumpToLine",
141+
cmdOutlineJumpToLine,
142+
),
133143
commands.registerCommand("pretext-tools.new", cmdNew),
134144
commands.registerCommand("pretext-tools.deploy", cmdDeploy),
135145
commands.registerCommand("pretext-tools.updatePTX", cmdUpdate),

0 commit comments

Comments
 (0)