[NTG-context] Export: \setuphemistich distance=

Wolfgang Schuster schuster.wolfgang at gmail.com
Wed Mar 18 21:34:25 CET 2015


> Am 18.03.2015 um 20:45 schrieb Idris Samawi Hamid ادريس سماوي حامد <ishamid at colostate.edu>:
> 
> On Wed, 18 Mar 2015 11:51:13 -0600, Wolfgang Schuster <schuster.wolfgang at gmail.com <mailto:schuster.wolfgang at gmail.com>> wrote:
> 
>> 
>>> Am 18.03.2015 um 15:04 schrieb Idris Samawi Hamid ادريس سماوي حامد <ishamid at colostate.edu>:
>>> 
>>> Dear gang,
>>> 
>>> In the attached, we export hemistiches:
>>> 
>>> ===============
>>> \setupexport[cssfile=sh_ahmad-qajar.css]
>>> \setupbackend[export=yes]
>>> 
>>> \usemodule[hemistich]
>>> 
>>> \setuphemistich
>>> [width=local,
>>>  distance=1\emwidth,
>>>  separator=]
>>> 
>>>  \setuphemistich
>>> [leftcolor=,
>>>  separatorcolor=,
>>>  rightcolor=]
>>> 
>>>  \setuphemistich
>>> % [separator=\vl\hskip.25em\vl]
>>> [separator=]
>>> 
>>> %% We need separate lines in the export, so use \start|stoplines
>>> \definestartstop[VERSES][before={\blank[medium]\startlines \noindentation},after={\stoplines \blank[medium]}]
>>> \starttext
>>> \startVERSES
>>> \hemistiches{Become a shunner of your affairs;}{Entrust all affairs to the Decision.}
>>> \hemistiches{Thus tight spaces will often widen;}{And open spaces will often get tight.}
>>> \stopVERSES
>>> \stoptext
>>> ===============
>>> 
>>> In the output we get
>>> 
>>> ===============
>>> <div>
>>> <div class="lines">
>>> <div class="line"><div class="line">Become a shunner of your affairs;Entrust all affairs to the Decision.</div><div class="line">Thus tight spaces will often widen;And open spaces will often get tight.</div></div>
>>> </div>
>>> </div>
>>> ===============
>>> 
>>> Is there anyway to tag and export the distance info:
>>> 
>>> distance=1\emwidth
>>> 
>>> so that we can get some space in the xhtml. Note that I do not expect any of the alignment that the hemistiches module provides. Just some reasonable space.
>>> 
>>> That said: How do I design a \start|stophemistiches environment that would get tagged in the output as such (i.e., <div class="hemistiches">)?
>> 
>> You have to add tag commands in the source of the module to get tags in the exported text.
>> 
>> The distance between both texts in the output can be set with CSS but first you need tags.
> 
> Hi Wolfgang,
> 
> Can you give an example of adding tag commands to a macro or to a \start-stop<command>? Thanks as always for the clarity and


Something like this should do it for the hemistiches module.

\unexpanded\def\dodohemistiches#1[#2]#3#4%
  {\dontleavehmode
   \begingroup
   \doifassignmentelse{#2}
     {\edef\currenthemistich{#1}%
      \setupcurrenthemistich[#2]}
     {\def\currenthemistich{#2}}%
   \doifelse{\hemistichparameter\c!width}\v!local
     {\scratchwidth\availablehsize}
     {\scratchwidth\hemistichparameter\c!width\relax}%
   \spaceskip\zeropoint\s!plus\plusone\s!fill\relax
+  \dostarttagged\t!division\currenthemistich
   \hbox to \scratchwidth\bgroup
     \scratchwidth.5\dimexpr\scratchwidth-\hemistichparameter\c!distance\relax
     \hbox to \scratchwidth\bgroup
+      \dostarttagged\t!construct\c!lefttext
       \usehemistichstyleandcolor\c!leftstyle\c!leftcolor#3%
+      \dostoptagged
     \egroup
     \hss
     \begingroup
+      \dostarttagged\t!construct\c!separator
       \usehemistichstyleandcolor\c!separatorstyle\c!separatorcolor
       \hemistichparameter\c!separator
+      \dostoptagged
     \endgroup
     \hss
     \hbox to \scratchwidth\bgroup
+      \dostarttagged\t!construct\c!righttext
       \usehemistichstyleandcolor\c!rightstyle\c!rightcolor#4%
+      \dostoptagged
     \egroup
   \egroup
+  \dostoptagged
   \endgroup}

Wolfgang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ntg.nl/pipermail/ntg-context/attachments/20150318/705790f4/attachment-0001.html>


More information about the ntg-context mailing list