Skip to content

Commit

Permalink
Merge pull request #219 from EarthMessenger/master
Browse files Browse the repository at this point in the history
fix: example counter
  • Loading branch information
yosupo06 authored Jul 14, 2024
2 parents 298cc42 + 5004ea5 commit 62e44e8
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/utils/statement.parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,21 @@ engine.registerTag("param", {
engine.registerTag("example", {
parse(tagToken) {
this.value = tagToken.args.substring(1);
this.exampleCounter = 1;
},
render(context, emitter) {
const examples = getStatementData(context).examples;

const inName = this.value + ".in";
const outName = this.value + ".out";

emitter.write(`### #${this.exampleCounter}\n`);
this.exampleCounter++;
const scope = context.environments as {
exampleCounter: number | undefined;
};
if (typeof scope.exampleCounter !== "number") {
scope.exampleCounter = 0;
}
scope.exampleCounter += 1;
emitter.write(`### #${scope.exampleCounter}\n`);

emitter.write("```\n");
if (inName in examples) {
Expand Down

0 comments on commit 62e44e8

Please sign in to comment.