Class OdfMathToken
Represents a lightweight MathML token. 表示一個簡易 MathML token。
public sealed class OdfMathToken
- Inheritance
-
OdfMathToken
- Inherited Members
Properties
Attributes
Gets the common MathML attributes set on this token. 取得此 token 上設定的 MathML 通用屬性。
public IReadOnlyDictionary<string, string>? Attributes { get; }
Property Value
Remarks
Examples include mathvariant, displaystyle, mathsize, mathcolor, mathbackground, stretchy, lspace, and rspace.
例如 mathvariant、displaystyle、mathsize、mathcolor、mathbackground、stretchy、lspace 與 rspace。
Base
Gets the first child token for binary composite tokens. 取得二元複合 token 的第一個子 token。
public OdfMathToken? Base { get; }
Property Value
Remarks
This applies to superscript, subscript, fraction, radical, and upper/lower mark tokens. 這適用於上標、下標、分數、根號與上下方標記 token。
Children
Gets the child token list for multi-child composite tokens. 取得多元複合 token 的子 token 清單。
public IReadOnlyList<OdfMathToken>? Children { get; }
Property Value
Remarks
Denominator
Gets the denominator of a Fraction token (the mfrac second child).
取得分數(Fraction,對應 mfrac)token 的分母。
public OdfMathToken Denominator { get; }
Property Value
Exceptions
- InvalidOperationException
When this token is not a Fraction. / 當此 token 不是分數時擲出。
Exponent
Gets the exponent of a Superscript token (the msup second child).
取得上標(Superscript,對應 msup)token 的指數。
public OdfMathToken Exponent { get; }
Property Value
Exceptions
- InvalidOperationException
When this token is not a Superscript. / 當此 token 不是上標時擲出。
Kind
Gets the token kind. 取得 token 類型。
public OdfMathTokenKind Kind { get; }
Property Value
Numerator
public OdfMathToken Numerator { get; }
Property Value
Exceptions
- InvalidOperationException
When this token is not a Fraction. / 當此 token 不是分數時擲出。
Radicand
public OdfMathToken Radicand { get; }
Property Value
Exceptions
- InvalidOperationException
When this token is not a Radical. / 當此 token 不是根號時擲出。
RootIndex
Gets the root index of a Radical token; null for a plain square root. 取得根號(Radical)token 的根指數;平方根時為 null。
public OdfMathToken? RootIndex { get; }
Property Value
Exceptions
- InvalidOperationException
When this token is not a Radical. / 當此 token 不是根號時擲出。
RowCount
public int RowCount { get; }
Property Value
Exceptions
- InvalidOperationException
When this token is not a Matrix. / 當此 token 不是矩陣時擲出。
Script
Gets the second child token for binary composite tokens. 取得二元複合 token 的第二個子 token。
public OdfMathToken? Script { get; }
Property Value
Remarks
This applies to superscript, subscript, fraction, radical, and upper/lower mark tokens. 這適用於上標、下標、分數、根號與上下方標記 token。
SubscriptIndex
Gets the subscript index of a Subscript token (the msub second child).
取得下標(Subscript,對應 msub)token 的下標索引。
public OdfMathToken SubscriptIndex { get; }
Property Value
Exceptions
- InvalidOperationException
When this token is not a Subscript. / 當此 token 不是下標時擲出。
Text
Gets leaf-token text, or auxiliary data for composite tokens. 取得葉節點 token 文字,或複合 token 的輔助資料。
public string Text { get; }
Property Value
Remarks
Composite tokens usually use an empty string, except for auxiliary data such as delimiters for Fenced or the displaystyle setting for Style. 複合 token 通常使用空字串,例外為 Fenced 的開閉括號或 Style 的 displaystyle 設定等輔助資料。
Methods
AddRow(OdfMathToken)
Returns a new Matrix token with the specified row appended at the end (the original token is not modified). 回傳在尾端新增一列後的新矩陣 token(原 token 不會被修改)。
public OdfMathToken AddRow(OdfMathToken row)
Parameters
rowOdfMathTokenThe row token to append, built with Row(params OdfMathToken[]). / 要新增的列 token,須以 Row(params OdfMathToken[]) 建立。
Returns
- OdfMathToken
The new OdfMathToken with the appended row. / 新增列後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Matrix. / 當此 token 不是矩陣時擲出。
- ArgumentNullException
When
rowis null. / 當row為 null 時擲出。
Apply(string, params OdfMathToken[])
Creates a basic Content MathML apply semantic token.
建立 Content MathML apply 語意標記 token(基礎支援)。
public static OdfMathToken Apply(string operatorName, params OdfMathToken[] operands)
Parameters
operatorNamestringThe operator name, such as
plus,times, oreq; it is serialized as the corresponding empty element. / 運算子名稱,例如plus、times或eq;序列化為對應的空元素。operandsOdfMathToken[]The operand token list. / 運算元 token 清單。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Exceptions
- ArgumentException
When
operatorNameis blank oroperandsis empty. / 當operatorName為空白,或operands為空時擲出。
Fenced(OdfMathToken)
Short overload of Fenced that accepts inner; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 inner;其餘可選參數使用預設值並轉呼叫最長 Fenced 多載。
public static OdfMathToken Fenced(OdfMathToken inner)
Parameters
innerOdfMathToken
Returns
Fenced(OdfMathToken, string)
Short overload of Fenced that accepts inner and open; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 inner 與 open;其餘可選參數使用預設值並轉呼叫最長 Fenced 多載。
public static OdfMathToken Fenced(OdfMathToken inner, string open)
Parameters
innerOdfMathTokenopenstring
Returns
Fenced(OdfMathToken, string, string)
Creates a fenced group token serialized as mrow with leading and trailing mo delimiters.
建立以括號包圍內容的群組 token(序列化為 mrow 搭配前後 mo 分隔符號)。
public static OdfMathToken Fenced(OdfMathToken inner, string open, string close)
Parameters
innerOdfMathTokenThe token content inside the delimiters. / 括號內的內容 token。
openstringThe opening delimiter text; defaults to
(. / 開括號文字,預設為(。closestringThe closing delimiter text; defaults to
). / 閉括號文字,預設為)。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
FindFirst(OdfMathTokenKind)
Recursively finds the first token matching the specified kind. 遞迴尋找第一個符合指定種類的 token。
public OdfMathToken? FindFirst(OdfMathTokenKind kind)
Parameters
kindOdfMathTokenKindThe target token kind. / 目標 token 種類。
Returns
- OdfMathToken
The first matching token, or null when none exists. / 找到的第一個 token;若不存在則為 null。
Fraction(OdfMathToken, OdfMathToken)
Creates a MathML mfrac fraction token.
建立 MathML mfrac 分數 token。
public static OdfMathToken Fraction(OdfMathToken numerator, OdfMathToken denominator)
Parameters
numeratorOdfMathTokenThe numerator token. / 分子 token。
denominatorOdfMathTokenThe denominator token. / 分母 token。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
GetAll(OdfMathTokenKind)
Recursively enumerates all tokens matching the specified kind. 遞迴列舉所有符合指定種類的 token。
public IEnumerable<OdfMathToken> GetAll(OdfMathTokenKind kind)
Parameters
kindOdfMathTokenKindThe target token kind. / 目標 token 種類。
Returns
- IEnumerable<OdfMathToken>
The matching token sequence. / 符合條件的 token 序列。
GetCell(int, int)
Gets the cell at the specified row and column of a Matrix token. 取得矩陣 token 指定列、欄位置的儲存格 token。
public OdfMathToken GetCell(int rowIndex, int columnIndex)
Parameters
rowIndexintThe zero-based row index. / 以零起始的列索引。
columnIndexintThe zero-based column index. / 以零起始的欄索引。
Returns
- OdfMathToken
The cell token at the specified position. / 指定位置的儲存格 token。
Exceptions
- InvalidOperationException
When this token is not a Matrix. / 當此 token 不是矩陣時擲出。
- ArgumentOutOfRangeException
When
rowIndexorcolumnIndexis out of range. / 當rowIndex或columnIndex超出範圍時擲出。
GetRow(int)
Gets the row at the specified index of a Matrix token (a Row token). 取得矩陣 token 指定索引的一列(一個 Row token)。
public OdfMathToken GetRow(int rowIndex)
Parameters
rowIndexintThe zero-based row index. / 以零起始的列索引。
Returns
- OdfMathToken
The row token at the specified index. / 指定索引的列 token。
Exceptions
- InvalidOperationException
When this token is not a Matrix. / 當此 token 不是矩陣時擲出。
- ArgumentOutOfRangeException
When
rowIndexis out of range. / 當rowIndex超出範圍時擲出。
Identifier(string)
Creates a MathML mi identifier token.
建立 MathML mi 識別名稱 token。
public static OdfMathToken Identifier(string text)
Parameters
textstringThe identifier text. / 識別名稱文字。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Matrix(params OdfMathToken[])
Creates a MathML mtable matrix token.
建立 MathML mtable 矩陣 token。
public static OdfMathToken Matrix(params OdfMathToken[] rows)
Parameters
rowsOdfMathToken[]The matrix rows, each created by Row(params OdfMathToken[]). / 矩陣的每一列,須為 Row(params OdfMathToken[]) 所建立的 token。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Number(string)
Creates a MathML mn number token.
建立 MathML mn 數值 token。
public static OdfMathToken Number(string text)
Parameters
textstringThe number text. / 數值文字。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Operator(string)
Creates a MathML mo operator token.
建立 MathML mo 運算子 token。
public static OdfMathToken Operator(string text)
Parameters
textstringThe operator text. / 運算子文字。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Over(OdfMathToken, OdfMathToken)
Creates a MathML mover overscript token.
建立 MathML mover 上方標記 token。
public static OdfMathToken Over(OdfMathToken baseToken, OdfMathToken over)
Parameters
baseTokenOdfMathTokenThe base token. / 底數 token。
overOdfMathTokenThe overscript token. / 上方標記 token。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Radical(OdfMathToken)
Short overload of Radical that accepts radicand; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 radicand;其餘可選參數使用預設值並轉呼叫最長 Radical 多載。
public static OdfMathToken Radical(OdfMathToken radicand)
Parameters
radicandOdfMathToken
Returns
Radical(OdfMathToken, OdfMathToken?)
Creates a MathML msqrt or mroot radical token.
建立 MathML msqrt(無索引)或 mroot(具索引)根號 token。
public static OdfMathToken Radical(OdfMathToken radicand, OdfMathToken? index)
Parameters
radicandOdfMathTokenThe radicand token. / 被開方數 token。
indexOdfMathTokenThe optional root index token; null means square root. / 選用的根指數 token;null 表示平方根。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
RemoveRow(int)
Returns a new Matrix token with the row at the specified index removed (the original token is not modified). 回傳移除指定列後的新矩陣 token(原 token 不會被修改)。
public OdfMathToken RemoveRow(int rowIndex)
Parameters
rowIndexintThe zero-based row index to remove. / 要移除的以零起始列索引。
Returns
- OdfMathToken
The new OdfMathToken with the row removed. / 移除指定列後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Matrix, or when removing would leave the matrix without any row. / 當此 token 不是矩陣,或移除後矩陣將不剩任何列時擲出。
- ArgumentOutOfRangeException
When
rowIndexis out of range. / 當rowIndex超出範圍時擲出。
ReplaceFirst(OdfMathTokenKind, OdfMathToken)
Recursively finds the first token with the specified kind and replaces it with the specified token. 遞迴尋找第一個指定種類的 token,並以指定 token 取代。
public OdfMathToken ReplaceFirst(OdfMathTokenKind kind, OdfMathToken replacement)
Parameters
kindOdfMathTokenKindThe target token kind. / 目標 token 種類。
replacementOdfMathTokenThe replacement token. / 替換後的新 token。
Returns
- OdfMathToken
The new token after replacement, or the current token when no token is matched. / 替換後的新 token;若未命中任何 token,則回傳目前 token。
Exceptions
ReplaceFirst(Func<OdfMathToken, bool>, Func<OdfMathToken, OdfMathToken>)
Recursively finds the first token matching the predicate and replaces it with a token created by the specified factory. 遞迴尋找第一個符合條件的 token,並以指定 factory 建立的新 token 取代。
public OdfMathToken ReplaceFirst(Func<OdfMathToken, bool> predicate, Func<OdfMathToken, OdfMathToken> replacementFactory)
Parameters
predicateFunc<OdfMathToken, bool>The delegate that determines whether a token is the replacement target. / 判斷 token 是否為替換目標的委派。
replacementFactoryFunc<OdfMathToken, OdfMathToken>The delegate that creates a replacement token from the matched token. / 根據命中的 token 建立替換 token 的委派。
Returns
- OdfMathToken
The new token after replacement, or the current token when no token is matched. / 替換後的新 token;若未命中任何 token,則回傳目前 token。
Exceptions
- ArgumentNullException
When
predicateorreplacementFactoryis null. / 當predicate或replacementFactory為 null 時擲出。
Row(params OdfMathToken[])
Creates a MathML mrow row token.
建立 MathML mrow 群組列 token。
public static OdfMathToken Row(params OdfMathToken[] children)
Parameters
childrenOdfMathToken[]The child token list in the row. / 群組中的子 token 清單。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Style(OdfMathToken)
Short overload of Style that accepts inner; remaining optional parameters use defaults and forward to the full overload. 便利多載:提供 inner;其餘可選參數使用預設值並轉呼叫最長 Style 多載。
public static OdfMathToken Style(OdfMathToken inner)
Parameters
innerOdfMathToken
Returns
Style(OdfMathToken, bool?)
Creates a MathML mstyle style group token.
建立 MathML mstyle 樣式群組 token。
public static OdfMathToken Style(OdfMathToken inner, bool? displayStyle)
Parameters
innerOdfMathTokenThe style group content token. / 樣式群組的內容 token。
displayStylebool?The optional
displaystylesetting. / 選用的displaystyle設定。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Subscript(OdfMathToken, OdfMathToken)
Creates a MathML msub subscript token.
建立 MathML msub 下標 token。
public static OdfMathToken Subscript(OdfMathToken baseToken, OdfMathToken scriptToken)
Parameters
baseTokenOdfMathTokenThe base token. / 底數 token。
scriptTokenOdfMathTokenThe subscript token. / 下標 token。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Superscript(OdfMathToken, OdfMathToken)
Creates a MathML msup superscript token.
建立 MathML msup 上標 token。
public static OdfMathToken Superscript(OdfMathToken baseToken, OdfMathToken scriptToken)
Parameters
baseTokenOdfMathTokenThe base token. / 底數 token。
scriptTokenOdfMathTokenThe superscript token. / 上標 token。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
TextToken(string)
Creates a MathML mtext text token.
建立 MathML mtext 文字 token。
public static OdfMathToken TextToken(string text)
Parameters
textstringThe text content. / 文字內容。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
Under(OdfMathToken, OdfMathToken)
Creates a MathML munder underscript token.
建立 MathML munder 下方標記 token。
public static OdfMathToken Under(OdfMathToken baseToken, OdfMathToken under)
Parameters
baseTokenOdfMathTokenThe base token. / 底數 token。
underOdfMathTokenThe underscript token. / 下方標記 token。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
UnderOver(OdfMathToken, OdfMathToken, OdfMathToken)
Creates a MathML munderover under-over token.
建立 MathML munderover 上下方標記 token。
public static OdfMathToken UnderOver(OdfMathToken baseToken, OdfMathToken under, OdfMathToken over)
Parameters
baseTokenOdfMathTokenThe base token. / 底數 token。
underOdfMathTokenThe underscript token. / 下方標記 token。
overOdfMathTokenThe overscript token. / 上方標記 token。
Returns
- OdfMathToken
A new OdfMathToken. / 新的 OdfMathToken。
WithAttribute(string, string)
Creates a new token with the specified MathML attribute added, leaving the original token unchanged. 建立一個附加指定 MathML 屬性的新 token(原 token 不會被修改)。
public OdfMathToken WithAttribute(string name, string value)
Parameters
namestringThe attribute name, such as
mathvariant. / 屬性名稱,例如mathvariant。valuestringThe attribute value. / 屬性值。
Returns
- OdfMathToken
A new OdfMathToken with the added attribute. / 附加屬性後的新 OdfMathToken。
Exceptions
- ArgumentException
When
nameis blank. / 當name為空白時擲出。- ArgumentNullException
WithCell(int, int, OdfMathToken)
Returns a new Matrix token with the cell at the specified row and column replaced (the original token is not modified). 回傳替換指定列、欄儲存格後的新矩陣 token(原 token 不會被修改)。
public OdfMathToken WithCell(int rowIndex, int columnIndex, OdfMathToken cell)
Parameters
rowIndexintThe zero-based row index. / 以零起始的列索引。
columnIndexintThe zero-based column index. / 以零起始的欄索引。
cellOdfMathTokenThe new cell token. / 新的儲存格 token。
Returns
- OdfMathToken
The new OdfMathToken with the replaced cell. / 替換指定儲存格後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Matrix. / 當此 token 不是矩陣時擲出。
- ArgumentNullException
When
cellis null. / 當cell為 null 時擲出。- ArgumentOutOfRangeException
When
rowIndexorcolumnIndexis out of range. / 當rowIndex或columnIndex超出範圍時擲出。
WithChild(int, OdfMathToken)
Returns a new token with the specified child replaced, leaving the original token unchanged. 回傳替換指定子節點後的新 token(原 token 不會被修改)。
public OdfMathToken WithChild(int index, OdfMathToken replacement)
Parameters
indexintThe child index to replace. / 要替換的子節點索引。
replacementOdfMathTokenThe replacement child token. / 替換後的新子節點。
Returns
- OdfMathToken
The new OdfMathToken with the replacement applied. / 替換完成的新 OdfMathToken。
Exceptions
- ArgumentNullException
- ArgumentOutOfRangeException
When
indexis outside the available child range. / 當index超出可用子節點範圍時擲出。
WithDenominator(OdfMathToken)
Returns a new Fraction token with the denominator replaced (the original token is not modified). 回傳替換分母後的新分數 token(原 token 不會被修改)。
public OdfMathToken WithDenominator(OdfMathToken denominator)
Parameters
denominatorOdfMathTokenThe new denominator token. / 新的分母 token。
Returns
- OdfMathToken
The new OdfMathToken with the replaced denominator. / 替換分母後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Fraction. / 當此 token 不是分數時擲出。
- ArgumentNullException
When
denominatoris null. / 當denominator為 null 時擲出。
WithExponent(OdfMathToken)
Returns a new Superscript token with the exponent replaced (the original token is not modified). 回傳替換指數後的新上標 token(原 token 不會被修改)。
public OdfMathToken WithExponent(OdfMathToken exponent)
Parameters
exponentOdfMathTokenThe new exponent token. / 新的指數 token。
Returns
- OdfMathToken
The new OdfMathToken with the replaced exponent. / 替換指數後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Superscript. / 當此 token 不是上標時擲出。
- ArgumentNullException
When
exponentis null. / 當exponent為 null 時擲出。
WithNumerator(OdfMathToken)
Returns a new Fraction token with the numerator replaced (the original token is not modified). 回傳替換分子後的新分數 token(原 token 不會被修改)。
public OdfMathToken WithNumerator(OdfMathToken numerator)
Parameters
numeratorOdfMathTokenThe new numerator token. / 新的分子 token。
Returns
- OdfMathToken
The new OdfMathToken with the replaced numerator. / 替換分子後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Fraction. / 當此 token 不是分數時擲出。
- ArgumentNullException
When
numeratoris null. / 當numerator為 null 時擲出。
WithRadicand(OdfMathToken)
Returns a new Radical token with the radicand replaced (the original token is not modified). 回傳替換被開方數後的新根號 token(原 token 不會被修改)。
public OdfMathToken WithRadicand(OdfMathToken radicand)
Parameters
radicandOdfMathTokenThe new radicand token. / 新的被開方數 token。
Returns
- OdfMathToken
The new OdfMathToken with the replaced radicand. / 替換被開方數後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Radical. / 當此 token 不是根號時擲出。
- ArgumentNullException
When
radicandis null. / 當radicand為 null 時擲出。
WithRootIndex(OdfMathToken?)
Returns a new Radical token with the root index replaced; pass null to turn it back into a plain square root. 回傳替換根指數後的新根號 token;傳入 null 可還原為平方根(原 token 不會被修改)。
public OdfMathToken WithRootIndex(OdfMathToken? rootIndex)
Parameters
rootIndexOdfMathTokenThe new root index token, or null for a square root. / 新的根指數 token,或 null 表示平方根。
Returns
- OdfMathToken
The new OdfMathToken with the replaced root index. / 替換根指數後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Radical. / 當此 token 不是根號時擲出。
WithRow(int, OdfMathToken)
Returns a new Matrix token with the row at the specified index replaced (the original token is not modified). 回傳替換指定列後的新矩陣 token(原 token 不會被修改)。
public OdfMathToken WithRow(int rowIndex, OdfMathToken row)
Parameters
rowIndexintThe zero-based row index to replace. / 要替換的以零起始列索引。
rowOdfMathTokenThe new row token. / 新的列 token。
Returns
- OdfMathToken
The new OdfMathToken with the replaced row. / 替換指定列後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Matrix. / 當此 token 不是矩陣時擲出。
- ArgumentNullException
When
rowis null. / 當row為 null 時擲出。- ArgumentOutOfRangeException
When
rowIndexis out of range. / 當rowIndex超出範圍時擲出。
WithSubscriptIndex(OdfMathToken)
Returns a new Subscript token with the subscript index replaced (the original token is not modified). 回傳替換下標索引後的新下標 token(原 token 不會被修改)。
public OdfMathToken WithSubscriptIndex(OdfMathToken subscriptIndex)
Parameters
subscriptIndexOdfMathTokenThe new subscript index token. / 新的下標索引 token。
Returns
- OdfMathToken
The new OdfMathToken with the replaced subscript index. / 替換下標索引後的新 OdfMathToken。
Exceptions
- InvalidOperationException
When this token is not a Subscript. / 當此 token 不是下標時擲出。
- ArgumentNullException
When
subscriptIndexis null. / 當subscriptIndex為 null 時擲出。