Bläddra i källkod

Error investigation configurable

main
Rocketsoup 1 år sedan
förälder
incheckning
7c87d3af97
4 ändrade filer med 34 tillägg och 3 borttagningar
  1. 10
    1
      js/markdown.js
  2. 1
    1
      js/markdown.min.js
  3. 10
    1
      php/markdown.php
  4. 13
    0
      php/test.php

+ 10
- 1
js/markdown.js Visa fil

@@ -4236,6 +4236,13 @@ class Markdown {
4236 4236
 	 */
4237 4237
 	tagFilter = new MDHTMLFilter();
4238 4238
 
4239
+	/**
4240
+	 * If an exception occurs, attempts to narrow down the portion of the
4241
+	 * markdown that triggered the error and outputs it to the console. For
4242
+	 * debugging. Investigation mode can be slow.
4243
+	 */
4244
+	investigateErrors = false;
4245
+
4239 4246
 	/** @type {MDReader[]} */
4240 4247
 	#readers;
4241 4248
 
@@ -4272,7 +4279,9 @@ class Markdown {
4272 4279
 		try {
4273 4280
 			return this.#parse(lines, elementIdPrefix);
4274 4281
 		} catch (e) {
4275
-			this.#investigateException(lines, elementIdPrefix);
4282
+			if (this.investigateErrors) {
4283
+				this.#investigateException(lines, elementIdPrefix);
4284
+			}
4276 4285
 			throw e;
4277 4286
 		}
4278 4287
 	}

+ 1
- 1
js/markdown.min.js
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 10
- 1
php/markdown.php Visa fil

@@ -3941,6 +3941,13 @@ class Markdown {
3941 3941
 	 */
3942 3942
 	public MDHTMLFilter $tagFilter;
3943 3943
 
3944
+	/**
3945
+	 * If an exception occurs, attempts to narrow down the portion of the
3946
+	 * markdown that triggered the error and outputs it to the console. For
3947
+	 * debugging. Investigation mode can be slow.
3948
+	 */
3949
+	public bool $investigateErrors = false;
3950
+
3944 3951
 	/** @var MDReader[] */
3945 3952
 	private array $readers;
3946 3953
 
@@ -3977,7 +3984,9 @@ class Markdown {
3977 3984
 		try {
3978 3985
 			return $this->parse($lines, $elementIdPrefix);
3979 3986
 		} catch (Error $e) {
3980
-			$this->investigateException($lines, $elementIdPrefix);
3987
+			if ($this->investigateErrors) {
3988
+				$this->investigateException($lines, $elementIdPrefix);
3989
+			}
3981 3990
 			throw $e;
3982 3991
 		}
3983 3992
 	}

+ 13
- 0
php/test.php Visa fil

@@ -0,0 +1,13 @@
1
+<?php
2
+include 'markdown.php';
3
+include 'spreadsheet.php';
4
+
5
+$address = 'C6';
6
+if (mb_eregi('^(\\$?)([A-Z]{1,2}?)((?:\\$(?=[0-9]))?)([0-9]*)$', $address, $groups)) {
7
+    print("Matched\n");
8
+    print_r($groups);
9
+} else {
10
+    print("No match!\n");
11
+}
12
+
13
+?>

Laddar…
Avbryt
Spara