diff options
author | bscan <10503608+bscan@users.noreply.github.com> | 2023-11-22 18:53:11 -0500 |
---|---|---|
committer | bscan <10503608+bscan@users.noreply.github.com> | 2023-11-22 18:53:11 -0500 |
commit | 657233d12b10add618c802277ff5ca8d6a3f8d47 (patch) | |
tree | b18e2f1c5b9c50e8a07df10359b28f0c245bd02c | |
parent | 2dc2bae31842144a11f0b4d555d6a3b8969801de (diff) | |
download | PerlNavigator-657233d12b10add618c802277ff5ca8d6a3f8d47.zip |
Remove trailing spaces from certain POD formats
-rw-r--r-- | server/src/pod.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/server/src/pod.ts b/server/src/pod.ts index 3c5d9a3..f4a9596 100644 --- a/server/src/pod.ts +++ b/server/src/pod.ts @@ -39,8 +39,14 @@ export async function getPod(elem: PerlElem, perlDoc: PerlDocument, modMap: Map< // These regexes are painful, but I didn't want to mix this with the line-by-line POD parsing which would overcomplicate that piece let match, match2; if(searchItem && (match = fileContent.match(`\\r?\\n#(?:####+| \-+) *(?:\\r?\\n# *)*${searchItem}\\r?\\n((?:(?:#.*| *)\\r?\\n)+)sub +${searchItem}\\b`))){ - if(!( (match2 = searchItem.match(/^get_(\w+)$/)) && match[1].match(new RegExp(`^(?:# +set_${match2[1]}\\r?\\n)?[\\s#]*$`)))) - markdown += "```text\n" + match[1].replace(/^ *#+ ?/gm,'') + "\n```\n" + // Ensure it's not an empty get/set pair. + if(!( (match2 = searchItem.match(/^get_(\w+)$/)) && match[1].match(new RegExp(`^(?:# +set_${match2[1]}\\r?\\n)?[\\s#]*$`)))){ + let content = match[1].replace(/^ *#+ ?/gm,''); + content = content.replace(/^\s+|\s+$/g,''); + if(content){ // It may still be empty for non-get functions + markdown += "```text\n" + content + "\n```\n" + } + } } // Split the file into lines and iterate through them |