HumanReadableLogsRules.js 24 KB

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