summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbscan <10503608+bscan@users.noreply.github.com>2023-10-29 16:11:28 -0400
committerGitHub <noreply@github.com>2023-10-29 16:11:28 -0400
commitf27a20640166a964558994857bfba5713db4f50a (patch)
tree0fc2613fbd29d086898c5945c6f6ab04da3bec38
parent3baaa6fbadaa6e2ccb4ea374deaf0cf54948d4a2 (diff)
parent9aceef7490c25817a98b7c86600963e87449a4c1 (diff)
downloadPerlNavigator-f27a20640166a964558994857bfba5713db4f50a.zip
Merge pull request #101 from IAKOBVS/main
pod.ts: reduce regex usage
-rw-r--r--server/src/pod.ts7
1 files changed, 4 insertions, 3 deletions
diff --git a/server/src/pod.ts b/server/src/pod.ts
index 02ad259..8e0efdb 100644
--- a/server/src/pod.ts
+++ b/server/src/pod.ts
@@ -33,7 +33,7 @@ export async function getPod(elem: PerlElem, perlDoc: PerlDocument): Promise<str
// Split the file into lines and iterate through them
const lines = fileContent.split("\n");
for (const line of lines) {
- if (line.match(/^=cut/)) {
+ if (line.startsWith("=cut")) {
// =cut lines are not added.
inPodBlock = false;
}
@@ -227,7 +227,8 @@ const processList = (line: string, state: ConversionState): ConversionState => {
// Remove the '=item' part to get the actual text for the list item.
let listItem = line.substring(6).trim();
- listItem = listItem.replace(/^\* /," "); // Doubled up list identifiers
+ if (listItem.startsWith("* ")) // Doubled up list identifiers
+ listItem = listItem.replace("*", "");
markdown = `\n- ${listItem} \n `; // Unordered list
}
// The =back command ends the list.
@@ -324,7 +325,7 @@ const tempPlaceholder = '\uFFFF';
const processInlineElements = (line: string): string => {
- line = line.replace(/`/g, tempPlaceholder);
+ line = line.replaceAll('`', tempPlaceholder);
// Handle code (C<code>), while allowing E<> replacements
line = line.replace(/C<((?:[^<>]|[EL]<[^<>]+>)+?)>/g, (match, code) => escapeBackticks(code));