Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make \symbf and \symsf handle Greek italics as in LaTeX. #1061

Merged
merged 1 commit into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -308,12 +308,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