diff --git a/package.json b/package.json
index 1b4a4eb7..5943c182 100644
--- a/package.json
+++ b/package.json
@@ -64,7 +64,7 @@
"scripts": {
"tsc": "tsc",
"lint": "tslint -c ./tslint.json --project ./tsconfig.json --format stylish",
- "test": "nyc --reporter=html --reporter=text mocha --require ts-node/register --bail src/test/**/*.ts",
+ "test": "nyc --reporter=html --reporter=text mocha --require ts-node/register --bail src/test/**/*.ts src/**/*.test.ts",
"prettier-check": "prettier --list-different \"src/**/*.ts*(x)\"",
"build": "webpack --mode production --devtool source-map --progress",
"start": "NODE_OPTIONS=--openssl-legacy-provider webpack-dev-server --mode development --open --devtool cheap-module-source-map",
diff --git a/src/ui/questPlay/brAndNobrTags.test.ts b/src/ui/questPlay/brAndNobrTags.test.ts
new file mode 100644
index 00000000..87dcc5d8
--- /dev/null
+++ b/src/ui/questPlay/brAndNobrTags.test.ts
@@ -0,0 +1,22 @@
+import * as assert from "assert";
+import { brAndNobrTags } from "./brAndNobrTags";
+
+describe("brAndNobrTags", () => {
+ it("should split the text by
into separate lines", () => {
+ const texts = ["a", " b
c ", "d", "
", "c"];
+ const result = brAndNobrTags(texts);
+ assert.deepEqual(result, ["a", " b ", " c ", "d", "", "", "c"]);
+ });
+
+ it("should join line with next if it ends with ", () => {
+ const texts = ["a", "b", "c", "d", "e ", "f", ""];
+ const result = brAndNobrTags(texts);
+ assert.deepEqual(result, ["a", "bc", "d", "e f", ""]);
+ });
+
+ it("should not cut last empty line", () => {
+ const texts = ["a", ""];
+ const result = brAndNobrTags(texts);
+ assert.deepEqual(result, ["a", ""]);
+ });
+});
diff --git a/src/ui/questPlay/brAndNobrTags.ts b/src/ui/questPlay/brAndNobrTags.ts
new file mode 100644
index 00000000..8fffef24
--- /dev/null
+++ b/src/ui/questPlay/brAndNobrTags.ts
@@ -0,0 +1,26 @@
+/**
+ * Split the text by
into separate lines
+ * Join line with next if it ends with
+ */
+export function brAndNobrTags(texts: string[]) {
+ const out: string[] = [];
+ let currentLine = "";
+ let isNeedLastLineFlush = false;
+ for (const text of texts) {
+ for (const line of text.split("
")) {
+ const rtimmedLine = line.trimRight();
+ if (rtimmedLine.endsWith("")) {
+ currentLine += rtimmedLine.slice(0, rtimmedLine.length - "".length);
+ isNeedLastLineFlush = true;
+ } else {
+ out.push(currentLine + line);
+ currentLine = "";
+ isNeedLastLineFlush = false;
+ }
+ }
+ }
+ if (isNeedLastLineFlush) {
+ out.push(currentLine);
+ }
+ return out;
+}
diff --git a/src/ui/questPlay/questPlay.tsx b/src/ui/questPlay/questPlay.tsx
index be44144d..39fa47a1 100644
--- a/src/ui/questPlay/questPlay.tsx
+++ b/src/ui/questPlay/questPlay.tsx
@@ -28,6 +28,7 @@ import {
import { GamePlayButton } from "./questPlay.button";
import { useDarkTheme } from "./questPlay.metatheme";
import { toggleFullscreen } from "./fullscreen";
+import { brAndNobrTags } from "./brAndNobrTags";
function initRandomGame(quest: Quest, doFirstStep: boolean) {
const gameState = initGame(
@@ -282,7 +283,7 @@ export function QuestPlay({
);
- const paramsStrings = ([] as string[]).concat(...uistate.paramsState.map((x) => x.split("
")));
+ const paramsStrings = brAndNobrTags(uistate.paramsState);
const params = (
<>