Dear gang, I have a paper done in ConTeXt that I would like to put online. I _could_ manually convert my input to markdown, but I was wondering if the xml/xhtml export options could be used to accomplish the same thing. Although I have done a lot of doc-to-context conversions via pandoc (doc->odt->markdown->context) I have never needed to go the other way till now. What would you guys suggest? Is there a way to convert context's xml/xhtml to markdown? (Note that I know little about html, css etc). One thing (bug?) I have noticed: bibliographic info gets lost in the backend export, so I end up with a lot of Xxxxxxxx (0000) etc in the output. Isn't there a tmp file the export backend can access to pick up this info? Any advice appreciated and Best wishes Idris
On Sun, 6 May 2012, Idris Samawi Hamid ادريس سماوي حامد wrote:
I have a paper done in ConTeXt that I would like to put online. I _could_ manually convert my input to markdown, but I was wondering if the xml/xhtml export options could be used to accomplish the same thing.
Why do you want to introduce markdown as an intermediate format? The exported XML can be used directly.
Although I have done a lot of doc-to-context conversions via pandoc (doc->odt->markdown->context) I have never needed to go the other way till now.
Pandoc has an latex reader, and it should not be too hard to write a context reader (although you end up loosing a lot of information about the structure, so it is not too useful). I had tried a proof of concept context to markdown writer by directly outputting the markdown in the pdf and converting it to text using pdftotext. I found that to be a more easily configurable way to export ConTeXt to markdown than tweaking a parser.
What would you guys suggest? Is there a way to convert context's xml/xhtml to markdown? (Note that I know little about html, css etc).
In one project, I used the ConTeXt export XML+custom CSS to display the results in a web-browser. For the most part it worked fine, although in some cases I had to tweak the lua code that generated the XML (mainly in order to control the conversion of images; Hans did add some support for image conversion after that). If you want more control, the best thing to do is to process the XML using xmlproc or something similar.
One thing (bug?) I have noticed: bibliographic info gets lost in the backend export, so I end up with a lot of Xxxxxxxx (0000) etc in the output. Isn't there a tmp file the export backend can access to pick up this info?
Best create a minimal example to show the bug. It should be relatively simple to fix. Aditya
On Sun, 06 May 2012 14:29:58 -0600, Aditya Mahajan
On Sun, 6 May 2012, Idris Samawi Hamid ادريس سماوي حامد wrote:
I have a paper done in ConTeXt that I would like to put online. I _could_ manually convert my input to markdown, but I was wondering if the xml/xhtml export options could be used to accomplish the same thing.
Why do you want to introduce markdown as an intermediate format? The exported XML can be used directly.
I opened the xml code in my browser, and there is zero formatting whatsoever. So it seems that something else is needed to get the formatting right for the web. Hence my thought of converting to markdown.
Although I have done a lot of doc-to-context conversions via pandoc (doc->odt->markdown->context) I have never needed to go the other way till now.
Pandoc has an latex reader, and it should not be too hard to write a context reader (although you end up loosing a lot of information about the structure, so it is not too useful).
Yeah, I noticed the latex input reader, and there was some discussion way back about doing a context reader as well, but I did not keep up with that discussion.
I had tried a proof of concept context to markdown writer by directly outputting the markdown in the pdf and converting it to text using pdftotext. I found that to be a more easily configurable way to export ConTeXt to markdown than tweaking a parser.
that sounds interesting, although the Arabic text that Adobe exports from a context pdf is generally not good (something I want to look at one day).
What would you guys suggest? Is there a way to convert context's xml/xhtml to markdown? (Note that I know little about html, css etc).
In one project, I used the ConTeXt export XML+custom CSS to display the results in a web-browser. For the most part it worked fine, although in some cases I had to tweak the lua code that generated the XML (mainly in order to control the conversion of images; Hans did add some support for image conversion after that).
Ok, so I have the .export and .css files. How do I turn them into something a browser can display correctly? How can I turn it into something I can copy and paste into, say, WordPress?
If you want more control, the best thing to do is to process the XML using xmlproc or something similar.
One thing (bug?) I have noticed: bibliographic info gets lost in the backend export, so I end up with a lot of Xxxxxxxx (0000) etc in the output. Isn't there a tmp file the export backend can access to pick up this info?
Best create a minimal example to show the bug. It should be relatively simple to fix.
Turns out it was my fault. I saved a project as <project>-xml.tex but did not save the corresponding bbl file to the exact same name <project>-xml.bbl. So the bbl file was not read during compile. OTOH, the list of bibliography entries all run together in the xml output, with no tagging of each entry as a separate line, etc. Thanks Aditya for your help and advice, and Best wishes Idris -- Professor Idris Samawi Hamid Department of Philosophy Colorado State University Fort Collins, CO 80523
On Sun, 6 May 2012, Idris Samawi Hamid ادريس سماوي حامد wrote:
On Sun, 06 May 2012 14:29:58 -0600, Aditya Mahajan
wrote: On Sun, 6 May 2012, Idris Samawi Hamid ادريس سماوي حامد wrote:
I have a paper done in ConTeXt that I would like to put online. I _could_ manually convert my input to markdown, but I was wondering if the xml/xhtml export options could be used to accomplish the same thing.
Why do you want to introduce markdown as an intermediate format? The exported XML can be used directly.
I opened the xml code in my browser, and there is zero formatting whatsoever. So it seems that something else is needed to get the formatting right for the web. Hence my thought of converting to markdown.
If you set \setupbackend [export=yes, xhtml=yes, css={context-export.css}, ] then the exported xhtml file should link to context-export.css file and most modern browsers render the xml correctly (at least opera, firefox, and chrome on Linux render it correctly).
Ok, so I have the .export and .css files. How do I turn them into something a browser can display correctly?
See above.
How can I turn it into something I can copy and paste into, say, WordPress?
You cannot. ConTeXt does not generate xhtml; it generate xml. The only way to convert xml to xhtml is to use a xmlproc stylesheet (or write your own xml conversion code in a programming language). Aditya
On Sun, 06 May 2012 16:37:18 -0600, Aditya Mahajan
If you set \setupbackend [export=yes, xhtml=yes, css={context-export.css}, ] then the exported xhtml file should link to context-export.css file and most modern browsers render the xml correctly (at least opera, firefox, and chrome on Linux render it correctly).
For the attached test file, xml-bib.tex (also reproduced inline below), I get in the output xml-bib-images.css xml-bib-styles.css but no context-export.css, although the resultant xml-bib.xhtml does indeed mention all three css files. Opera will open xml-bib.xhtml without any formatting. Am I still missing something? Thanks again, Aditya! Idris ====================xml-bib.tex==================== \startpublication[k=Fry95, t=book, a=Fry, y=1995, s=] \author[]{Maxwell}[]{}{Fry} \title{ Money, Interest, and Banking in Economic Development} \pubyear{{1995}} \pubname{The Johns Hopkins University Press} \city{Baltimore} \stoppublication \setupbackend [export=yes, xhtml=yes, css={context-export.css}, ] \setuppublicationlist[totalnumber={},samplesize=,author={\invertedauthor}] \def \citeauthoroutpage[#1][#2]{\cite[alternative=authoryears,left={}, right={, #2)},inbetween={ (}][#1]} \starttext According to \citeauthoroutpage[Fry95][p.~38]: \startblockquote \dots a financial system is a collection of institutions that facilitate transactions between financial resources and their users, and provide support for the real sector of the economy to convert primary resources into production for final use. \stopblockquote \input zapf \startsubject[title={References}] {\tfx \setupinterlinespace{\dontleavehmode \placepublications[criterium=all]}} \stopsubject \stoptext =====================================================
On Sun, 6 May 2012, Idris Samawi Hamid ادريس سماوي حامد wrote:
On Sun, 06 May 2012 16:37:18 -0600, Aditya Mahajan
wrote: If you set \setupbackend [export=yes, xhtml=yes, css={context-export.css}, ] then the exported xhtml file should link to context-export.css file and most modern browsers render the xml correctly (at least opera, firefox, and chrome on Linux render it correctly).
For the attached test file, xml-bib.tex (also reproduced inline below), I get in the output
xml-bib-images.css xml-bib-styles.css
but no context-export.css, although the resultant xml-bib.xhtml does indeed mention all three css files. Opera will open xml-bib.xhtml without any formatting.
Am I still missing something? Thanks again, Aditya!
You need to provide context-export.css file! There is an sample css file in the distribution. See export-example.{tex,css}. You can tweak it to style the resultant xml as you want. Aditya
On Sun, 06 May 2012 22:52:50 -0600, Aditya Mahajan
Am I still missing something? Thanks again, Aditya!
You need to provide context-export.css file! There is an sample css file in the distribution. See export-example.{tex,css}. You can tweak it to style the resultant xml as you want.
Ah! I have to write my own css file! I was thinking somehow context would export the relevant setup info in the original file to the css file... Ok, I'm much clearer now. In my current case (academic article) I might be better off just manually redoing the article in markdown rather than fiddling with css, but at some point I want to learn the latter skill as well. At least the xml export gives me a clean text I can copy from my browser to tag in md as well. That saves time. So a possible blogger-friendly workflow (at least till I gain facility with css): context->xml/xhtml->browser (copy to editor)->markdown (manual). Thanks, Aditya! Idris
On 7-5-2012 20:07, Idris Samawi Hamid ادريس سماوي حامد wrote:
On Sun, 06 May 2012 22:52:50 -0600, Aditya Mahajan
wrote: Am I still missing something? Thanks again, Aditya!
You need to provide context-export.css file! There is an sample css file in the distribution. See export-example.{tex,css}. You can tweak it to style the resultant xml as you want.
Ah! I have to write my own css file! I was thinking somehow context would export the relevant setup info in the original file to the css file... Ok, I'm much clearer now.
you can just use the example css file as starting point (make a copy) and see how bad things look (the default is quite acceptable) ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com | www.pragma-pod.nl -----------------------------------------------------------------
On Mon, 07 May 2012 12:24:44 -0600, Hans Hagen
you can just use the example css file as starting point (make a copy) and see how bad things look (the default is quite acceptable)
Actually it looks quite acceptable indeed! Just a few things need fiddling: quotation handling (block quotes and single quotes become double quotes), footnotes (should be turned into endnotes), publicationslist (each entry should be a new par) and sectioning numerals ... Some of these I can do in the css file I presume, but some may need deeper work; I'll have to spend time with it sometime. [BTW: At first glance I find all css code quite ugly and off-putting, but that's just me...] Thanks, Hans! Idris
On Mon, 07 May 2012 12:37:19 -0600, Idris Samawi Hamid ادريس سماوي حامد
[BTW: At first glance I find all css code quite ugly and off-putting, but that's just me...]
That was poorly put: What I mean is that I find css in general to be an ugly language :-) Best wishes -- Professor Idris Samawi Hamid Department of Philosophy Colorado State University Fort Collins, CO 80523
participants (3)
-
Aditya Mahajan
-
Hans Hagen
-
Idris Samawi Hamid ادريس سماوي حامد