HumanReadableLogsRules.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /* eslint-disable no-useless-escape */
  2. import packageSuggestions from './HumanReadableLogsPackageSuggestions'
  3. const rules = [
  4. {
  5. ruleId: 'hint_misplaced_alignment_tab_character',
  6. regexToMatch: /Misplaced alignment tab character \&/,
  7. },
  8. {
  9. ruleId: 'hint_extra_alignment_tab_has_been_changed',
  10. regexToMatch: /Extra alignment tab has been changed to \\cr/,
  11. },
  12. {
  13. ruleId: 'hint_display_math_should_end_with',
  14. regexToMatch: /Display math should end with \$\$/,
  15. },
  16. {
  17. ruleId: 'hint_missing_inserted',
  18. regexToMatch: /Missing [{$] inserted./,
  19. },
  20. {
  21. ruleId: 'hint_reference_undefined',
  22. regexToMatch: /Reference.+undefined/,
  23. },
  24. {
  25. ruleId: 'hint_there_were_undefined_references',
  26. regexToMatch: /There were undefined references/,
  27. },
  28. {
  29. ruleId: 'hint_citation_on_page_undefined_on_input_line',
  30. regexToMatch: /Citation .+ on page .+ undefined on input line .+/,
  31. },
  32. {
  33. ruleId: 'hint_label_multiply_defined_labels',
  34. regexToMatch: /(Label .+)? multiply[ -]defined( labels)?/,
  35. },
  36. {
  37. ruleId: 'hint_float_specifier_changed',
  38. regexToMatch: /`!?h' float specifier changed to `!?ht'/,
  39. },
  40. {
  41. ruleId: 'hint_no_positions_in_optional_float_specifier',
  42. regexToMatch: /No positions in optional float specifier/,
  43. },
  44. {
  45. ruleId: 'hint_undefined_control_sequence',
  46. regexToMatch: /Undefined control sequence/,
  47. contentRegex:
  48. /^(?:l\.[0-9]+|<(?:recently read|inserted text|to be read again)>)\s*(\\\S+)/,
  49. improvedTitle: (currentTitle, details) => {
  50. if (details?.length && packageSuggestions.has(details[0])) {
  51. const command = details[0]
  52. const suggestion = packageSuggestions.get(command)
  53. return `${suggestion.command} is missing.`
  54. }
  55. return currentTitle
  56. },
  57. },
  58. {
  59. ruleId: 'hint_file_not_found',
  60. regexToMatch: /File .+ not found/,
  61. },
  62. {
  63. ruleId: 'hint_unknown_graphics_extension',
  64. regexToMatch: /LaTeX Error: Unknown graphics extension: \..+/,
  65. },
  66. {
  67. ruleId: 'hint_unknown_float_option_h',
  68. regexToMatch: /LaTeX Error: Unknown float option `H'/,
  69. },
  70. {
  71. ruleId: 'hint_unknown_float_option_q',
  72. regexToMatch: /LaTeX Error: Unknown float option `q'/,
  73. },
  74. {
  75. ruleId: 'hint_math_allowed_only_in_math_mode',
  76. regexToMatch: /LaTeX Error: \\math.+ allowed only in math mode/,
  77. },
  78. {
  79. ruleId: 'hint_mismatched_environment',
  80. types: ['environment'],
  81. regexToMatch: /Error: `([^']{2,})' expected, found `([^']{2,})'.*/,
  82. newMessage: 'Error: environment does not match \\begin{$1} ... \\end{$2}',
  83. },
  84. {
  85. ruleId: 'hint_mismatched_brackets',
  86. types: ['environment'],
  87. regexToMatch: /Error: `([^a-zA-Z0-9])' expected, found `([^a-zA-Z0-9])'.*/,
  88. newMessage: "Error: brackets do not match, found '$2' instead of '$1'",
  89. },
  90. {
  91. ruleId: 'hint_can_be_used_only_in_preamble',
  92. regexToMatch: /LaTeX Error: Can be used only in preamble/,
  93. },
  94. {
  95. ruleId: 'hint_missing_right_inserted',
  96. regexToMatch: /Missing \\right inserted/,
  97. },
  98. {
  99. ruleId: 'hint_double_superscript',
  100. regexToMatch: /Double superscript/,
  101. },
  102. {
  103. ruleId: 'hint_double_subscript',
  104. regexToMatch: /Double subscript/,
  105. },
  106. {
  107. ruleId: 'hint_no_author_given',
  108. regexToMatch: /No \\author given/,
  109. },
  110. {
  111. ruleId: 'hint_environment_undefined',
  112. regexToMatch: /LaTeX Error: Environment .+ undefined/,
  113. },
  114. {
  115. ruleId: 'hint_somethings_wrong_perhaps_a_missing_item',
  116. regexToMatch: /LaTeX Error: Something's wrong--perhaps a missing \\item/,
  117. },
  118. {
  119. ruleId: 'hint_misplaced_noalign',
  120. regexToMatch: /Misplaced \\noalign/,
  121. },
  122. {
  123. ruleId: 'hint_no_line_here_to_end',
  124. regexToMatch: /LaTeX Error: There's no line here to end/,
  125. },
  126. {
  127. ruleId: 'hint_verb_ended_by_end_of_line',
  128. regexToMatch: /LaTeX Error: \\verb ended by end of line/,
  129. },
  130. {
  131. ruleId: 'hint_illegal_unit_of_measure_pt_inserted',
  132. regexToMatch: /Illegal unit of measure (pt inserted)/,
  133. },
  134. {
  135. ruleId: 'hint_extra_right',
  136. regexToMatch: /Extra \\right/,
  137. },
  138. {
  139. ruleId: 'hint_missing_begin_document_',
  140. regexToMatch: /Missing \\begin{document}/,
  141. },
  142. {
  143. ruleId: 'hint_mismatched_environment2',
  144. types: ['environment'],
  145. cascadesFrom: ['environment'],
  146. regexToMatch:
  147. /Error: `\\end\{([^\}]+)\}' expected but found `\\end\{([^\}]+)\}'.*/,
  148. newMessage: 'Error: environments do not match: \\begin{$1} ... \\end{$2}',
  149. },
  150. {
  151. ruleId: 'hint_mismatched_environment3',
  152. types: ['environment'],
  153. cascadesFrom: ['environment'],
  154. regexToMatch:
  155. /Warning: No matching \\end found for `\\begin\{([^\}]+)\}'.*/,
  156. newMessage: 'Warning: No matching \\end found for \\begin{$1}',
  157. },
  158. {
  159. ruleId: 'hint_mismatched_environment4',
  160. types: ['environment'],
  161. cascadesFrom: ['environment'],
  162. regexToMatch:
  163. /Error: Found `\\end\{([^\}]+)\}' without corresponding \\begin.*/,
  164. newMessage: 'Error: found \\end{$1} without a corresponding \\begin{$1}',
  165. },
  166. ]
  167. export default rules