Handle rich text sizes and classify math conservatively
This commit is contained in:
@@ -36,9 +36,10 @@ type Config struct {
|
||||
// back to PNG and PDF only.
|
||||
RichTextEnabled bool
|
||||
|
||||
// RichDefaultMath controls how the rich format treats a bare source
|
||||
// (no math delimiters, no text-mode command): true renders it as a math
|
||||
// expression, false parses it as text so formulas need $...$ delimiters.
|
||||
// RichDefaultMath controls how the rich format treats ambiguous bare
|
||||
// source. It defaults to false so non-math LaTeX is never guessed to be
|
||||
// math; formulas need explicit delimiters unless operators opt into the
|
||||
// legacy behavior.
|
||||
RichDefaultMath bool
|
||||
|
||||
RenderDPI int
|
||||
@@ -81,7 +82,7 @@ func Load() (*Config, error) {
|
||||
if cfg.RichTextEnabled, err = getenvBool("RICH_TEXT_ENABLED", true); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cfg.RichDefaultMath, err = getenvBool("RICH_DEFAULT_MATH", true); err != nil {
|
||||
if cfg.RichDefaultMath, err = getenvBool("RICH_DEFAULT_MATH", false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if cfg.RenderDPI, err = getenvInt("RENDER_DPI", 600); err != nil {
|
||||
|
||||
@@ -39,8 +39,8 @@ func TestLoadDefaults(t *testing.T) {
|
||||
if !cfg.RichTextEnabled {
|
||||
t.Error("RichTextEnabled = false, want true by default")
|
||||
}
|
||||
if !cfg.RichDefaultMath {
|
||||
t.Error("RichDefaultMath = false, want true by default")
|
||||
if cfg.RichDefaultMath {
|
||||
t.Error("RichDefaultMath = true, want false by default")
|
||||
}
|
||||
if cfg.S3PresignTTL != time.Hour {
|
||||
t.Errorf("S3PresignTTL = %s, want 1h", cfg.S3PresignTTL)
|
||||
@@ -80,13 +80,13 @@ func TestLoadRejectsIncompleteS3(t *testing.T) {
|
||||
|
||||
func TestLoadRichDefaultMathToggle(t *testing.T) {
|
||||
setRequired(t)
|
||||
t.Setenv("RICH_DEFAULT_MATH", "false")
|
||||
t.Setenv("RICH_DEFAULT_MATH", "true")
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatalf("Load: %v", err)
|
||||
}
|
||||
if cfg.RichDefaultMath {
|
||||
t.Error("RichDefaultMath = true, want false")
|
||||
if !cfg.RichDefaultMath {
|
||||
t.Error("RichDefaultMath = false, want true")
|
||||
}
|
||||
|
||||
t.Setenv("RICH_DEFAULT_MATH", "banana")
|
||||
|
||||
Reference in New Issue
Block a user