Skip to content

Commit b073c6b

Browse files
committed
content: Render KaTeX by default, the way we have in recent releases
This is cherry-picked from commits we included in each of the last several releases, starting with 8f37237 in v0.0.31.
1 parent fe186b2 commit b073c6b

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

lib/model/settings.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ enum BoolGlobalSetting {
178178
upgradeWelcomeDialogShown(GlobalSettingType.internal, false),
179179

180180
/// An experimental flag to toggle rendering KaTeX content in messages.
181-
renderKatex(GlobalSettingType.experimentalFeatureFlag, false),
181+
renderKatex(GlobalSettingType.experimentalFeatureFlag, true),
182182

183183
/// An experimental flag to enable rendering KaTeX even when some
184184
/// errors are encountered.

test/model/content_test.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ class ContentExample {
512512
static final mathInline = ContentExample.inline(
513513
'inline math',
514514
r"$$ \lambda $$",
515-
expectedText: r'\lambda',
515+
expectedText: r'λ',
516516
'<p><span class="katex">'
517517
'<span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>λ</mi></mrow>'
518518
'<annotation encoding="application/x-tex"> \\lambda </annotation></semantics></math></span>'
@@ -532,7 +532,7 @@ class ContentExample {
532532
static const mathBlock = ContentExample(
533533
'math block',
534534
"```math\n\\lambda\n```",
535-
expectedText: r'\lambda',
535+
expectedText: r'λ',
536536
'<p><span class="katex-display"><span class="katex">'
537537
'<span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mrow><mi>λ</mi></mrow>'
538538
'<annotation encoding="application/x-tex">\\lambda</annotation></semantics></math></span>'

test/widgets/content_test.dart

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,11 @@ void main() {
558558
group('MathBlock', () {
559559
testContentSmoke(ContentExample.mathBlock);
560560

561-
testWidgets('displays KaTeX source; experimental flag default', (tester) async {
561+
testWidgets('displays KaTeX source; experimental flag disabled', (tester) async {
562+
addTearDown(testBinding.reset);
563+
final globalSettings = testBinding.globalStore.settings;
564+
await globalSettings.setBool(BoolGlobalSetting.renderKatex, false);
565+
562566
await prepareContent(tester, plainContent(ContentExample.mathBlock.html));
563567
tester.widget(find.text(r'\lambda', findRichText: true));
564568
});
@@ -1102,6 +1106,23 @@ void main() {
11021106
});
11031107

11041108
testWidgets('maintains font-size ratio with surrounding text, when showing TeX source', (tester) async {
1109+
const html = '<span class="katex">'
1110+
'<span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>λ</mi></mrow>'
1111+
'<annotation encoding="application/x-tex"> \\lambda </annotation></semantics></math></span>'
1112+
'<span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6944em;"></span><span class="mord mathnormal">λ</span></span></span></span>';
1113+
await checkFontSizeRatio(tester,
1114+
targetHtml: html,
1115+
targetFontSizeFinder: mkTargetFontSizeFinderFromPattern(r'λ'));
1116+
}, skip: true // TODO(#46): adapt this test
1117+
// (it needs a more complex targetFontSizeFinder;
1118+
// see other uses in this file for examples.)
1119+
);
1120+
1121+
testWidgets('maintains font-size ratio with surrounding text, when showing TeX source', (tester) async {
1122+
addTearDown(testBinding.reset);
1123+
final globalSettings = testBinding.globalStore.settings;
1124+
await globalSettings.setBool(BoolGlobalSetting.renderKatex, false);
1125+
11051126
const html = '<span class="katex">'
11061127
'<span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>λ</mi></mrow>'
11071128
'<annotation encoding="application/x-tex"> \\lambda </annotation></semantics></math></span>'
@@ -1111,7 +1132,11 @@ void main() {
11111132
targetFontSizeFinder: mkTargetFontSizeFinderFromPattern(r'\lambda'));
11121133
});
11131134

1114-
testWidgets('displays KaTeX source; experimental flag default', (tester) async {
1135+
testWidgets('displays KaTeX source; experimental flag disabled', (tester) async {
1136+
addTearDown(testBinding.reset);
1137+
final globalSettings = testBinding.globalStore.settings;
1138+
await globalSettings.setBool(BoolGlobalSetting.renderKatex, false);
1139+
11151140
await prepareContent(tester, plainContent(ContentExample.mathInline.html));
11161141
tester.widget(find.text(r'\lambda', findRichText: true));
11171142
});

0 commit comments

Comments
 (0)