Skip to content

Commit

Permalink
Merge pull request #1061 from mathjax/symbf-greek
Browse files Browse the repository at this point in the history
Make \symbf and \symsf handle Greek italics as in LaTeX.
  • Loading branch information
dpvc committed Mar 16, 2024
2 parents 119fb6b + b9e5d1e commit 5b28ff8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
13 changes: 8 additions & 5 deletions ts/input/tex/base/BaseConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ import './BaseMappings.js';
import {getRange} from '../../../core/MmlTree/OperatorDictionary.js';
import ParseOptions from '../ParseOptions.js';
import {ParseUtil} from '../ParseUtil.js';
import {TexConstant} from '../TexConstants.js';

const MATHVARIANT = TexConstant.Variant;

/**
* Remapping some ASCII characters to their Unicode operator equivalent.
Expand All @@ -53,17 +56,17 @@ new CharacterMap('remap', null, {
*/
export function Other(parser: TexParser, char: string) {
const font = parser.stack.env['font'];
let def = font ?
// @test Other Font
{mathvariant: parser.stack.env['font']} : {};
const ifont = parser.stack.env['italicFont'];
// @test Other Font
let def = font ? {mathvariant: font} : {};
const remap = (MapHandler.getMap('remap') as CharacterMap).lookup(char);
const range = getRange(char);
const type = range[3]
// @test Other
// @test Other Remap
let mo = parser.create('token', type, def, (remap ? remap.char : char));
const variant = (range[4] ||
(ParseUtil.isLatinOrGreekChar(char) ? parser.configuration.mathStyle(char, true) : ''));
const style = (ParseUtil.isLatinOrGreekChar(char) ? parser.configuration.mathStyle(char, true) || ifont : '');
const variant = (range[4] || (font && style === MATHVARIANT.NORMAL? '' : style));
if (variant) {
mo.attributes.set('mathvariant', variant);
}
Expand Down
4 changes: 2 additions & 2 deletions ts/input/tex/base/BaseMappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ new sm.CommandMap('macros', {
symrm: ['MathFont', VARIANT.NORMAL],
symup: ['MathFont', VARIANT.NORMAL],
symnormal: ['MathFont', ''],
symbf: ['MathFont', VARIANT.BOLD],
symbf: ['MathFont', VARIANT.BOLD, VARIANT.BOLDITALIC],
symbfup: ['MathFont', VARIANT.BOLD],
symit: ['MathFont', VARIANT.ITALIC],
symbfit: ['MathFont', VARIANT.BOLDITALIC],
Expand All @@ -448,7 +448,7 @@ new sm.CommandMap('macros', {
symbffrak: ['MathFont', VARIANT.BOLDFRAKTUR],
symscr: ['MathFont', VARIANT.SCRIPT],
symbfscr: ['MathFont', VARIANT.BOLDSCRIPT],
symsf: ['MathFont', VARIANT.SANSSERIF],
symsf: ['MathFont', VARIANT.SANSSERIF, VARIANT.SANSSERIFITALIC],
symsfup: ['MathFont', VARIANT.SANSSERIF],
symbfsf: ['MathFont', VARIANT.BOLDSANSSERIF],
symbfsfup: ['MathFont', VARIANT.BOLDSANSSERIF],
Expand Down
3 changes: 2 additions & 1 deletion ts/input/tex/base/BaseMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,12 +307,13 @@ BaseMethods.Hash = function(_parser: TexParser, _c: string) {
/**
* Handle \mathrm, \mathbf, etc, allowing for multi-letter runs to be one <mi>.
*/
BaseMethods.MathFont = function(parser: TexParser, name: string, variant: string) {
BaseMethods.MathFont = function(parser: TexParser, name: string, variant: string, italic: string = '') {
const text = parser.GetArgument(name);
let mml = new TexParser(text, {
multiLetterIdentifiers: parser.options.identifierPattern,
...parser.stack.env,
font: variant,
italicFont: italic,
noAutoOP: true
}, parser.configuration).mml();
parser.Push(parser.create('node', 'TeXAtom', [mml]));
Expand Down

0 comments on commit 5b28ff8

Please sign in to comment.