-
Notifications
You must be signed in to change notification settings - Fork 852
BibTeX: lint #3538
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
base: master
Are you sure you want to change the base?
BibTeX: lint #3538
Conversation
The linter has not been run on this file in ages, because ./lint.sh only lints changes, and the lint rules have gotten a lot stricter in the meantime.
| @@ -48,11 +48,11 @@ function detectImport() { | |||
| var chr = ""; | |||
| var charsRead = 0; | |||
|
|
|||
| var re = /^\s*@[a-zA-Z]+[\(\{]/; | |||
| var re = /^\s*@[a-zA-Z]+[({]/; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were a bunch of regex errors reported. I fixed them all as far as I can tell but REs are touchy. Please take a second look before committing.
| }; | ||
|
|
||
|
|
||
| var strings = {}; | ||
| var keyRe = /[a-zA-Z0-9\-]/; | ||
| var keyRe = /[a-zA-Z0-9-]/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| var newStr = str.replace(/[|<>~^\\{}]/g, function (c) { | ||
| return alwaysMap[c]; | ||
| }) | ||
| .replace(/([#$%&_])/g, "\\$1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
|
||
| var numberRe = /^[0-9]+/; | ||
| // Below is a list of words that should not appear as part of the citation key | ||
| // it includes the indefinite articles of English, German, French and Spanish, as well as a small set of English prepositions whose | ||
| // force is more grammatical than lexical, i.e. which are likely to strike many as 'insignificant'. | ||
| // The assumption is that most who want a title word in their key would prefer the first word of significance. | ||
| // Also remove markup | ||
| var citeKeyTitleBannedRe = /\b(a|an|the|some|from|on|in|to|of|do|with|der|die|das|ein|eine|einer|eines|einem|einen|un|une|la|le|l\'|les|el|las|los|al|uno|una|unos|unas|de|des|del|d\')(\s+|\b)|(<\/?(i|b|sup|sub|sc|span style=\"small-caps\"|span)>)/g; | ||
| var citeKeyTitleBannedRe = /\b(a|an|the|some|from|on|in|to|of|do|with|der|die|das|ein|eine|einer|eines|einem|einen|un|une|la|le|l'|les|el|las|los|al|uno|una|unos|unas|de|des|del|d')(\s+|\b)|(<\/?(i|b|sup|sub|sc|span style="small-caps"|span)>)/g; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| @@ -1316,7 +1405,7 @@ function buildCiteKey (item, extraFields, citekeys) { | |||
|
|
|||
| basekey = tidyAccents(basekey); | |||
| // use legacy pattern for all old items to not break existing usages | |||
| var citeKeyCleanRe = /[^a-z0-9\!\$\&\*\+\-\.\/\:\;\<\>\?\[\]\^\_\`\|]+/g; | |||
| var citeKeyCleanRe = /[^a-z0-9!$&*+\-./:;<>?[\]^_`|]+/g; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
| characters = characters.replace(/\{\\textless}i\{\\textgreater}(.+?)\{\\textless}\/i{\\textgreater}/g, "\\textit{$1}") | ||
| .replace(/\{\\textless}b\{\\textgreater}(.+?)\{\\textless}\/b{\\textgreater}/g, "\\textbf{$1}"); | ||
| //sub and superscript | ||
| characters = characters.replace(/\{\\textless\}sup\{\\textgreater\}(.+?)\{\\textless\}\/sup{\\textgreater\}/g, "\$^{\\textrm{$1}}\$") | ||
| .replace(/\{\\textless\}sub\{\\textgreater\}(.+?)\{\\textless\}\/sub\{\\textgreater\}/g, "\$_{\\textrm{$1}}\$"); | ||
| characters = characters.replace(/\{\\textless}sup\{\\textgreater}(.+?)\{\\textless}\/sup{\\textgreater}/g, "$^{\\textrm{$1}}$") | ||
| .replace(/\{\\textless}sub\{\\textgreater}(.+?)\{\\textless}\/sub\{\\textgreater}/g, "$_{\\textrm{$1}}$"); | ||
| //two variants of small caps | ||
| characters = characters.replace(/\{\\textless\}span\sstyle=\"small\-caps\"\{\\textgreater\}(.+?)\{\\textless\}\/span{\\textgreater\}/g, "\\textsc{$1}") | ||
| .replace(/\{\\textless\}sc\{\\textgreater\}(.+?)\{\\textless\}\/sc\{\\textgreater\}/g, "\\textsc{$1}"); | ||
| characters = characters.replace(/\{\\textless}span\sstyle="small-caps"\{\\textgreater}(.+?)\{\\textless}\/span{\\textgreater}/g, "\\textsc{$1}") | ||
| .replace(/\{\\textless}sc\{\\textgreater}(.+?)\{\\textless}\/sc\{\\textgreater}/g, "\\textsc{$1}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
especially check this block
| tex = tex.replace(/\\textit\{([^}]+})/g, "<i>$1</i>").replace(/\\textbf\{([^}]+})/g, "<b>$1</b>"); | ||
| //two versions of subscript the .* after $ is necessary because people m | ||
| tex = tex.replace(/\$([^\{\$]*)_\{([^\}]+)\}\$/g, sub).replace(/\$([^\{\$]*)_\{\\textrm\{([^\}\$]+)\}\}\$/g, sub); | ||
| tex = tex.replace(/\$([^{$]*)_\{([^}]+)}\$/g, sub).replace(/\$([^{$]*)_\{\\textrm\{([^}$]+)}}\$/g, sub); | ||
| //two version of superscript | ||
| tex = tex.replace(/\$([^\{\$]*)\^\{([^\}]+)\}\$/g, sup).replace(/\$([^\{\$]*)\^\{\\textrm\{([^\}]+)\}\}\$/g, sup); | ||
| tex = tex.replace(/\$([^{$]*)\^\{([^}]+)}\$/g, sup).replace(/\$([^{$]*)\^\{\\textrm\{([^}]+)}}\$/g, sup); | ||
| //small caps | ||
| tex = tex.replace(/\\textsc\{([^\}]+)/g, "<span style=\"small-caps\">$1</span>"); | ||
| tex = tex.replace(/\\textsc\{([^}]+)/g, "<span style=\"small-caps\">$1</span>"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and these
| // // XXX this code seems unmaintained? jabrefMap is not defined anywhere. | ||
| // if (parentCollection && record.intersection == '1') { // intersection with parent | ||
| // collection.children = jabrefMap(collection.children, function (n) { | ||
| // parentCollection.includes(n); | ||
| // }); | ||
| // } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jabrefMap is not defined. 58b257f mentioned this already, but I guess it wasn't a hard error then. Now it is.
I don't know what it's for so I took it out, but it should be fixed properly. Help me please ?
The linter has not been run on this file in ages, because ./lint.sh only lints changes, and the lint rules have gotten a lot stricter in the meantime.