%%
%% This is file `mathwrap.sty',
%% generated with the docstrip utility.
%%
%% Copyright (C) 2026 by Lee Yiu Sing <yslee.pika@connect.hku.hk>
%% ---------------------------------------------------------------------------
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   https://latex-project.org
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2008-05-04 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% The Current Maintainer of this work is Lee Yiu Sing.
%%
%% This work consists of the file mathwrap.sty.
%%

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mathwrap}[2026/11/14 Automatic Inline Math Wrapping]

\AtBeginDocument{%
  \global\mathchardef\stdcomma=\mathcode`,%
  \global\mathcode`,="8000\relax
}

\begingroup
  \catcode`,=\active
  \gdef,{\stdcomma\ifmmode\ifinner\penalty0\mskip0mu plus 2mu\relax\fi\fi}%
\endgroup

\binoppenalty=100\relax
\relpenalty=100\relax
\emergencystretch=1em\relax

\endinput