Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the types parser regex #13

Closed
synw opened this issue Mar 26, 2023 · 0 comments
Closed

Fix the types parser regex #13

synw opened this issue Mar 26, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@synw
Copy link
Owner

synw commented Mar 26, 2023

We have an option to declare and parse the types (undocumented yet). The principle: the user declares his type links in a public/doc/type_urls.json file like here. This file is used to parse the docstrings to search for types and replace them by a regex using this function

function linkType(data, typename, typelink) {
  const regex = new RegExp(`(?<!<\\/a>|'\\)")(\\b${typename}\\b)`, 'g');
  const replacement = `<a href="javascript:openLink(\'${typelink}\')">${typename}</a>`;
  return data.replace(regex, replacement);
}

The regex is currently broken: it works on the first pass and transforms the found types into links correctly. But on the second pass it does not detect correctly the already linked types and relink them, breaking the html

[Edit]: to parse the types run the docnav command with a -t flag

@synw synw added the bug Something isn't working label Mar 26, 2023
@synw synw closed this as completed Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant