|
| 1 | +/************************************************************* |
| 2 | + * |
| 3 | + * Copyright (c) 2017 The MathJax Consortium |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | +/** |
| 19 | + * @fileoverview Implements the CHTMLmath wrapper for the MmlMath object |
| 20 | + * |
| 21 | + * @author [email protected] (Davide Cervone) |
| 22 | + */ |
| 23 | + |
| 24 | +import {CHTMLWrapper} from '../Wrapper.js'; |
| 25 | +import {CHTMLWrapperFactory} from '../WrapperFactory.js'; |
| 26 | +import {MmlMath} from '../../../core/MmlTree/MmlNodes/math.js'; |
| 27 | +import {MmlNode} from '../../../core/MmlTree/MmlNode.js'; |
| 28 | +import {StyleList} from '../CssStyles.js'; |
| 29 | + |
| 30 | +/*****************************************************************/ |
| 31 | +/* |
| 32 | + * The CHTMLmath wrapper for the MmlMath object |
| 33 | + */ |
| 34 | + |
| 35 | +export class CHTMLmath extends CHTMLWrapper { |
| 36 | + public static kind = MmlMath.prototype.kind; |
| 37 | + |
| 38 | + public static styles: StyleList = { |
| 39 | + 'mjx-math': { |
| 40 | + 'line-height': 0, |
| 41 | + 'text-align': 'left', |
| 42 | + 'text-indent': 0, |
| 43 | + 'font-style': 'normal', |
| 44 | + 'font-weight': 'normal', |
| 45 | + 'font-size': '100%', |
| 46 | + 'font-size-adjust': 'none', |
| 47 | + 'letter-spacing': 'normal', |
| 48 | + 'word-wrap': 'normal', |
| 49 | + 'word-spacing': 'normal', |
| 50 | + 'white-space': 'nowrap', |
| 51 | + 'direction': 'ltr', |
| 52 | + 'padding': '1px 0' |
| 53 | + }, |
| 54 | + 'mjx-chtml.MJX-DISPLAY': { |
| 55 | + display: 'block', |
| 56 | + 'text-align': 'center', |
| 57 | + margin: '1em 0' |
| 58 | + }, |
| 59 | + 'mjx-chtml.MJX-DISPLAY mjx-math': { |
| 60 | + padding: 0 |
| 61 | + } |
| 62 | + }; |
| 63 | + |
| 64 | + /* |
| 65 | + * @override |
| 66 | + */ |
| 67 | + public toCHTML(parent: HTMLElement) { |
| 68 | + super.toCHTML(parent); |
| 69 | + if (this.node.attributes.get('display') === 'block') { |
| 70 | + this.chtml.setAttribute('display', 'true'); |
| 71 | + parent.classList.add('MJX-DISPLAY'); |
| 72 | + } |
| 73 | + } |
| 74 | + |
| 75 | +} |
0 commit comments