Skip to content

Commit 9480084

Browse files
authored
Merge pull request #21 from ahnafnafee/bug/fixes-20
2 parents 0217cfb + ddf8a71 commit 9480084

8 files changed

Lines changed: 74 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,20 @@ jobs:
9090
name: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
9191
path: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
9292
if-no-files-found: error
93+
- name: Extract Changelog
94+
if: (env.VS_EXISTS == 'false' || env.OVSX_EXISTS == 'false') && success()
95+
run: |
96+
awk -v v="[${{ steps.package-version.outputs.current-version }}]" '
97+
/^## / {
98+
if (index($0, v)) {
99+
p=1
100+
next
101+
} else {
102+
p=0
103+
}
104+
}
105+
p { print }
106+
' CHANGELOG.md > RELEASE_BODY.md
93107
- name: Create release with artifact
94108
if: (env.VS_EXISTS == 'false' || env.OVSX_EXISTS == 'false') && success()
95109
uses: softprops/action-gh-release@v2.0.8
@@ -99,6 +113,7 @@ jobs:
99113
name: Release v${{ steps.package-version.outputs.current-version }}
100114
tag_name: v${{ steps.package-version.outputs.current-version }}
101115
draft: false
116+
body_path: RELEASE_BODY.md
102117
files: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
103118
- name: Publish to Open VSX Registry
104119
if: env.OVSX_EXISTS == 'false'

ANTIGRAVITY.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Antigravity Guide
2+
3+
## Project Overview
4+
5+
**PostScript Preview** is a VS Code extension that renders previews for `.ps` and `.eps` files.
6+
7+
- **Core Logic**: Uses `Ghostscript` (`ps2pdf`) to convert PS -> PDF, then `Poppler` (`pdftocairo`) to convert PDF -> SVG for display in a webview.
8+
- **Languages**: TypeScript.
9+
10+
## Build & Test
11+
12+
- **Build**: `yarn compile` (runs `tsc`).
13+
- **Test**: `yarn test` (runs VS Code extension tests via `mocha`).
14+
- **Lint**: `yarn lint` (`eslint`).
15+
16+
## Key Files
17+
18+
- **`src/extension.ts`**: Entry point. Registers commands (`postscript-preview.sidePreview`).
19+
- **`src/preview.ts`**: Core logic.
20+
- `generatePreview()`: Handles the `ps2pdf` and `pdftocairo` pipeline.
21+
- **CRITICAL**: usage of `spawnSync` for `ps2pdf` must use `{ shell: false }` to support special characters in filenames.
22+
- **`src/webview.ts`**: Generates HTML content for the webview.
23+
- **`src/config.ts`**: Manages configuration settings (paths to executables).
24+
- **`src/test/suite/extension.test.ts`**: Integration tests. Includes cases for special character filenames.
25+
- **`.github/workflows/release.yml`**: CI/CD for publishing. Automatically extracts changelog entries for release descriptions.
26+
27+
## Workflows
28+
29+
- **Release**:
30+
1. Bump version in `package.json`.
31+
2. Add entry to `CHANGELOG.md`.
32+
3. Push to `main`. The GitHub Action will build, test, package (`vsce`), and publish to Marketplace/OpenVSX.
33+
34+
## Common Issues
35+
36+
- **Ghostscript Warnings**: "no display font for 'ArialUnicode'" is a common benign warning from Ghostscript.
37+
- **Filenames**: Always ensure command execution avoids shell injection (use `shell: false`).

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## [0.5.4] - 2025-12-23
4+
5+
- Fixed an issue where previewing files with special characters in the filename (e.g., spaces, parentheses) would fail with a syntax error.
6+
37
## [0.5.2] - 2025-12-17
48

59
- Fixed `Cannot find module 'path-scurry'` runtime error by downgrading `glob` dependency.

examples/test (example).ps

126 Bytes
Binary file not shown.

examples/test example.ps

126 Bytes
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "postscript-preview",
33
"displayName": "PostScript Preview",
44
"description": "PostScript Preview is an extension that helps to preview EPS and PS files in Visual Studio Code.",
5-
"version": "0.5.3",
5+
"version": "0.5.4",
66
"icon": "images/logo.png",
77
"publisher": "ahnafnafee",
88
"engines": {

src/preview.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ export function generatePreview(
115115
const ps2pdfResult = spawnSync(
116116
config.ps2pdf,
117117
["-dEPSCrop", filepath, pdfInfo.path],
118-
{ encoding: "utf-8", shell: true }
118+
{ encoding: "utf-8", shell: false }
119119
);
120120

121121
// Display any console output from GhostScript

src/test/suite/extension.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,20 @@ suite("Extension Test Suite", () => {
4444
// Execute the command - validation fails if this throws
4545
await vscode.commands.executeCommand("postscript-preview.sidePreview");
4646
});
47+
48+
test("Preview command should execute with special characters in filename", async () => {
49+
// Ensure workspace is open
50+
assert.ok(vscode.workspace.workspaceFolders, "No workspace is open");
51+
52+
const workspaceRoot = vscode.workspace.workspaceFolders[0].uri.fsPath;
53+
const filePath = vscode.Uri.file(
54+
workspaceRoot + "/examples/test (example).ps"
55+
);
56+
57+
const doc = await vscode.workspace.openTextDocument(filePath);
58+
await vscode.window.showTextDocument(doc);
59+
60+
// Execute the command - validation fails if this throws
61+
await vscode.commands.executeCommand("postscript-preview.sidePreview");
62+
});
4763
});

0 commit comments

Comments
 (0)