Substitute $cmd[CMD_FOO] with the corresponding key, and likewise transform foo .
| 322 | /// Substitute $cmd[CMD_FOO] with the corresponding key, and likewise |
| 323 | /// transform <input>foo</input>. |
| 324 | void hint_replace_cmds(string &text) |
| 325 | { |
| 326 | size_t p; |
| 327 | while ((p = text.find("$cmd[")) != string::npos) |
| 328 | { |
| 329 | size_t q = text.find("]", p + 5); |
| 330 | if (q == string::npos) |
| 331 | { |
| 332 | text += "<lightred>ERROR: unterminated $cmd</lightred>"; |
| 333 | break; |
| 334 | } |
| 335 | |
| 336 | string command = text.substr(p + 5, q - p - 5); |
| 337 | command_type cmd = name_to_command(command); |
| 338 | |
| 339 | command = command_to_string(cmd); |
| 340 | if (command == "<") |
| 341 | command += "<"; |
| 342 | |
| 343 | text.replace(p, q - p + 1, command); |
| 344 | } |
| 345 | |
| 346 | // Brand user-input -related (tutorial) items with <w>[(text here)]</w>. |
| 347 | while ((p = text.find("<input>")) != string::npos) |
| 348 | { |
| 349 | size_t q = text.find("</input>", p + 7); |
| 350 | if (q == string::npos) |
| 351 | { |
| 352 | text += "<lightred>ERROR: unterminated <input></lightred>"; |
| 353 | break; |
| 354 | } |
| 355 | |
| 356 | string input = text.substr(p + 7, q - p - 7); |
| 357 | input = "<w>[" + input; |
| 358 | input += "]</w>"; |
| 359 | text.replace(p, q - p + 8, input); |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | static void _replace_static_tags(string &text) |
| 364 | { |
no test coverage detected