HumanReadableLogsRules.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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: /^l\.[0-9]+\s*(\\\S+)/,
  48. improvedTitle: (currentTitle, details) => {
  49. if (details?.length && packageSuggestions.has(details[0])) {
  50. const command = details[0]
  51. const suggestion = packageSuggestions.get(command)
  52. return `${suggestion.command} is missing.`
  53. }
  54. return currentTitle
  55. },
  56. },
  57. {
  58. ruleId: 'hint_file_not_found',
  59. regexToMatch: /File .+ not found/,
  60. },
  61. {
  62. ruleId: 'hint_unknown_graphics_extension',
  63. regexToMatch: /LaTeX Error: Unknown graphics extension: \..+/,
  64. },
  65. {
  66. ruleId: 'hint_unknown_float_option_h',
  67. regexToMatch: /LaTeX Error: Unknown float option `H'/,
  68. },
  69. {
  70. ruleId: 'hint_unknown_float_option_q',
  71. regexToMatch: /LaTeX Error: Unknown float option `q'/,
  72. },
  73. {
  74. ruleId: 'hint_math_allowed_only_in_math_mode',
  75. regexToMatch: /LaTeX Error: \\math.+ allowed only in math mode/,
  76. },
  77. {
  78. ruleId: 'hint_mismatched_environment',
  79. types: ['environment'],
  80. regexToMatch: /Error: `([^']{2,})' expected, found `([^']{2,})'.*/,
  81. newMessage: 'Error: environment does not match \\begin{$1} ... \\end{$2}',
  82. },
  83. {
  84. ruleId: 'hint_mismatched_brackets',
  85. types: ['environment'],
  86. regexToMatch: /Error: `([^a-zA-Z0-9])' expected, found `([^a-zA-Z0-9])'.*/,
  87. newMessage: "Error: brackets do not match, found '$2' instead of '$1'",
  88. },
  89. {
  90. ruleId: 'hint_can_be_used_only_in_preamble',
  91. regexToMatch: /LaTeX Error: Can be used only in preamble/,
  92. },
  93. {
  94. ruleId: 'hint_missing_right_inserted',
  95. regexToMatch: /Missing \\right inserted/,
  96. },
  97. {
  98. ruleId: 'hint_double_superscript',
  99. regexToMatch: /Double superscript/,
  100. },
  101. {
  102. ruleId: 'hint_double_subscript',
  103. regexToMatch: /Double subscript/,
  104. },
  105. {
  106. ruleId: 'hint_no_author_given',
  107. regexToMatch: /No \\author given/,
  108. },
  109. {
  110. ruleId: 'hint_environment_undefined',
  111. regexToMatch: /LaTeX Error: Environment .+ undefined/,
  112. },
  113. {
  114. ruleId: 'hint_somethings_wrong_perhaps_a_missing_item',
  115. regexToMatch: /LaTeX Error: Something's wrong--perhaps a missing \\item/,
  116. },
  117. {
  118. ruleId: 'hint_misplaced_noalign',
  119. regexToMatch: /Misplaced \\noalign/,
  120. },
  121. {
  122. ruleId: 'hint_no_line_here_to_end',
  123. regexToMatch: /LaTeX Error: There's no line here to end/,
  124. },
  125. {
  126. ruleId: 'hint_verb_ended_by_end_of_line',
  127. regexToMatch: /LaTeX Error: \\verb ended by end of line/,
  128. },
  129. {
  130. ruleId: 'hint_illegal_unit_of_measure_pt_inserted',
  131. regexToMatch: /Illegal unit of measure (pt inserted)/,
  132. },
  133. {
  134. ruleId: 'hint_extra_right',
  135. regexToMatch: /Extra \\right/,
  136. },
  137. {
  138. ruleId: 'hint_missing_begin_document_',
  139. regexToMatch: /Missing \\begin{document}/,
  140. },
  141. {
  142. ruleId: 'hint_mismatched_environment2',
  143. types: ['environment'],
  144. cascadesFrom: ['environment'],
  145. regexToMatch:
  146. /Error: `\\end\{([^\}]+)\}' expected but found `\\end\{([^\}]+)\}'.*/,
  147. newMessage: 'Error: environments do not match: \\begin{$1} ... \\end{$2}',
  148. },
  149. {
  150. ruleId: 'hint_mismatched_environment3',
  151. types: ['environment'],
  152. cascadesFrom: ['environment'],
  153. regexToMatch:
  154. /Warning: No matching \\end found for `\\begin\{([^\}]+)\}'.*/,
  155. newMessage: 'Warning: No matching \\end found for \\begin{$1}',
  156. },
  157. {
  158. ruleId: 'hint_mismatched_environment4',
  159. types: ['environment'],
  160. cascadesFrom: ['environment'],
  161. regexToMatch:
  162. /Error: Found `\\end\{([^\}]+)\}' without corresponding \\begin.*/,
  163. newMessage: 'Error: found \\end{$1} without a corresponding \\begin{$1}',
  164. },
  165. ]
  166. export default rules