Skip to content

Commit

Permalink
Merged PR 311: v1.31.0 - Add square bracket versions of default reade…
Browse files Browse the repository at this point in the history
…r directives (#291)

v1.31.0 - Add square bracket versions of default reader directives
  • Loading branch information
alopezlago authored Apr 19, 2024
1 parent bf7a245 commit d91e137
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "modaq",
"version": "1.30.1",
"version": "1.31.0",
"description": "Quiz Bowl Reader using TypeScript, React, and MobX",
"repository": {
"type": "git",
Expand Down
9 changes: 8 additions & 1 deletion src/parser/FormattedTextParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,14 @@ export const defaultPronunciationGuideMarkers: [string, string] = ["(", ")"];
/**
* Default reader directives used if none are passed into `IFormattingOptions`
*/
export const defaultReaderDirectives: string[] = ["(emphasize)", "(pause)", "(read slowly)"];
export const defaultReaderDirectives: string[] = [
"(emphasize)",
"(pause)",
"(read slowly)",
"[emphasize]",
"[pause]",
"[read slowly]",
];

/**
* Options for how to parse and format text
Expand Down
75 changes: 73 additions & 2 deletions tests/FormattedTextParserTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,12 +431,11 @@ describe("FormattedTextParserTests", () => {
},
]);
});
it("Default reader directives", () => {
it("Default reader directives (parentheses)", () => {
const textToFormat =
"This (Emphasize) equation is proportional to (read slowly) a minus x, plus (pause) 1.";
const result: IFormattedText[] = FormattedTextParser.parseFormattedText(textToFormat, {
pronunciationGuideMarkers: ["[", "]"],
// readerDirectives: ["(emphasize)", "(read slowly)", "(pause)"],
});
expect(result).to.deep.equal([
{
Expand Down Expand Up @@ -504,6 +503,78 @@ describe("FormattedTextParserTests", () => {
},
]);
});
it("Default reader directives (square brackets)", () => {
const textToFormat =
"This [Emphasize] equation is proportional to [read Slowly] a minus x, plus [pause] 1.";
const result: IFormattedText[] = FormattedTextParser.parseFormattedText(textToFormat, {
pronunciationGuideMarkers: ["(", ")"],
});
expect(result).to.deep.equal([
{
text: "This ",
bolded: false,
emphasized: false,
underlined: false,
subscripted: false,
superscripted: false,
pronunciation: false,
},
{
text: "[Emphasize]",
bolded: false,
emphasized: false,
underlined: false,
subscripted: false,
superscripted: false,
pronunciation: true,
},
{
text: " equation is proportional to ",
bolded: false,
emphasized: false,
underlined: false,
subscripted: false,
superscripted: false,
pronunciation: false,
},
{
text: "[read Slowly]",
bolded: false,
emphasized: false,
underlined: false,
subscripted: false,
superscripted: false,
pronunciation: true,
},
{
text: " a minus x, plus ",
bolded: false,
emphasized: false,
underlined: false,
subscripted: false,
superscripted: false,
pronunciation: false,
},
{
text: "[pause]",
bolded: false,
emphasized: false,
underlined: false,
subscripted: false,
superscripted: false,
pronunciation: true,
},
{
text: " 1.",
bolded: false,
emphasized: false,
underlined: false,
subscripted: false,
superscripted: false,
pronunciation: false,
},
]);
});
it("Explicit reader directives", () => {
const textToFormat = "This (Emphasize) equation is proportional to (slowly) a minus x, plus (pause) 1.";
const result: IFormattedText[] = FormattedTextParser.parseFormattedText(textToFormat, {
Expand Down

0 comments on commit d91e137

Please sign in to comment.