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
16 changes: 10 additions & 6 deletions server/src/api/compiler/htmlGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string> {
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();
Expand All @@ -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
}
Expand Down Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions server/tests/compiler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,14 @@ describe('figures', () => {
input: '\\fullfig[h]{fig}{Figures}{fig1}[width=0.2\\textwidth]',
output: '<figure class="figure w-50 text-center mx-auto d-block"><img class="figure-img img-fluid rounded w-100" src="fig"><figcaption class="figure-caption text-center">Obrázek 1: Figures</figcaption></figure>',
},
{
input: '\\plotfig{fig}{Figures}{fig1}',
output: '<figure class="figure w-50 text-center mx-auto d-block"><img class="figure-img img-fluid rounded w-100" src="fig"><figcaption class="figure-caption text-center">Obrázek 1: Figures</figcaption></figure>',
},
{
input: '\\plotfig[h]{fig}{Figures}{fig1}',
output: '<figure class="figure w-50 text-center mx-auto d-block"><img class="figure-img img-fluid rounded w-100" src="fig"><figcaption class="figure-caption text-center">Obrázek 1: Figures</figcaption></figure>',
},
{
input: '\\illfig{fig}{Figures}{fig1}{}',
output: '<figure class="figure w-25 float-end m-3"><img class="figure-img img-fluid rounded w-100" src="fig"><figcaption class="figure-caption text-center">Obrázek 1: Figures</figcaption></figure>',
Expand Down
Loading