Skip to content

Commit 6fd712a

Browse files
committed
[fix] negative numbers in parentheses, fixes #18
1 parent 847143f commit 6fd712a

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

src/formatting.typ

+9-9
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
/// if `positive-sign` is set to true. In all other cases, the result is
2020
/// `none`.
2121
#let format-sign(sign, positive-sign: false) = {
22-
if sign == "-" { return sym.minus }
23-
else if sign == "+" and positive-sign { return sym.plus }
22+
if sign == "-" { return "" }
23+
else if sign == "+" and positive-sign { return "+" }
2424
}
2525

26-
#assert.eq(format-sign("-", positive-sign: false), sym.minus)
26+
#assert.eq(format-sign("-", positive-sign: false), "")
2727
#assert.eq(format-sign("+", positive-sign: false), none)
28-
#assert.eq(format-sign("-", positive-sign: true), sym.minus)
29-
#assert.eq(format-sign("+", positive-sign: true), sym.plus)
28+
#assert.eq(format-sign("-", positive-sign: true), "")
29+
#assert.eq(format-sign("+", positive-sign: true), "+")
3030
#assert.eq(format-sign(none, positive-sign: true), none)
3131

3232

@@ -177,16 +177,16 @@
177177
(
178178
math.attach(
179179
none,
180-
t: sym.plus + pm.at(0),
181-
b: sym.minus + pm.at(1)
180+
t: "+" + pm.at(0),
181+
b: "" + pm.at(1)
182182
),
183183
)
184184
} else {
185185
(
186186
non-math-attach(
187187
none,
188-
t: sym.plus + pm.at(0),
189-
b: sym.minus + pm.at(1)
188+
t: "+" + pm.at(0),
189+
b: "" + pm.at(1)
190190
),
191191
)
192192
}

src/num.typ

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
info = it.number
5353
if "mantissa" in info {
5454
let mantissa = info.mantissa
55-
if type(mantissa) in (int, float) { mantissa = str(mantissa).replace(sym.minus, "-") }
55+
if type(mantissa) in (int, float) { mantissa = str(mantissa).replace("", "-") }
5656
let (sign, int, frac) = parsing.decompose-signed-float-string(mantissa)
5757
info += (sign: sign, int: int, frac: frac)
5858
}
@@ -68,7 +68,7 @@
6868
/// Maybe shift exponent
6969
if it.fixed != none {
7070
let e = if info.e == none { 0 } else { int(info.e) }
71-
info.e = str(it.fixed).replace(sym.minus, "-")
71+
info.e = str(it.fixed).replace("", "-")
7272
(info.int, info.frac) = utility.shift-decimal-left(info.int, info.frac, it.fixed - e)
7373
}
7474

src/parsing.typ

+4-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
else if type(number) == content { result = content-to-string(number) }
6262
else { result = none }
6363
if result == none { return none }
64-
return result.replace(",", ".").replace(sym.minus, "-")
64+
return result.replace(",", ".").replace("", "-")
6565
}
6666

6767
#let number-to-string-table(number) = {
@@ -72,7 +72,7 @@
7272
else { result = none }
7373
if result == none { return none }
7474
if type(result) != array { result = (result, none, none) }
75-
result.at(0) = result.at(0).replace(",", ".").replace(sym.minus, "-")
75+
result.at(0) = result.at(0).replace(",", ".").replace("", "-")
7676
if result.len() == 0 or result.at(0).at(0) not in "0123456789+-." {
7777
return none
7878
}
@@ -81,7 +81,7 @@
8181

8282
#assert.eq(number-to-string("123"), "123")
8383
#assert.eq(number-to-string("-2.0"), "-2.0")
84-
#assert.eq(number-to-string(sym.minus + "2,0"), "-2.0")
84+
#assert.eq(number-to-string("" + "2,0"), "-2.0")
8585
#assert.eq(number-to-string[2], "2")
8686
#assert.eq(number-to-string[-2.1], "-2.1")
8787
#assert.eq(number-to-string[-2.], "-2.")
@@ -149,7 +149,7 @@
149149
/// Decomposes a normalized number string into sign, integer, fractional,
150150
/// uncertainty and exponent. Here, normalized means that the decimal separator
151151
/// is `"."`, and `"+"`, `"-"` is used for all signs (as opposed to
152-
/// `sym.minus`).
152+
/// `"−"`).
153153
///
154154
/// Sign, integer and fractional part are guaranteed to be valid (however,
155155
/// the latter two may be empty strings) while the uncertainty and the

tests/num/test.typ

+2-2
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@
130130
// power base
131131

132132
#num("1e2", base: 2) \
133-
#num("1e2", base: [e]) \
134-
#num("1e2", base: [π])
133+
#num("1e2", base: $e$) \
134+
#num("1e2", base: $π$)
135135
#set-num(base: "4")
136136
#num("1e2") \
137137
#set-num(base: 10)

0 commit comments

Comments
 (0)