[MTMathAtomFactory] add support for /mod and /pmod
This commit is contained in:
@@ -310,6 +310,7 @@ public class MTMathAtomFactory {
|
||||
"hom" : MTMathAtomFactory.operatorWithName( "hom", limits: false),
|
||||
"exp" : MTMathAtomFactory.operatorWithName( "exp", limits: false),
|
||||
"deg" : MTMathAtomFactory.operatorWithName( "deg", limits: false),
|
||||
"mod" : MTMathAtomFactory.operatorWithName("mod", limits: false),
|
||||
|
||||
// Limit operators
|
||||
"lim" : MTMathAtomFactory.operatorWithName( "lim", limits: true),
|
||||
|
||||
24
Sources/SwiftMath/MathRender/MTMathListBuilder.swift
Executable file → Normal file
24
Sources/SwiftMath/MathRender/MTMathListBuilder.swift
Executable file → Normal file
@@ -620,6 +620,30 @@ public struct MTMathListBuilder {
|
||||
mathColorbox.colorString = color!
|
||||
mathColorbox.innerList = self.buildInternal(true)
|
||||
return mathColorbox
|
||||
} else if command == "pmod" {
|
||||
// A pmod command has 1 argument - creates (mod n)
|
||||
let inner = MTInner()
|
||||
inner.leftBoundary = MTMathAtomFactory.boundary(forDelimiter: "(")
|
||||
inner.rightBoundary = MTMathAtomFactory.boundary(forDelimiter: ")")
|
||||
|
||||
let innerList = MTMathList()
|
||||
|
||||
// Add the "mod" operator (upright text)
|
||||
let modOperator = MTMathAtomFactory.atom(forLatexSymbol: "mod")!
|
||||
innerList.add(modOperator)
|
||||
|
||||
// Add medium space between "mod" and argument (6mu)
|
||||
let space = MTMathSpace(space: 6.0)
|
||||
innerList.add(space)
|
||||
|
||||
// Parse the argument from braces
|
||||
let argument = self.buildInternal(true)
|
||||
if let argList = argument {
|
||||
innerList.append(argList)
|
||||
}
|
||||
|
||||
inner.innerList = innerList
|
||||
return inner
|
||||
} else {
|
||||
let errorMessage = "Invalid command \\\(command)"
|
||||
self.setError(.invalidCommand, message:errorMessage)
|
||||
|
||||
Reference in New Issue
Block a user