HumanReadableLogsRules.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558
  1. /* eslint-disable no-useless-escape */
  2. import PropTypes from 'prop-types'
  3. function WikiLink({ url, children }) {
  4. return window.wikiEnabled ? (
  5. <a href={url} target="_blank">
  6. {children}
  7. </a>
  8. ) : (
  9. <>{children}</>
  10. )
  11. }
  12. WikiLink.propTypes = {
  13. url: PropTypes.string,
  14. children: PropTypes.node.isRequired,
  15. }
  16. const rules = [
  17. {
  18. regexToMatch: /Misplaced alignment tab character \&/,
  19. extraInfoURL:
  20. 'https://www.overleaf.com/learn/Errors/Misplaced_alignment_tab_character_%26',
  21. humanReadableHintComponent: (
  22. <>
  23. You have placed an alignment tab character '&' in the wrong place. If
  24. you want to align something, you must write it inside an align
  25. environment such as \begin
  26. {'{align}'} … \end
  27. {'{align}'}, \begin
  28. {'{tabular}'} … \end
  29. {'{tabular}'}, etc. If you want to write an ampersand '&' in text, you
  30. must write \& instead.
  31. </>
  32. ),
  33. humanReadableHint:
  34. 'You have placed an alignment tab character &#x27;&amp;&#x27; in the wrong place. If you want to align something, you must write it inside an align environment such as \\begin{align} … \\end{align}, \\begin{tabular} … \\end{tabular}, etc. If you want to write an ampersand &#x27;&amp;&#x27; in text, you must write \\&amp; instead.',
  35. },
  36. {
  37. regexToMatch: /Extra alignment tab has been changed to \\cr/,
  38. extraInfoURL:
  39. 'https://www.overleaf.com/learn/Errors/Extra_alignment_tab_has_been_changed_to_%5Ccr',
  40. humanReadableHintComponent: (
  41. <>
  42. You have written too many alignment tabs in a table, causing one of them
  43. to be turned into a line break. Make sure you have specified the correct
  44. number of columns in your{' '}
  45. <WikiLink url="https://www.overleaf.com/learn/Tables">table</WikiLink>.
  46. </>
  47. ),
  48. humanReadableHint:
  49. 'You have written too many alignment tabs in a table, causing one of them to be turned into a line break. Make sure you have specified the correct number of columns in your <a href="https://www.overleaf.com/learn/Tables" target="_blank">table</a>.',
  50. },
  51. {
  52. regexToMatch: /Display math should end with \$\$/,
  53. extraInfoURL:
  54. 'https://www.overleaf.com/learn/Errors/Display_math_should_end_with_$$',
  55. humanReadableHintComponent: (
  56. <>
  57. You have forgotten a $ sign at the end of 'display math' mode. When
  58. writing in display math mode, you must always math write inside $$ … $$.
  59. Check that the number of $s match around each math expression.
  60. </>
  61. ),
  62. humanReadableHint:
  63. 'You have forgotten a $ sign at the end of &#x27;display math&#x27; mode. When writing in display math mode, you must always math write inside $$ … $$. Check that the number of $s match around each math expression.',
  64. },
  65. {
  66. regexToMatch: /Missing [{$] inserted./,
  67. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Missing_$_inserted',
  68. humanReadableHintComponent: (
  69. <>
  70. Check that your $'s match around math expressions. If they do, then
  71. you've probably used a symbol in normal text that needs to be in math
  72. mode. Symbols such as subscripts ( _ ), integrals ( \int ), Greek
  73. letters ( \alpha, \beta, \delta ), and modifiers (\vec
  74. {'{x}'}, \tilde
  75. {'{x}'} ) must be written in math mode. See the full list{' '}
  76. <WikiLink url="https://www.overleaf.com/learn/Errors/Missing_$_inserted">
  77. here
  78. </WikiLink>
  79. . If you intended to use mathematics mode, then use $ … $ for 'inline
  80. math mode', $$ … $$ for 'display math mode' or alternatively \begin
  81. {'{math}'} … \end
  82. {'{math}'}.
  83. </>
  84. ),
  85. humanReadableHint:
  86. 'Check that your $&#x27;s match around math expressions. If they do, then you&#x27;ve probably used a symbol in normal text that needs to be in math mode. Symbols such as subscripts ( _ ), integrals ( \\int ), Greek letters ( \\alpha, \\beta, \\delta ), and modifiers (\\vec{x}, \\tilde{x} ) must be written in math mode. See the full list <a href="https://www.overleaf.com/learn/Errors/Missing_$_inserted" target="_blank">here</a>. If you intended to use mathematics mode, then use $ … $ for &#x27;inline math mode&#x27;, $$ … $$ for &#x27;display math mode&#x27; or alternatively \\begin{math} … \\end{math}.',
  87. },
  88. {
  89. regexToMatch: /(undefined )?[rR]eference(s)?.+(undefined)?/,
  90. extraInfoURL:
  91. 'https://www.overleaf.com/learn/Errors/There_were_undefined_references',
  92. humanReadableHintComponent: (
  93. <>
  94. You have referenced something which has not yet been labelled. If you
  95. have labelled it already, make sure that what is written inside \ref
  96. {'{...}'} is the same as what is written inside \label
  97. {'{...}'}.
  98. </>
  99. ),
  100. humanReadableHint:
  101. 'You have referenced something which has not yet been labelled. If you have labelled it already, make sure that what is written inside \\ref{...} is the same as what is written inside \\label{...}.',
  102. },
  103. {
  104. regexToMatch: /Citation .+ on page .+ undefined on input line .+/,
  105. extraInfoURL:
  106. 'https://www.overleaf.com/learn/Errors/Citation_XXX_on_page_XXX_undefined_on_input_line_XXX',
  107. humanReadableHintComponent: (
  108. <>
  109. You have cited something which is not included in your bibliography.
  110. Make sure that the citation (\cite
  111. {'{...}'}) has a corresponding key in your bibliography, and that both
  112. are spelled the same way.
  113. </>
  114. ),
  115. humanReadableHint:
  116. 'You have cited something which is not included in your bibliography. Make sure that the citation (\\cite{...}) has a corresponding key in your bibliography, and that both are spelled the same way.',
  117. },
  118. {
  119. regexToMatch: /(Label .+)? multiply[ -]defined( labels)?/,
  120. extraInfoURL:
  121. 'https://www.overleaf.com/learn/Errors/There_were_multiply-defined_labels',
  122. humanReadableHintComponent: (
  123. <>
  124. You have used the same label more than once. Check that each \label
  125. {'{...}'} labels only one item.
  126. </>
  127. ),
  128. humanReadableHint:
  129. 'You have used the same label more than once. Check that each \\label{...} labels only one item.',
  130. },
  131. {
  132. regexToMatch: /`!?h' float specifier changed to `!?ht'/,
  133. extraInfoURL:
  134. 'https://www.overleaf.com/learn/Errors/%60!h%27_float_specifier_changed_to_%60!ht%27',
  135. humanReadableHintComponent: (
  136. <>
  137. The float specifier 'h' is too strict of a demand for LaTeX to place
  138. your float in a nice way here. Try relaxing it by using 'ht', or even
  139. 'htbp' if necessary. If you want to try keep the float here anyway,
  140. check out the{' '}
  141. <WikiLink url="https://www.overleaf.com/learn/Positioning_of_Figures">
  142. float package
  143. </WikiLink>
  144. .
  145. </>
  146. ),
  147. humanReadableHint:
  148. 'The float specifier &#x27;h&#x27; is too strict of a demand for LaTeX to place your float in a nice way here. Try relaxing it by using &#x27;ht&#x27;, or even &#x27;htbp&#x27; if necessary. If you want to try keep the float here anyway, check out the <a href="https://www.overleaf.com/learn/Positioning_of_Figures" target="_blank">float package</a>.',
  149. },
  150. {
  151. regexToMatch: /No positions in optional float specifier/,
  152. extraInfoURL:
  153. 'https://www.overleaf.com/learn/Errors/No_positions_in_optional_float_specifier',
  154. humanReadableHintComponent: (
  155. <>
  156. You have forgotten to include a float specifier, which tells LaTeX where
  157. to position your figure. To fix this, either insert a float specifier
  158. inside the square brackets (e.g. \begin
  159. {'{figure}'}
  160. [h]), or remove the square brackets (e.g. \begin
  161. {'{figure}'}
  162. ). Find out more about float specifiers{' '}
  163. <WikiLink url="https://www.overleaf.com/learn/Positioning_of_Figures">
  164. here
  165. </WikiLink>
  166. .
  167. </>
  168. ),
  169. humanReadableHint:
  170. 'You have forgotten to include a float specifier, which tells LaTeX where to position your figure. To fix this, either insert a float specifier inside the square brackets (e.g. \\begin{figure}[h]), or remove the square brackets (e.g. \\begin{figure}). Find out more about float specifiers <a href="https://www.overleaf.com/learn/Positioning_of_Figures" target="_blank">here</a>.',
  171. },
  172. {
  173. regexToMatch: /Undefined control sequence/,
  174. extraInfoURL:
  175. 'https://www.overleaf.com/learn/Errors/Undefined_control_sequence',
  176. humanReadableHintComponent: (
  177. <>
  178. The compiler is having trouble understanding a command you have used.
  179. Check that the command is spelled correctly. If the command is part of a
  180. package, make sure you have included the package in your preamble using
  181. \usepackage
  182. {'{...}'}.
  183. </>
  184. ),
  185. humanReadableHint:
  186. 'The compiler is having trouble understanding a command you have used. Check that the command is spelled correctly. If the command is part of a package, make sure you have included the package in your preamble using \\usepackage{...}.',
  187. },
  188. {
  189. regexToMatch: /File .+ not found/,
  190. extraInfoURL:
  191. 'https://www.overleaf.com/learn/Errors/File_XXX_not_found_on_input_line_XXX',
  192. humanReadableHintComponent: (
  193. <>
  194. The compiler cannot find the file you want to include. Make sure that
  195. you have{' '}
  196. <WikiLink url="https://www.overleaf.com/learn/Including_images_in_ShareLaTeX">
  197. uploaded the file
  198. </WikiLink>{' '}
  199. and{' '}
  200. <WikiLink url="https://www.overleaf.com/learn/Errors/File_XXX_not_found_on_input_line_XXX.">
  201. specified the file location correctly
  202. </WikiLink>
  203. .
  204. </>
  205. ),
  206. humanReadableHint:
  207. 'The compiler cannot find the file you want to include. Make sure that you have <a href="https://www.overleaf.com/learn/Including_images_in_ShareLaTeX" target="_blank">uploaded the file</a> and <a href="https://www.overleaf.com/learn/Errors/File_XXX_not_found_on_input_line_XXX." target="_blank">specified the file location correctly</a>.',
  208. },
  209. {
  210. regexToMatch: /LaTeX Error: Unknown graphics extension: \..+/,
  211. extraInfoURL:
  212. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Unknown_graphics_extension:_.XXX',
  213. humanReadableHintComponent: (
  214. <>
  215. The compiler does not recognise the file type of one of your images.
  216. Make sure you are using a{' '}
  217. <WikiLink url="https://www.overleaf.com/learn/Errors/LaTeX_Error:_Unknown_graphics_extension:_.gif.">
  218. supported image format
  219. </WikiLink>{' '}
  220. for your choice of compiler, and check that there are no periods (.) in
  221. the name of your image.
  222. </>
  223. ),
  224. humanReadableHint:
  225. 'The compiler does not recognise the file type of one of your images. Make sure you are using a <a href="https://www.overleaf.com/learn/Errors/LaTeX_Error:_Unknown_graphics_extension:_.gif." target="_blank">supported image format</a> for your choice of compiler, and check that there are no periods (.) in the name of your image.',
  226. },
  227. {
  228. regexToMatch: /LaTeX Error: Unknown float option `H'/,
  229. extraInfoURL:
  230. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Unknown_float_option_%60H%27',
  231. humanReadableHintComponent: (
  232. <>
  233. The compiler isn't recognizing the float option 'H'. Include \usepackage
  234. {'{float}'} in your preamble to fix this.
  235. </>
  236. ),
  237. humanReadableHint:
  238. 'The compiler isn&#x27;t recognizing the float option &#x27;H&#x27;. Include \\usepackage{float} in your preamble to fix this.',
  239. },
  240. {
  241. regexToMatch: /LaTeX Error: Unknown float option `q'/,
  242. extraInfoURL:
  243. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Unknown_float_option_%60q%27',
  244. humanReadableHintComponent: (
  245. <>
  246. You have used a float specifier which the compiler does not understand.
  247. You can learn more about the different float options available for
  248. placing figures{' '}
  249. <WikiLink url="https://www.overleaf.com/learn/Positioning_of_Figures">
  250. here
  251. </WikiLink>{' '}
  252. .
  253. </>
  254. ),
  255. humanReadableHint:
  256. 'You have used a float specifier which the compiler does not understand. You can learn more about the different float options available for placing figures <a href="https://www.overleaf.com/learn/Positioning_of_Figures" target="_blank">here</a> .',
  257. },
  258. {
  259. regexToMatch: /LaTeX Error: \\math.+ allowed only in math mode/,
  260. extraInfoURL:
  261. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_%5Cmathrm_allowed_only_in_math_mode',
  262. humanReadableHintComponent: (
  263. <>
  264. You have used a font command which is only available in math mode. To
  265. use this command, you must be in maths mode (E.g. $ … $ or \begin
  266. {'{math}'} … \end
  267. {'{math}'}
  268. ). If you want to use it outside of math mode, use the text version
  269. instead: \textrm, \textit, etc.
  270. </>
  271. ),
  272. humanReadableHint:
  273. 'You have used a font command which is only available in math mode. To use this command, you must be in maths mode (E.g. $ … $ or \\begin{math} … \\end{math}). If you want to use it outside of math mode, use the text version instead: \\textrm, \\textit, etc.',
  274. },
  275. {
  276. ruleId: 'hint_mismatched_environment',
  277. types: ['environment'],
  278. regexToMatch: /Error: `([^']{2,})' expected, found `([^']{2,})'.*/,
  279. newMessage: 'Error: environment does not match \\begin{$1} ... \\end{$2}',
  280. humanReadableHintComponent: (
  281. <>
  282. You have used \begin
  283. {'{...}'} without a corresponding \end
  284. {'{...}'}.
  285. </>
  286. ),
  287. humanReadableHint:
  288. 'You have used \\begin{...} without a corresponding \\end{...}.',
  289. },
  290. {
  291. ruleId: 'hint_mismatched_brackets',
  292. types: ['environment'],
  293. regexToMatch: /Error: `([^a-zA-Z0-9])' expected, found `([^a-zA-Z0-9])'.*/,
  294. newMessage: "Error: brackets do not match, found '$2' instead of '$1'",
  295. humanReadableHintComponent: (
  296. <>You have used an open bracket without a corresponding close bracket.</>
  297. ),
  298. humanReadableHint:
  299. 'You have used an open bracket without a corresponding close bracket.',
  300. },
  301. {
  302. regexToMatch: /LaTeX Error: Can be used only in preamble/,
  303. extraInfoURL:
  304. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Can_be_used_only_in_preamble',
  305. humanReadableHintComponent: (
  306. <>
  307. You have used a command in the main body of your document which should
  308. be used in the preamble. Make sure that \documentclass[…]
  309. {'{…}'} and all \usepackage
  310. {'{…}'} commands are written before \begin
  311. {'{document}'}.
  312. </>
  313. ),
  314. humanReadableHint:
  315. 'You have used a command in the main body of your document which should be used in the preamble. Make sure that \\documentclass[…]{…} and all \\usepackage{…} commands are written before \\begin{document}.',
  316. },
  317. {
  318. regexToMatch: /Missing \\right inserted/,
  319. extraInfoURL:
  320. 'https://www.overleaf.com/learn/Errors/Missing_%5Cright_insertede',
  321. humanReadableHintComponent: (
  322. <>
  323. You have started an expression with a \left command, but have not
  324. included a corresponding \right command. Make sure that your \left and
  325. \right commands balance everywhere, or else try using \Biggl and \Biggr
  326. commands instead as shown{' '}
  327. <WikiLink url="https://www.overleaf.com/learn/Errors/Missing_%5Cright_inserted">
  328. here
  329. </WikiLink>
  330. .
  331. </>
  332. ),
  333. humanReadableHint:
  334. 'You have started an expression with a \\left command, but have not included a corresponding \\right command. Make sure that your \\left and \\right commands balance everywhere, or else try using \\Biggl and \\Biggr commands instead as shown <a href="https://www.overleaf.com/learn/Errors/Missing_%5Cright_inserted" target="_blank">here</a>.',
  335. },
  336. {
  337. regexToMatch: /Double superscript/,
  338. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Double_superscript',
  339. humanReadableHintComponent: (
  340. <>
  341. You have written a double superscript incorrectly as a^b^c, or else you
  342. have written a prime with a superscript. Remember to include {'{and}'}{' '}
  343. when using multiple superscripts. Try a^
  344. {'{b ^ c}'} instead.
  345. </>
  346. ),
  347. humanReadableHint:
  348. 'You have written a double superscript incorrectly as a^b^c, or else you have written a prime with a superscript. Remember to include {and} when using multiple superscripts. Try a^{b ^ c} instead.',
  349. },
  350. {
  351. regexToMatch: /Double subscript/,
  352. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Double_subscript',
  353. humanReadableHintComponent: (
  354. <>
  355. You have written a double subscript incorrectly as a_b_c. Remember to
  356. include {'{and}'} when using multiple subscripts. Try a_
  357. {'{b_c}'} instead.
  358. </>
  359. ),
  360. humanReadableHint:
  361. 'You have written a double subscript incorrectly as a_b_c. Remember to include {and} when using multiple subscripts. Try a_{b_c} instead.',
  362. },
  363. {
  364. regexToMatch: /No \\author given/,
  365. extraInfoURL: 'https://www.overleaf.com/learn/Errors/No_%5Cauthor_given',
  366. humanReadableHintComponent: (
  367. <>
  368. You have used the \maketitle command, but have not specified any
  369. \author. To fix this, include an author in your preamble using the
  370. \author
  371. {'{…}'} command.
  372. </>
  373. ),
  374. humanReadableHint:
  375. 'You have used the \\maketitle command, but have not specified any \\author. To fix this, include an author in your preamble using the \\author{…} command.',
  376. },
  377. {
  378. regexToMatch: /LaTeX Error: Environment .+ undefined/,
  379. extraInfoURL:
  380. 'https://www.overleaf.com/learn/Errors%2FLaTeX%20Error%3A%20Environment%20XXX%20undefined',
  381. humanReadableHintComponent: (
  382. <>
  383. You have created an environment (using \begin
  384. {'{…}'} and \end
  385. {'{…}'} commands) which is not recognized. Make sure you have included
  386. the required package for that environment in your preamble, and that the
  387. environment is spelled correctly.
  388. </>
  389. ),
  390. humanReadableHint:
  391. 'You have created an environment (using \\begin{…} and \\end{…} commands) which is not recognized. Make sure you have included the required package for that environment in your preamble, and that the environment is spelled correctly.',
  392. },
  393. {
  394. regexToMatch: /LaTeX Error: Something's wrong--perhaps a missing \\item/,
  395. extraInfoURL:
  396. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_Something%27s_wrong--perhaps_a_missing_%5Citem',
  397. humanReadableHintComponent: (
  398. <>
  399. There are no entries found in a list you have created. Make sure you
  400. label list entries using the \item command, and that you have not used a
  401. list inside a table.
  402. </>
  403. ),
  404. humanReadableHint:
  405. 'There are no entries found in a list you have created. Make sure you label list entries using the \\item command, and that you have not used a list inside a table.',
  406. },
  407. {
  408. regexToMatch: /Misplaced \\noalign/,
  409. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Misplaced_%5Cnoalign',
  410. humanReadableHintComponent: (
  411. <>
  412. You have used a \hline command in the wrong place, probably outside a
  413. table. If the \hline command is written inside a table, try including \\
  414. before it.
  415. </>
  416. ),
  417. humanReadableHint:
  418. 'You have used a \\hline command in the wrong place, probably outside a table. If the \\hline command is written inside a table, try including \\\\ before it.',
  419. },
  420. {
  421. regexToMatch: /LaTeX Error: There's no line here to end/,
  422. extraInfoURL:
  423. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_There%27s_no_line_here_to_end',
  424. humanReadableHintComponent: (
  425. <>
  426. You have used a \\ or \newline command where LaTeX was not expecting
  427. one. Make sure that you only use line breaks after blocks of text, and
  428. be careful using linebreaks inside lists and other environments.\
  429. </>
  430. ),
  431. humanReadableHint:
  432. 'You have used a \\\\ or \\newline command where LaTeX was not expecting one. Make sure that you only use line breaks after blocks of text, and be careful using linebreaks inside lists and other environments.\\',
  433. },
  434. {
  435. regexToMatch: /LaTeX Error: \\verb ended by end of line/,
  436. extraInfoURL:
  437. 'https://www.overleaf.com/learn/Errors/LaTeX_Error:_%5Cverb_ended_by_end_of_line',
  438. humanReadableHintComponent: (
  439. <>
  440. You have used a \verb command incorrectly. Try replacling the \verb
  441. command with \begin
  442. {'{verbatim}'}
  443. …\end
  444. {'{verbatim}'}
  445. .\
  446. </>
  447. ),
  448. humanReadableHint:
  449. 'You have used a \\verb command incorrectly. Try replacling the \\verb command with \\begin{verbatim}…\\end{verbatim}.\\',
  450. },
  451. {
  452. regexToMatch: /Illegal unit of measure (pt inserted)/,
  453. extraInfoURL:
  454. 'https://www.overleaf.com/learn/Errors%2FIllegal%20unit%20of%20measure%20(pt%20inserted)',
  455. humanReadableHintComponent: (
  456. <>
  457. You have written a length, but have not specified the appropriate units
  458. (pt, mm, cm etc.). If you have not written a length, check that you have
  459. not witten a linebreak \\ followed by square brackets […] anywhere.
  460. </>
  461. ),
  462. humanReadableHint:
  463. 'You have written a length, but have not specified the appropriate units (pt, mm, cm etc.). If you have not written a length, check that you have not witten a linebreak \\\\ followed by square brackets […] anywhere.',
  464. },
  465. {
  466. regexToMatch: /Extra \\right/,
  467. extraInfoURL: 'https://www.overleaf.com/learn/Errors/Extra_%5Cright',
  468. humanReadableHintComponent: (
  469. <>
  470. You have written a \right command without a corresponding \left command.
  471. Check that all \left and \right commands balance everywhere.
  472. </>
  473. ),
  474. humanReadableHint:
  475. 'You have written a \\right command without a corresponding \\left command. Check that all \\left and \\right commands balance everywhere.',
  476. },
  477. {
  478. regexToMatch: /Missing \\begin{document}/,
  479. extraInfoURL:
  480. 'https://www.overleaf.com/learn/Errors%2FLaTeX%20Error%3A%20Missing%20%5Cbegin%20document',
  481. humanReadableHintComponent: (
  482. <>
  483. No \begin
  484. {'{document}'} command was found. Make sure you have included \begin
  485. {'{document}'} in your preamble, and that your main document is set
  486. correctly.
  487. </>
  488. ),
  489. humanReadableHint:
  490. 'No \\begin{document} command was found. Make sure you have included \\begin{document} in your preamble, and that your main document is set correctly.',
  491. },
  492. {
  493. ruleId: 'hint_mismatched_environment2',
  494. types: ['environment'],
  495. cascadesFrom: ['environment'],
  496. regexToMatch: /Error: `\\end\{([^\}]+)\}' expected but found `\\end\{([^\}]+)\}'.*/,
  497. newMessage: 'Error: environments do not match: \\begin{$1} ... \\end{$2}',
  498. humanReadableHintComponent: (
  499. <>
  500. You have used \begin
  501. {'{}'} without a corresponding \end
  502. {'{}'}.
  503. </>
  504. ),
  505. humanReadableHint:
  506. 'You have used \\begin{} without a corresponding \\end{}.',
  507. },
  508. {
  509. ruleId: 'hint_mismatched_environment3',
  510. types: ['environment'],
  511. cascadesFrom: ['environment'],
  512. regexToMatch: /Warning: No matching \\end found for `\\begin\{([^\}]+)\}'.*/,
  513. newMessage: 'Warning: No matching \\end found for \\begin{$1}',
  514. humanReadableHintComponent: (
  515. <>
  516. You have used \begin
  517. {'{}'} without a corresponding \end
  518. {'{}'}.
  519. </>
  520. ),
  521. humanReadableHint:
  522. 'You have used \\begin{} without a corresponding \\end{}.',
  523. },
  524. {
  525. ruleId: 'hint_mismatched_environment4',
  526. types: ['environment'],
  527. cascadesFrom: ['environment'],
  528. regexToMatch: /Error: Found `\\end\{([^\}]+)\}' without corresponding \\begin.*/,
  529. newMessage: 'Error: found \\end{$1} without a corresponding \\begin{$1}',
  530. humanReadableHintComponent: (
  531. <>
  532. You have used \begin
  533. {'{}'} without a corresponding \end
  534. {'{}'}.
  535. </>
  536. ),
  537. humanReadableHint:
  538. 'You have used \\begin{} without a corresponding \\end{}.',
  539. },
  540. ]
  541. if (!window.wikiEnabled) {
  542. rules.forEach(rule => {
  543. rule.extraInfoURL = null
  544. rule.humanReadableHint = stripHTMLFromString(rule.humanReadableHint)
  545. })
  546. }
  547. function stripHTMLFromString(htmlStr) {
  548. const tmp = document.createElement('DIV')
  549. tmp.innerHTML = htmlStr
  550. return tmp.textContent || tmp.innerText || ''
  551. }
  552. export default rules