% engine=luatex

\setuppapersize[S6][S6]
\setupcolors[state=start]
\setuptyping[option=color]
\setupitemize[each][paragraph,inmargin][headstyle=bold]

\startbuffer[dirpreamble]
% Directionality preamble

\def\GLOBALLR{\pagedir TLT \bodydir TLT}
\def\GLOBALRL{\pagedir TRT \bodydir TRT}
\def\PARLR	 {\pardir  TLT}
\def\PARRL	 {\pardir  TRT}
\def\CHARLR	 {\textdir TLT}
\def\CHARRL	 {\textdir TRT}
\definestartstop[RL]
				[commands={\textdir TRT}] 
\definestartstop[LR]
				[commands={\textdir TLT}] 
\definestartstop[RLpar]
				[commands={\pardir TRT}] 
\definestartstop[LRpar]
				[commands={\pardir TLT}]  
				
\GLOBALRL % Whole document              RL
\PARRL   % Default paragraph dir        RL	
\CHARRL  % Default character-string dir RL	
\stopbuffer

\getbuffer[dirpreamble] 
 
\starttext

%\startLRpar
\startLR
\typebuffer[dirpreamble]
\stopLR
%\stopLRpar 
\page

\startitemize[n]

\head {\CHARLR RL RL RL}

\startbuffer[RL_RL_RL]

\startRLpar
\dorecurse{8}{  This is a test of an RL document, with RL 
paragraphs, and  with the RL direction for all character 
strings.}\par \blank

\parfillskip=0em 
\dorecurse{8}{  This is a test of an RL document, with RL 
paragraphs, and with the RL direction for all character 
strings.}\par
\stopRLpar
\stopbuffer

%\startLRpar
\startLR
\typebuffer[RL_RL_RL]
\stopLR
%\stopLRpar  
\page 
\getbuffer[RL_RL_RL]
\page

\head {\CHARLR RL RL LR}

\startbuffer[RL_RL_LR]
\startRLpar
\dorecurse{4}{ This is a test of an RL document, with RL 
paragraphs, with insertions 
	\startLR\bf 
	This is a test of LR character-string insertions within 
	an RL paragraph.%
	% The percent sign is neccessary.	
	\stopLR\ 
of LR character strings.}\par \blank

\parfillskip=0em 
\dorecurse{4}{ This is a test of an RL document, with RL 
paragraphs, with insertions 
	\startLR\bf 
	This is a test of LR character-string insertions within
	an RL paragraph.%
	% The percent sign is neccessary.	
	\stopLR\ 
of LR character strings.}\par
\stopRLpar
\stopbuffer

%\startLRpar
\startLR
\typebuffer[RL_RL_LR]
\stopLR
%\stopLRpar  
\page 
\getbuffer[RL_RL_LR]
\page

\head {\CHARLR RL LR LR}

\startbuffer[RL_LR_LR]
\startLRpar\startLR 
\dorecurse{8}{ This is a test of an RL document, with LR 
paragraphs, and with the LR direction for all character 
strings.}\par \blank

\parfillskip=0em 
\dorecurse{8}{ This is a test of an RL document, with LR 
paragraphs, and with the LR direction for all character 
strings.}\par
\stopLR\stopLRpar
\stopbuffer

%\startLRpar
\startLR
\typebuffer[RL_LR_LR]
\stopLR
%\stopLRpar 
\page 
\getbuffer[RL_LR_LR]
\page

\head {\CHARLR RL LR RL}

\startbuffer[RL_LR_RL]
\startLRpar\startLR
\dorecurse{4}{ This is a test of an RL document, with LR 
paragraphs, with insertions 
	\startRL\bf 
	This is a test of RL character-string insertions within 
	an LR paragraph.%
	% The percent sign is neccessary.	
	\stopRL\ 
of RL character strings.}\par \blank

\parfillskip=0em 
\dorecurse{4}{ This is a test of an RL document, with LR 
paragraphs, with insertions 
	\startRL\bf 
	This is a test of RL character-string insertions within 
	an LR paragraph.%
	% The percent sign is neccessary.	
	\stopRL\ 
of RL character strings.}\par 
\stopLR\stopLRpar
\stopbuffer

%\startLRpar
\startLR
\typebuffer[RL_LR_RL]
\stopLR
%\stopLRpar 
\page
\getbuffer[RL_LR_RL]

\stopitemize

\stoptext 