This commit is contained in:
wangjinlei
2024-07-17 09:23:45 +08:00
parent edf9deeb1a
commit 881ac3e056
1001 changed files with 41032 additions and 5452 deletions

View File

@@ -0,0 +1,61 @@
## Usage
To create a fraction, use the `PhpOffice\Math\Element\Fraction` class.
### Methods
#### getDenominator
The method has no parameter.
#### getNumerator
The method has no parameter.
#### setDenominator
The method has one parameter :
* `PhpOffice\Math\Element\AbstractElement` **$element**
#### setNumerator
The method has one parameter :
* `PhpOffice\Math\Element\AbstractElement` **$element**
## Example
### Math
<math display="block">
<mfrac>
<mi>a</mi>
<mn>3</mn>
</mfrac>
</math>
### XML
``` xml
<math display="block">
<mfrac>
<mi>a</mi>
<mn>3</mn>
</mfrac>
</math>
```
### PHP
``` php
<?php
use PhpOffice\Math\Element;
use PhpOffice\Math\Math;
$math = new Math();
$fraction = new Element\Fraction();
$fraction->setDenominator(new Element\Identifier('a'));
$fraction->setNumerator(new Element\Numeric(3));
$math->add($fraction);
```

View File

@@ -0,0 +1,43 @@
## Usage
To create an identifier, use the `PhpOffice\Math\Element\Identifier` class.
### Methods
#### getValue
The method has no parameter.
#### setValue
The method has one parameter :
* `string` **$value**
## Example
### Math
<math display="block">
<mi>a</mi>
</math>
### XML
``` xml
<math display="block">
<mi>a</mi>
</math>
```
### PHP
``` php
<?php
use PhpOffice\Math\Element;
use PhpOffice\Math\Math;
$math = new Math();
$identifier = new Element\Identifier('a');
$math->add($identifier);
```

View File

@@ -0,0 +1,43 @@
## Usage
To create a numeric, use the `PhpOffice\Math\Element\Numeric` class.
### Methods
#### getValue
The method has no parameter.
#### setValue
The method has one parameter :
* `float` **$value**
## Example
### Math
<math display="block">
<mn>3</mn>
</math>
### XML
``` xml
<math display="block">
<mn>3</mn>
</math>
```
### PHP
``` php
<?php
use PhpOffice\Math\Element;
use PhpOffice\Math\Math;
$math = new Math();
$identifier = new Element\Numeric(3);
$math->add($identifier);
```

View File

@@ -0,0 +1,43 @@
## Usage
To create an operator, use the `PhpOffice\Math\Element\Operator` class.
### Methods
#### getValue
The method has no parameter.
#### setValue
The method has one parameter :
* `string` **$value**
## Example
### Math
<math display="block">
<mo>+</mo>
</math>
### XML
``` xml
<math display="block">
<mo>+</mo>
</math>
```
### PHP
``` php
<?php
use PhpOffice\Math\Element;
use PhpOffice\Math\Math;
$math = new Math();
$identifier = new Element\Operator('+');
$math->add($identifier);
```

View File

@@ -0,0 +1,62 @@
## Usage
To create a row, use the `PhpOffice\Math\Element\Row` class.
### Methods
#### add
The method add an element to the row.
The method has one parameter :
* `PhpOffice\Math\Element\AbstractElement` **$element**
#### getElements
The method return all elements of the row.
#### remove
The method remove an element to the row.
The method has one parameter :
* `PhpOffice\Math\Element\AbstractElement` **$element**
## Example
### Math
<math display="block">
<mrow>
<mn>1</mn>
<mo>+</mo>
<mi>K</mi>
</mrow>
</math>
### XML
``` xml
<math display="block">
<mrow>
<mn>1</mn>
<mo>+</mo>
<mi>K</mi>
</mrow>
</math>
```
### PHP
``` php
<?php
use PhpOffice\Math\Element;
use PhpOffice\Math\Math;
$math = new Math();
$row = new Element\Row();
$row->add(new Element\Numeric(1));
$row->add(new Element\Operator('+'));
$row->add(new Element\Identifier('K'));
$math->add($row);
```

View File

