% Enable hyperlinks
\setupinteraction
  [state=start,
  style=,
  color=,
  contrastcolor=]
\setupurl[style=]

% make chapter, section bookmarks visible when opening document
\placebookmarks[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][chapter, section]
\setupinteractionscreen[option={bookmark,title}]

\setuppagenumbering[location={footer,middle}]
\setupstructure[state=start,method=auto]

% use microtypography
\definefontfeature[default][default][script=latn, protrusion=quality, expansion=quality, itlc=yes, textitalics=yes, onum=yes, pnum=yes]
\definefontfeature[default:tnum][default][tnum=yes, pnum=no]
\definefontfeature[smallcaps][script=latn, protrusion=quality, expansion=quality, smcp=yes, onum=yes, pnum=yes]
\setupalign[hz,hanging]
\setupitaliccorrection[global, always]

\setupbodyfontenvironment[default][em=italic] % use italic as em, not slanted

\definefallbackfamily[mainface][rm][CMU Serif][preset=range:greek, force=yes]
\definefontfamily[mainface][rm][Latin Modern Roman]
\definefontfamily[mainface][mm][Latin Modern Math]
\definefontfamily[mainface][ss][Latin Modern Sans]
\definefontfamily[mainface][tt][Latin Modern Typewriter][features=none]
\setupbodyfont[mainface]

\setupwhitespace[medium]

\setuphead[chapter]            [style=\tfd\setupinterlinespace,header=empty]
\setuphead[section]            [style=\tfc\setupinterlinespace]
\setuphead[subsection]         [style=\tfb\setupinterlinespace]
\setuphead[subsubsection]      [style=\bf]
\setuphead[subsubsubsection]   [style=\sc]
\setuphead[subsubsubsubsection][style=\it]

\definesectionlevels
   [default]
   [section, subsection, subsubsection, subsubsubsection, subsubsubsubsection]

\setuphead[chapter, section, subsection, subsubsection, subsubsubsection, subsubsubsubsection][number=no]

\definedescription
  [description]
  [headstyle=bold, style=normal, location=hanging, width=broad, margin=1cm, alternative=hanging]

\setupitemize[autointro]    % prevent orphan list intro
\setupitemize[indentnext=no]

\defineitemgroup[enumerate]
\setupenumerate[each][fit][itemalign=left,distance=.5em,style={\feature[+][default:tnum]}]

\setupfloat[figure][default={here,nonumber}]
\setupfloat[table][default={here,nonumber}]

\setupxtable[frame=off]
\setupxtable[head][topframe=on]
\setupxtable[body][]
\setupxtable[foot][]
\setupxtable[lastrow][bottomframe=on]


\starttext

\startsectionlevel[title={Empty Divs and
Spans},reference={empty-divs-and-spans}]

Some text and

div contents

and more text.

Next paragraph with a span and a word-thatincludesaspanright?

\stopsectionlevel

\startsectionlevel[title={Directionality},reference={directionality}]

Some text and

\startalignment[righttoleft]
rtl div contents

\stopalignment

and more text.

\startalignment[lefttoright]
and a ltr div. with a {\righttoleft rtl span}.

\stopalignment

Next paragraph with a {\righttoleft rtl span} and a
word-that-includesa{\lefttoright ltrspan}right?

\stopsectionlevel

\startsectionlevel[title={Languages},reference={languages}]

Some text and

\start\language[de]
German div contents

\stop

and more text.

Next paragraph with a {\language[en-gb]British span} and a
word-that-includesa{\language[de-ch]Swiss German span}right?

Some {\language[es]Spanish text}.

\stopsectionlevel

\startsectionlevel[title={Combined},reference={combined}]

Some text and

\start\language[fr]
\startalignment[righttoleft]
French rtl div contents

\stopalignment
\stop

and more text.

Next paragraph with a {\language[en-gb]{\lefttoright British ltr span}}
and a word-that-includesa{\language[de-ch]{\lefttoright Swiss German ltr
span}}right?

\stopsectionlevel

\stoptext
