@mulmoclaude/markdown-utils 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -52,9 +52,14 @@
52
52
  // The SHAPE is matched rather than a particular separator, because a
53
53
  // comma groups thousands in English and marks the decimal in most of
54
54
  // Europe, and a dot does the opposite (codex, #2985). `$1,5$` is one and
55
- // a half and typesets; `$1.000,50$` is a price and does not. `$1,500$`
56
- // is genuinely ambiguous and is read as the price — the reading rule 5
57
- // already had, which this narrowing keeps rather than reverses.
55
+ // a half and typesets; `$1.000,50$` carries both a grouping AND a
56
+ // decimal mark, which no one computes with, and does not.
57
+ //
58
+ // A number with ONE separator typesets whatever follows it. Reading
59
+ // three digits after it as money cost every three-decimal constant a
60
+ // maths article writes (`$3.141$`, `$1.414$`, `$2.718$`) and bought only
61
+ // `$1,500$` — a shape currency prose never reaches, because rules 1-4
62
+ // kill every realistic way of writing a price first (#2991).
58
63
  //
59
64
  // Rules 2-5 are enforced in the tokenizer, where the whole match is in
60
65
  // hand. Rule 1 needs the character BEFORE the match, which a marked
@@ -76,7 +81,6 @@ const DIGITS = /^\d+$/;
76
81
  * and which one marks the decimal is exactly what cannot be known, so
77
82
  * none of them is read as one or the other. */
78
83
  const NUMBER_SEPARATORS = /[.,\s]/;
79
- const THOUSAND = 3;
80
84
  /** A bare number written the way MONEY is written rather than the way a
81
85
  * quantity is — `1,000`, `1.000`, `1 000`, `1.000,50`, `12,345,678`.
82
86
  *
@@ -85,31 +89,36 @@ const THOUSAND = 3;
85
89
  * and a dot does the opposite, so a rule that names one of them fails
86
90
  * half the world's authors either way (codex, #2985).
87
91
  *
88
- * Two separators or more is money a quantity does not need them. One
89
- * separator followed by exactly three digits is ambiguous, `$1,500$` as
90
- * much as `$1.500$`, and is read as money: that is the reading rule 5
91
- * already had, and the one this file is narrowing rather than
92
- * reversing. Everything else `10000`, `1`, `1,5`, `3.14159` is a
93
- * number, and a number in a maths article is maths.
92
+ * Two separators or more is money: `1.000,50` groups AND marks a
93
+ * decimal, which is a formatted amount rather than a quantity anyone
94
+ * computes with.
95
+ *
96
+ * ONE separator is not, whatever follows it. That branch used to read
97
+ * "exactly three digits after it" as money, and the cost was every
98
+ * three-decimal constant a maths article writes — `3.141`, `1.414`,
99
+ * `2.718`, `1.618`, `0.577`, `6.022`, `9.807` all came out as literal
100
+ * `$…$` in the prose (#2991). What it bought was `$1,500$`, and that
101
+ * turns out to be a shape currency prose never reaches: every realistic
102
+ * form dies earlier, at rules 1-4 —
103
+ *
104
+ * `$1,000 と $2,000` rule 3, whitespace before the close
105
+ * `合計 $1,000から$500` rule 3
106
+ * `$1,000-$2,000` rule 4, a digit after the close
107
+ * `US$1,000` rule 1, alphanumeric before the open
108
+ * `価格は $1,000 です` no closing `$` at all
94
109
  *
95
- * A leading zero is NOT an exception, though it looks like one: a
96
- * three-decimal sub-unit price is how fuel is priced (`$0.100` a litre),
97
- * so `$0.100$` is as ambiguous as `$1.500$` and is read the same way
98
- * (codex, #2985). Three digits after the separator is the whole test. */
110
+ * leaving only `$1,000$`, both delimiters written out. That is the
111
+ * same shape this file already reads as maths for `$5$`: a person
112
+ * quoting a price writes `$1,000`, and it is the DOUBLED delimiter that
113
+ * makes it a formula. Rule 5 was applying one reading to `$5$` and the
114
+ * opposite to `$1,500$`; now it applies the same one to both. */
99
115
  function isMoneyShaped(body) {
100
116
  const runs = body.split(NUMBER_SEPARATORS);
101
117
  // Anything that is not digits-and-separators is not a written number at
102
118
  // all — `x=1` and `\pi` land here and are maths by this rule.
103
119
  if (!runs.every((run) => DIGITS.test(run)))
104
120
  return false;
105
- if (runs.length === 1)
106
- return false;
107
- if (runs.length > 2)
108
- return true;
109
- const [, tail] = runs;
110
- if (tail === undefined)
111
- return false;
112
- return tail.length === THOUSAND;
121
+ return runs.length > 2;
113
122
  }
114
123
  /** The same set with the digits removed: a body of punctuation has
115
124
  * nothing to typeset. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulmoclaude/markdown-utils",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Browser-safe markdown / image rendering utilities shared by the MulmoClaude host and the markdown plugin",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -35,7 +35,7 @@
35
35
  "dependencies": {
36
36
  "@mulmoclaude/common": "^1.2.0",
37
37
  "dompurify": "^3.4.13",
38
- "js-yaml": "^5.2.3",
38
+ "js-yaml": "^5.4.1",
39
39
  "marked": "^18.0.11"
40
40
  },
41
41
  "peerDependencies": {
@@ -47,7 +47,7 @@
47
47
  "mathjax-full": "^3.2.2",
48
48
  "mermaid": "^11.17.2",
49
49
  "typescript": "^6.0.3",
50
- "vue": "^3.5.41"
50
+ "vue": "^3.5.42"
51
51
  },
52
52
  "homepage": "https://github.com/receptron/mulmoclaude/tree/main/packages/markdown-utils#readme",
53
53
  "repository": {