@@ -0,0 +1,81 @@
## Usage
To create a semantics, use the `PhpOffice\Math\Element\Semantics` class.
### Methods
#### add
The method add an element to the `semantics` element.
The method has one parameter :
* `PhpOffice\Math\Element\AbstractElement` **$element**
#### addAnnotation
The method add an annotation to the `semantics` element.
The method has two parameters :
* `string` **$encoding**
* `string` **$annotation**
#### getAnnotation
The method return an annotation based on its encoding.
The method has one parameter :
* `string` **$encoding**
#### getAnnotations
The method return alls annotation of the `semantics` element.
The method has no parameter.
#### getElements
The method return all elements of the `semantics` element.
#### remove
The method remove an element to the `semantics` element.
The method has one parameter :
* `PhpOffice\Math\Element\AbstractElement` **$element**
## Example
### Math
<math display="block">
<semantics>
<mi>y</mi>
<annotation encoding="application/x-tex"> y </annotation>
</semantics>
</math>
### XML
``` xml
<math display="block">
<semantics>
<mi>y</mi>
<annotation encoding="application/x-tex"> y </annotation>
</semantics>
</math>
```
### PHP
``` php
<?php
use PhpOffice\Math\Element;
use PhpOffice\Math\Math;
$math = new Math();
$semantics = new Element\Semantics();
$semantics->add(new Element\Identifier('y'));
$semantics->addAnnotation('application/x-tex', ' y ');
$math->add($semantics);
```

View File

@@ -0,0 +1,61 @@
## Usage
To attach a superscript to an expression, use the `PhpOffice\Math\Element\Superscript` class.
### Methods
#### getBase
The method has no parameter.
#### getSuperscript
The method has no parameter.
#### setBase
The method has one parameter :
* `PhpOffice\Math\Element\AbstractElement` **$element**
#### setSuperscript
The method has one parameter :
* `PhpOffice\Math\Element\AbstractElement` **$element**
## Example
### Math
<math display="block">
<msup>
<mi>X</mi>
<mn>2</mn>
</msup>
</math>
### XML
``` xml
<math display="block">
<msup>
<mi>X</mi>
<mn>2</mn>
</msup>
</math>
```
### PHP
``` php
<?php
use PhpOffice\Math\Element;
use PhpOffice\Math\Math;
$math = new Math();
$superscript = new Element\Superscript();
$superscript->setBase(new Element\Identifier('X'));
$superscript->setSuperscript(new Element\Numeric(2));
$math->add($superscript);
```

View File

@@ -0,0 +1,50 @@
## Readers
### MathML
The name of the reader is `MathML`.
``` php
<?php
use PhpOffice\Math\Reader\MathML;
$reader = new MathML();
$math = $reader->read(
'<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE math PUBLIC "-//W3C//DTD MathML 2.0//EN" "http://www.w3.org/Math/DTD/mathml2/mathml2.dtd">
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mi> a </mi>
</math>'
);
```
### OfficeMathML
The name of the reader is `OfficeMathML`.
``` php
<?php
use PhpOffice\Math\Reader\OfficeMathML;
$reader = new OfficeMathML();
$math = $reader->read(
'<m:oMathPara xmlns:m="http://schemas.openxmlformats.org/officeDocument/2006/math">
<m:oMath>
<m:f>
<m:num><m:r><m:t>π</m:t></m:r></m:num>
<m:den><m:r><m:t>2</m:t></m:r></m:den>
</m:f>
</m:oMath>
</m:oMathPara>'
);
```
## Methods
### read
The method has one parameter :
* `string` **$content**
The method returns a `PhpOffice\Math\Math` object.

View File

@@ -0,0 +1,46 @@
## Writers
### MathML
The name of the writer is `MathML`.
``` php
<?php
use PhpOffice\Math\Element;
use PhpOffice\Math\Math;
use PhpOffice\Math\Writer\MathML;
$math = new Math();
$math->add(new Element\Operator('+'));
$writer = new MathML();
$output = $writer->write($math);
```
### OfficeMathML
The name of the writer is `OfficeMathML`.
``` php
<?php
use PhpOffice\Math\Element;
use PhpOffice\Math\Math;
use PhpOffice\Math\Writer\OfficeMathML;
$math = new Math();
$math->add(new Element\Operator('+'));
$writer = new OfficeMathML();
$output = $writer->write($math);
```
## Methods
### writer
The method has one parameter :
* `PhpOffice\Math\Math` **$math**
The method returns a `string`.