HumanReadableLogsRules.js 5.5 KB

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