webgal-parser 4.4.15 → 4.5.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -45,12 +45,12 @@ export const contentParser = (
45
45
  };
46
46
 
47
47
  function getChooseContent(contentRaw: string, assetSetter: any): string {
48
- const chooseList = contentRaw.split('|');
48
+ const chooseList = contentRaw.split(/(?<!\\)\|/);
49
49
  const chooseKeyList: Array<string> = [];
50
50
  const chooseValueList: Array<string> = [];
51
51
  for (const e of chooseList) {
52
- chooseKeyList.push(e.split(':')[0] ?? '');
53
- chooseValueList.push(e.split(':')[1] ?? '');
52
+ chooseKeyList.push(e.split(/(?<!\\):/)[0] ?? '');
53
+ chooseValueList.push(e.split(/(?<!\\):/)[1] ?? '');
54
54
  }
55
55
  const parsedChooseList = chooseValueList.map((e) => {
56
56
  if (e.match(/\./)) {
@@ -35,8 +35,9 @@ export const scriptParser = (
35
35
 
36
36
  // 正式开始解析
37
37
 
38
- // 去分号,前面已做,这里不再需要
39
- let newSentenceRaw = sentenceRaw.split(';')[0];
38
+ // 去分号
39
+ let newSentenceRaw = sentenceRaw.split(/(?<!\\);/)[0];
40
+ newSentenceRaw = newSentenceRaw.replaceAll('\\;',';');
40
41
  if (newSentenceRaw === '') {
41
42
  // 注释提前返回
42
43
  return {
@@ -56,7 +57,11 @@ export const scriptParser = (
56
57
  // 没有command,说明这是一条连续对话或单条语句
57
58
  if (getCommandResult === null) {
58
59
  commandRaw = newSentenceRaw;
59
- parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP);
60
+ parsedCommand = commandParser(
61
+ commandRaw,
62
+ ADD_NEXT_ARG_LIST,
63
+ SCRIPT_CONFIG_MAP,
64
+ );
60
65
  command = parsedCommand.type;
61
66
  for (const e of parsedCommand.additionalArgs) {
62
67
  // 由于是连续对话,所以我们去除 speaker 参数。
@@ -72,7 +77,11 @@ export const scriptParser = (
72
77
  getCommandResult.index + 1,
73
78
  newSentenceRaw.length,
74
79
  );
75
- parsedCommand = commandParser(commandRaw, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG_MAP);
80
+ parsedCommand = commandParser(
81
+ commandRaw,
82
+ ADD_NEXT_ARG_LIST,
83
+ SCRIPT_CONFIG_MAP,
84
+ );
76
85
  command = parsedCommand.type;
77
86
  for (const e of parsedCommand.additionalArgs) {
78
87
  args.push(e);
@@ -91,12 +100,12 @@ export const scriptParser = (
91
100
  args.push(e);
92
101
  }
93
102
  }
94
- content = contentParser(newSentenceRaw, command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
103
+ content = contentParser(newSentenceRaw.trim(), command, assetSetter); // 将语句内容里的文件名转为相对或绝对路径
95
104
  sentenceAssets = assetsScanner(command, content, args); // 扫描语句携带资源
96
105
  subScene = subSceneScanner(command, content); // 扫描语句携带子场景
97
106
  return {
98
107
  command: command, // 语句类型
99
- commandRaw: commandRaw, // 命令原始内容,方便调试
108
+ commandRaw: commandRaw.trim(), // 命令原始内容,方便调试
100
109
  content: content, // 语句内容
101
110
  args: args, // 参数列表
102
111
  sentenceAssets: sentenceAssets, // 语句携带的资源列表