Skip to content

Commit

Permalink
PDF Generation: feature parity with the toolbox
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Ponzi <me@fponzi.me>
  • Loading branch information
FedericoPonzi committed Oct 31, 2024
1 parent 220a265 commit 71c87dd
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
25 changes: 25 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,31 @@
"maxLength": 1000,
"description": "Command to produce PDFs from .tex files."
},
"tlaplus.pdf.commentsShade": {
"default": true,
"type": "boolean",
"scope": "application",
"description": "If enabled, comments will have a gray background."
},
"tlaplus.pdf.commentsShadeColor": {
"default": 0.85,
"type": "number",
"scope": "application",
"maxLength": 10,
"description": "If comments are shaded in gray, this config changes the darkness of the shading. This must be a number between 0.0 (completely black) and 1.0 (no shading)."
},
"tlaplus.pdf.numberLines": {
"default": false,
"type": "boolean",
"scope": "application",
"description": "Show line numbers in PDFs."
},
"tlaplus.pdf.noPcalShade": {
"default": false,
"type": "boolean",
"scope": "application",
"description": "Causes a PlusCal algorithm (which appear in a comment) not to be shaded. (The algorithm's comments will be shaded.)"
},
"tlaplus.tlaps.enabled": {
"type": "boolean",
"default": false,
Expand Down
32 changes: 31 additions & 1 deletion src/tla2tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const CFG_JAVA_OPTIONS = 'tlaplus.java.options';
const CFG_TLC_OPTIONS = 'tlaplus.tlc.modelChecker.options';
const CFG_PLUSCAL_OPTIONS = 'tlaplus.pluscal.options';
const CFG_TLC_OPTIONS_PROMPT = 'tlaplus.tlc.modelChecker.optionsPrompt';
const CFG_TLA_PDF_NUMBER_LINES = 'tlaplus.pdf.numberLines';
const CFG_TLA_PDF_NO_PCAL_SHADE = 'tlaplus.pdf.noPcalShade';
const CFG_TLA_PDF_COMMENTS_SHADE = 'tlaplus.pdf.commentsShade';
const CFG_TLA_PDF_COMMENTS_SHADE_COLOR = 'tlaplus.pdf.commentsShadeColor';

const VAR_TLC_SPEC_NAME = /\$\{specName\}/g;
const VAR_TLC_MODEL_NAME = /\$\{modelName\}/g;
Expand Down Expand Up @@ -102,10 +106,34 @@ export async function runSany(tlaFilePath: string): Promise<ToolProcessInfo> {
}

export async function runTex(tlaFilePath: string): Promise<ToolProcessInfo> {
const shadeComments = vscode.workspace.getConfiguration().get<boolean>(CFG_TLA_PDF_COMMENTS_SHADE, true);
const commentColor = vscode.workspace.getConfiguration().get<number>(CFG_TLA_PDF_COMMENTS_SHADE_COLOR, 0.85);
const numberLines = vscode.workspace.getConfiguration().get<boolean>(CFG_TLA_PDF_NUMBER_LINES, false);
const noPcalShade = vscode.workspace.getConfiguration().get<boolean>(CFG_TLA_PDF_NO_PCAL_SHADE, false);

const toolArgs = ["-metadir",

Check warning on line 114 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Strings must use singlequote

Check warning on line 114 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Trailing spaces not allowed

Check warning on line 114 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Strings must use singlequote

Check warning on line 114 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Trailing spaces not allowed

Check warning on line 114 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Strings must use singlequote

Check warning on line 114 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Trailing spaces not allowed
path.dirname(tlaFilePath),

Check warning on line 115 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Expected indentation of 8 spaces but found 21

Check warning on line 115 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Trailing spaces not allowed

Check warning on line 115 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Expected indentation of 8 spaces but found 21

Check warning on line 115 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Trailing spaces not allowed

Check warning on line 115 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Expected indentation of 8 spaces but found 21

Check warning on line 115 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Trailing spaces not allowed
path.basename(tlaFilePath)];

Check warning on line 116 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Expected indentation of 8 spaces but found 21

Check warning on line 116 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Expected indentation of 8 spaces but found 21

Check warning on line 116 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Expected indentation of 8 spaces but found 21

if (shadeComments) {
toolArgs.unshift("-nops",

Check warning on line 119 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Strings must use singlequote

Check warning on line 119 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Trailing spaces not allowed

Check warning on line 119 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Strings must use singlequote

Check warning on line 119 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Trailing spaces not allowed

Check warning on line 119 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Strings must use singlequote

Check warning on line 119 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Trailing spaces not allowed
"-shade",

Check warning on line 120 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Expected indentation of 12 spaces but found 21

Check warning on line 120 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Strings must use singlequote

Check warning on line 120 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (macOS-latest)

Trailing spaces not allowed

Check warning on line 120 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Expected indentation of 12 spaces but found 21

Check warning on line 120 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Strings must use singlequote

Check warning on line 120 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-20.04)

Trailing spaces not allowed

Check warning on line 120 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Expected indentation of 12 spaces but found 21

Check warning on line 120 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Strings must use singlequote

Check warning on line 120 in src/tla2tools.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Trailing spaces not allowed
"-grayLevel",
commentColor.toString());
}

if (numberLines) {
toolArgs.unshift("-number");
}

if (noPcalShade) {
toolArgs.unshift("-noPcalShade");
}

return runTool(
TlaTool.TEX,
tlaFilePath,
[ path.basename(tlaFilePath) ],
toolArgs,
[]
);
}
Expand Down Expand Up @@ -148,6 +176,8 @@ async function runTool(
toolOptions: string[],
javaOptions: string[]
): Promise<ToolProcessInfo> {
// log the arugments:
//console.log(toolName + ': ' + filePath + ' ' + toolOptions.join(' ') + ' ' + javaOptions.join(' '));
const javaPath = await obtainJavaPath();
// TODO: Merge cfgOptions with javaOptions to avoid complete overrides.
const cfgOptions = getConfigOptions(CFG_JAVA_OPTIONS);
Expand Down

0 comments on commit 71c87dd

Please sign in to comment.