Dear gang, Ok, I'm rolling up my sleeves and taking another stab at exporting to xhtml (maybe even epub). Major project, so taking this one small step at a time. The immediate aim is to get correct output in a browser (I use Opera, and Chrome as a control). Test files attached. Immediate problem is highlights. ============export-highlight.tex============== \setupbackend [export=yes,css=highlight.css] \definehighlight[emphasis] [style=italic] \definehighlight[important][style=bold] \definehighlight[regular][style=\tf] \starttext \startchapter[title=Highlights] \startparagraph This is \emphasis{emphasis}. This is \important{important}. This is \regular{regular}. This is \emphasis{some emphasized text, with \regular{regular} in between}. This is \important{some important text, with \regular{regular} in between}. \stopparagraph \stopchapter \stoptext =============================================== In highlight.css (copied from export-sample.css and modified) I added these lines: ================== highlight [detail="emphasis"]{ font-weight : italic ; } highlight [detail="important"]{ font-weight : bold ; } highlight [detail="regular"]{ font-weight : regular ; } ================== Results: =======export-highlight-tag.xhtml======== <sectioncontent> <paragraph>This is <highlight detail="emphasis">emphasis</highlight>. This is <highlight detail="important">important</highlight>. This is <highlight detail="regular">regular</highlight>. <break/> This is <highlight detail="emphasis">some emphasized text, with <highlight detail="regular">regular</highlight> in between</highlight>. <break/> This is <highlight detail="important">some important text, with <highlight detail="regular">regular</highlight> in between</highlight>.</paragraph> </sectioncontent> =======export-highlight-div.xhtml======== <div class="paragraph">This is <div class="highlight emphasis">emphasis</div>. This is <div class="highlight important">important</div>. This is <div class="highlight regular">regular</div>. <div class="break"><!--empty--></div> This is <div class="highlight emphasis">some emphasized text, with <div class="highlight regular">regular</div> in between</div>. <div class="break"><!--empty--></div> This is <div class="highlight important">some important text, with <div class="highlight regular">regular</div> in between</div>.</div> ========================================= Observation: Opera won't render *-raw.xml, so we ignore that file. In a browser we have Challenge 1: Neither export-highlight-tag.xhtml nor export-highlight-div.xhtml renders the highlights. What do we need to do? Challenge 2: export-highlight-div.xhtml breaks the line before a highlight as well as after a highlight. What is missing here? Aim: To turn my current project into an epub, or at least something that can be viewed in a browser (xhtml). Caveat: I don't know much web development (css, xhtml, div, etc) but am willing to work with what I have... but only IF there is a finish line. If there is no finish line (i.e., things are too broken at the moment to get the mission accomplished via what ConTeXt and CSS provide) kindly let me know so I can stop now! Henning Hraban Ramm and Aditya Mahajan mentioned XSLT stylesheets, but this is probably way above my paygrade, unless someone can give me very simple newbie pointers. Thanks to all in advance and Best wishes Idris -- Idris Samawi Hamid Professor of Philosophy Colorado State University Fort Collins, CO 80523
On Sun, 15 Mar 2015, Idris Samawi Hamid ادريس سماوي حامد wrote:
[Dear Aditya, I sent this to the list; sending it to you to have a look as well. Any assistance is much appreciated, especially if I have to go the xslt route! Thanks in advance!!]
It has been almost 1.5 years since I had a serious look at XML generated by ConTeXt. At that time, ConTeXt did not generate XHTML, so I thought that one has to go through the XLST route. But, it looks that things have changed.
=======export-highlight-div.xhtml======== <div class="paragraph">This is <div class="highlight emphasis">emphasis</div>. This is <div class="highlight important">important</div>. This is <div class="highlight regular">regular</div>. <div class="break"><!--empty--></div> This is <div class="highlight emphasis">some emphasized text, with <div class="highlight regular">regular</div> in between</div>. <div class="break"><!--empty--></div> This is <div class="highlight important">some important text, with <div class="highlight regular">regular</div> in between</div>.</div> =========================================
This is very well formed XHTML. You just need a proper CSS stylesheet to do the correct rednering. Something like: .highlight.important { font-weight: bold; } .highlight.emphasis { font-style: italic; } etc. Aditya
Ok, I've made some progress:
On Sun, 15 Mar 2015 17:01:16 -0600, Idris Samawi Hamid ادريس سماوي حامد
============export-highlight.tex============== \setupbackend [export=yes,css=highlight.css]
\setupexport[cssfile=highlight.css] \setupbackend[export=yes]
\definehighlight[emphasis] [style=italic] \definehighlight[important][style=bold] \definehighlight[regular][style=\tf]
\starttext
\startchapter[title=Highlights] \startparagraph This is \emphasis{emphasis}. This is \important{important}. This is \regular{regular}.
This is \emphasis{some emphasized text, with \regular{regular} in between}.
This is \important{some important text, with \regular{regular} in between}. \stopparagraph \stopchapter \stoptext ===============================================
In highlight.css (copied from export-sample.css and modified) I added these lines:
================== highlight [detail="emphasis"]{ font-weight : italic ; }
highlight [detail="important"]{ font-weight : bold ; }
highlight [detail="regular"]{ font-weight : regular ; } ==================
Syntax correction (thanks Aditya!): .highlight.emphasis { font-style: italic; } etc.
Challenge 1: Neither export-highlight-tag.xhtml nor export-highlight-div.xhtml renders the highlights. What do we need to do?
For italic, see above. For bold, we need font-weight: bold;
Challenge 2: export-highlight-div.xhtml breaks the line before a highlight as well as after a highlight. What is missing here?
display: inline; So here is exactly what we need: .highlight.important { font-weight: bold; font-style: normal; display: inline; } .highlight.emphasis { font-weight: normal; font-style: italic; display: inline; } .highlight.regular { font-weight: normal; font-style: normal; display: inline; } Now export-highlight-div.xhtml renders in the browser exactly as in export-highlight.pdf. This is progress: a first step! Best wishes Idris -- Idris Samawi Hamid Professor of Philosophy Colorado State University Fort Collins, CO 80523
participants (2)
-
Aditya Mahajan
-
Idris Samawi Hamid ادريس سماوي ح امد