Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ jobs:
name: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
path: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
if-no-files-found: error
- name: Extract Changelog
if: (env.VS_EXISTS == 'false' || env.OVSX_EXISTS == 'false') && success()
run: |
awk -v v="[${{ steps.package-version.outputs.current-version }}]" '
/^## / {
if (index($0, v)) {
p=1
next
} else {
p=0
}
}
p { print }
' CHANGELOG.md > RELEASE_BODY.md
- name: Create release with artifact
if: (env.VS_EXISTS == 'false' || env.OVSX_EXISTS == 'false') && success()
uses: softprops/action-gh-release@v2.0.8
Expand All @@ -99,6 +113,7 @@ jobs:
name: Release v${{ steps.package-version.outputs.current-version }}
tag_name: v${{ steps.package-version.outputs.current-version }}
draft: false
body_path: RELEASE_BODY.md
files: postscript-preview-${{ steps.package-version.outputs.current-version }}.vsix
- name: Publish to Open VSX Registry
if: env.OVSX_EXISTS == 'false'
Expand Down
37 changes: 37 additions & 0 deletions ANTIGRAVITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Antigravity Guide

## Project Overview

**PostScript Preview** is a VS Code extension that renders previews for `.ps` and `.eps` files.

- **Core Logic**: Uses `Ghostscript` (`ps2pdf`) to convert PS -> PDF, then `Poppler` (`pdftocairo`) to convert PDF -> SVG for display in a webview.
- **Languages**: TypeScript.

## Build & Test

- **Build**: `yarn compile` (runs `tsc`).
- **Test**: `yarn test` (runs VS Code extension tests via `mocha`).
- **Lint**: `yarn lint` (`eslint`).

## Key Files

- **`src/extension.ts`**: Entry point. Registers commands (`postscript-preview.sidePreview`).
- **`src/preview.ts`**: Core logic.
- `generatePreview()`: Handles the `ps2pdf` and `pdftocairo` pipeline.
- **CRITICAL**: usage of `spawnSync` for `ps2pdf` must use `{ shell: false }` to support special characters in filenames.
- **`src/webview.ts`**: Generates HTML content for the webview.
- **`src/config.ts`**: Manages configuration settings (paths to executables).
- **`src/test/suite/extension.test.ts`**: Integration tests. Includes cases for special character filenames.
- **`.github/workflows/release.yml`**: CI/CD for publishing. Automatically extracts changelog entries for release descriptions.

## Workflows

- **Release**:
1. Bump version in `package.json`.
2. Add entry to `CHANGELOG.md`.
3. Push to `main`. The GitHub Action will build, test, package (`vsce`), and publish to Marketplace/OpenVSX.

## Common Issues

- **Ghostscript Warnings**: "no display font for 'ArialUnicode'" is a common benign warning from Ghostscript.
- **Filenames**: Always ensure command execution avoids shell injection (use `shell: false`).
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## [0.5.4] - 2025-12-23

- Fixed an issue where previewing files with special characters in the filename (e.g., spaces, parentheses) would fail with a syntax error.

## [0.5.2] - 2025-12-17

- Fixed `Cannot find module 'path-scurry'` runtime error by downgrading `glob` dependency.
Expand Down
Binary file added examples/test (example).ps
Binary file not shown.
Binary file added examples/test example.ps
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "postscript-preview",
"displayName": "PostScript Preview",
"description": "PostScript Preview is an extension that helps to preview EPS and PS files in Visual Studio Code.",
"version": "0.5.3",
"version": "0.5.4",
"icon": "images/logo.png",
"publisher": "ahnafnafee",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export function generatePreview(
const ps2pdfResult = spawnSync(
config.ps2pdf,
["-dEPSCrop", filepath, pdfInfo.path],
{ encoding: "utf-8", shell: true }
{ encoding: "utf-8", shell: false }
);

// Display any console output from GhostScript
Expand Down
16 changes: 16 additions & 0 deletions src/test/suite/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,20 @@ suite("Extension Test Suite", () => {
// Execute the command - validation fails if this throws
await vscode.commands.executeCommand("postscript-preview.sidePreview");
});

test("Preview command should execute with special characters in filename", async () => {
// Ensure workspace is open
assert.ok(vscode.workspace.workspaceFolders, "No workspace is open");

const workspaceRoot = vscode.workspace.workspaceFolders[0].uri.fsPath;
const filePath = vscode.Uri.file(
workspaceRoot + "/examples/test (example).ps"
);

const doc = await vscode.workspace.openTextDocument(filePath);
await vscode.window.showTextDocument(doc);

// Execute the command - validation fails if this throws
await vscode.commands.executeCommand("postscript-preview.sidePreview");
});
});