From 65aff0ad44f425aeeb7d4e85b1900f957ae2b855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Kr=C5=A1ka?= Date: Wed, 22 Apr 2026 12:02:16 +0200 Subject: [PATCH] generate html for plotfig --- server/src/api/compiler/htmlGenerator.ts | 16 ++++++++++------ server/tests/compiler.test.ts | 8 ++++++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/server/src/api/compiler/htmlGenerator.ts b/server/src/api/compiler/htmlGenerator.ts index b2355a2..30a083a 100644 --- a/server/src/api/compiler/htmlGenerator.ts +++ b/server/src/api/compiler/htmlGenerator.ts @@ -451,13 +451,16 @@ export class HtmlGenerator { } } - // generate html for \fullfig[position]{filename}{caption}{label}[opts] - private async generateCommandFullfig( + // generate html for + // \fullfig[position]{filename}{caption}{label}[opts] + // \plotfig[position]{filename}{caption}{label} + private async generateCommandFullsizeFig( commandNode: SyntaxNode ): Promise { this.expectNodeName('CommandIdentifier'); - if (this.getCursorText() !== '\\fullfig') { - throw new Error('Fullfig command expected'); + const commandName = this.getCursorText(); + if (!['\\fullfig', '\\plotfig'].includes(commandName)) { + throw new Error('Fullfig or plotfig command expected'); } this.expectNext(); @@ -473,7 +476,7 @@ export class HtmlGenerator { await this.generateCommandArgument(); // consume label // label was not the last argument - if (this.cursor.to < commandNode.to) { + if (commandName == '\\fullfig' && this.cursor.to < commandNode.to) { this.expectNext(); await this.generateCommandArgumentOptional(); // consume the graphics opts } @@ -657,7 +660,8 @@ export class HtmlGenerator { } case '\\fullfig': - return await this.generateCommandFullfig(topNode); + case '\\plotfig': + return await this.generateCommandFullsizeFig(topNode); case '\\illfig': case '\\illfigi': return await this.generateCommandIllfig(); diff --git a/server/tests/compiler.test.ts b/server/tests/compiler.test.ts index 0765291..8db3857 100644 --- a/server/tests/compiler.test.ts +++ b/server/tests/compiler.test.ts @@ -610,6 +610,14 @@ describe('figures', () => { input: '\\fullfig[h]{fig}{Figures}{fig1}[width=0.2\\textwidth]', output: '
Obrázek 1: Figures
', }, + { + input: '\\plotfig{fig}{Figures}{fig1}', + output: '
Obrázek 1: Figures
', + }, + { + input: '\\plotfig[h]{fig}{Figures}{fig1}', + output: '
Obrázek 1: Figures
', + }, { input: '\\illfig{fig}{Figures}{fig1}{}', output: '
Obrázek 1: Figures
',