I am having problems with the directionality of numbers and mirrored characters (like parentheses). When using bidi, the numbers are inverted (5102 instead of 2015); with the explicit commands, the mirrored characters are inverted as well.

For reasons I think I understand, this is only happening in the text: the problem occurs with numbers in headings (chapters, etc.), and likewise in the main of the text. The digits of footnotes, linemargin numbers, and page numbers are correctly arranged.

I have learnt that if I add the option [numbercommand=\lefttoright] to \setuphead[section], I can get the digits in the section number to be in the right order. But this does not address the problem of other numbers in the text.

How do I solve this? I am happy to abandon the conveniences of bidi, as Idris suggests might be needed (see below), but it didn’t get any easier when trying to do it manually. See MWE below.

With thanks,
Talal

p.s. The Wiki page on "Arabic and Hebrew" is out of date, instructing the use of \setcharactermirroring[1] which is clearly deprecated now in favour of \setupdirections[bidi=global]. I am happy to update the wiki page once I get my head around things. Does anybody have an authoritative list of the various commands related to right-to-left, as well as what combinations are not needed (e.g. are \setupalign[r2l] and \righttoleft overlapping, or do they play different roles)?

========
%%% LANGUAGE AND FONTS
\mainlanguage[arabic]
\definefontfamily [mainface] [rm] [ALM Fixed][range=arabic,features=arabic]   
\setupbodyfont[mainface,12pt]

%\setupdirections[bidi=global]
\setupalign[r2l]
%\righttoleft

%% HEADINGS

\setuphead[chapter,section][
conversion=myconversion,
% numbercommand=\lefttoright % <-- toggle
]
\setuplinenumbering[conversion=myconversion]
\setupnotations[footnote][numberconversion=myconversion]
\setupnotations[linenote][numberconversion=myconversion]
\setuppagenumber[numberconversion=myconversion]

\defineconversion
[myconversion]
[١,٢,٣,٤,٥,٦,٧,٨,٩,١٠,
١١,١٢,١٣,١٤,١٥,١٦,١٧,١٨,١٩,٢٠,
۲۱,۲۲,۲۳,۲٤,۲٥,۲٦,۲۷,۲۸,۲۹,۳۰,
٣١,٣٢,٣٣,٣٤,٣٥,٣٦,٣٧,٣٨,٣٩,٤٠,
٤١,٤٢,٤٣,٤٤,٤٥,٤٦,٤٧,٤٨,٤٩,٥٠,
٥١,٥٢,٥٣,٥٤,٥٥,٥٦,٥٧,٥٨,٥٩,٦٠,
٦١,٦٢,٦٣,٦٤,٦٥,٦٦,٦٧,٦٨,٦٩,٧٠,
٧١,٧٢,٧٣,٧٤,٧٥,٧٦,٧٧,٧٨,٧٩,٨٠,
٨١,٨٢,٨٣,٨٤,٨٥,٨٦,٨٧,٨٨,٨٩,٩٠,
٩١,٩٢,٩٣,٩٤,٩٥,٩٦,٩٧,٩٨,٩٩,١٠٠,
١٠١,١٠٢,١٠٣,١٠٤,١٠٥,١٠٦,١٠٧,١٠٨,١٠٩,١١٠,
١١١,١١٢,١١٣,١١٤,١١٥,١١٦,١١٧,١١٨,١١٩,١٢٠,
١٢١,١٢٢,١٢٣,١٢٤,١٢٥,١٢٦,١٢٧,١٢٨,١٢٩,١٣٠,
١٣١,١٣٢,١٣٣,١٣٤,١٣٥,١٣٦,١٣٧,١٣٨,١٣٩,١١٣٠,
١٤١,١٤٢,١٤٣,١٤٤,١٤٥,١٤٦,١٤٧,١٤٨,١٤٩,١٥٠,
١٥١,١٥٢,١٥٣,١٥٤,١٥٥,١٥٦,١٥٧,١٥٨,١٥٩,١٦٠,
١٦١,١٦٢,١٦٣,١٦٤,١٦٥,١٦٦,١٦٧,١٦٨,١٦٩,١٧٠,
١٧١,١٧٢,١٧٣,١٧٤,١٧٥,١٧٦,١٧٧,١٧٨,١٧٩,١٨٠,
١٨١,١٨٢,١٨٣,١٨٤,١٨٥,١٨٦,١٨٧,١٨٨,١٨٩,١٩٠,
١٩١,١٩٢,١٩٣,١٩٤,١٩٥,١٩٦,١٩٧,١٩٨,١٩٩,٢٠٠,
٢٠١,٢٠٢,٢٠٣,٢٠٤,٢٠٥,٢٠٦,٢٠٧,٢٠٨,٢٠٩,٢١٠,
٢١١,٢١٢,٢١٣,٢١٤,٢١٥,٢١٦,٢١٧,٢١٨,٢١٩,٢٢٠,
٢٢١,٢٢٢,٢٢٣,٢٢٤,٢٢٥,٢٢٦,٢٢٧,٢٢٨,٢٢٩,٢٣٠,
٢٣١,٢٣٢,٢٣٣,٢٣٤,٢٣٥,٢٣٦,٢٣٧,٢٣٨,٢٣٩,٢٢٣٠,
٢٤١,٢٤٢,٢٤٣,٢٤٤,٢٤٥,٢٤٦,٢٤٧,٢٤٨,٢٤٩,٢٥٠,
٢٥١,٢٥٢,٢٥٣,٢٥٤,٢٥٥,٢٥٦,٢٥٧,٢٥٨,٢٥٩,٢٦٠,
٢٦١,٢٦٢,٢٦٣,٢٦٤,٢٦٥,٢٦٦,٢٦٧,٢٦٨,٢٦٩,٢٧٠,
٢٧١,٢٧٢,٢٧٣,٢٧٤,٢٧٥,٢٧٦,٢٧٧,٢٧٨,٢٧٩,٢٨٠,
٢٨١,٢٨٢,٢٨٣,٢٨٤,٢٨٥,٢٨٦,٢٨٧,٢٨٨,٢٨٩,٢٩٠,
٢٩١,٢٩٢,٢٩٣,٢٩٤,٢٩٥,٢٩٦,٢٩٧,٢٩٨,٢٩٩,٣٠٠,
]

%%% DOCUMENT

\starttext \showframe 

\section{section one}

\startlinenumbering
\input tufte
\input tufte
\stoplinenumbering

\dorecurse{20}{
\section{محمد الجمل (١٨٧٢—١٩٢٣)}
مرحباً باعالم . ١٢٣٤٥٦٧٨٩٠ مرحباً بالعالم. ولد عام١٩٣٤.
\footnote{تعليقة لطيفة.}
\pagebreak
}

\stoptext
=============