Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,18 @@ describe("convertGrapherOptionsToInteractiveGraph", () => {
type: "sinusoid",
});
});

it("wraps axis labels in $...$ delimiters so they are interpreted as TeX", () => {
const grapher = generateGrapherWidgetOptions({
availableTypes: ["sinusoid"],
graph: {
...generateGrapherWidgetOptions().graph,
labels: ["x", "f(x)"],
},
});

const ig = convertGrapherOptionsToInteractiveGraph(grapher);

expect(ig?.labels).toEqual(["$x$", "$f(x)$"]);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function convertGrapherOptionsToInteractiveGraph(
snapStep: grapherOptions.graph.snapStep,
backgroundImage: grapherOptions.graph.backgroundImage,
markings: grapherOptions.graph.markings,
labels: grapherOptions.graph.labels,
labels: grapherOptions.graph.labels.map(wrapTexInDelimitersForMarkdown),
labelLocation: "onAxis",
showAxisArrows: {
xMin: true,
Expand Down Expand Up @@ -187,3 +187,7 @@ function grapherAnswerTypesToPerseusGraphType(
function grapherFunctionTypeToInteractiveGraphType(type: GrapherFunctionType) {
return type === "absolute_value" ? "absolute-value" : type;
}

function wrapTexInDelimitersForMarkdown(tex): string {
return `$${tex}$`;
}
Loading