ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* context to markdown/html
@ 2012-05-06 17:27 Idris Samawi Hamid ادريس   سماوي حامد
  2012-05-06 20:29 ` Aditya Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Idris Samawi Hamid ادريس   سماوي حامد @ 2012-05-06 17:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: context to markdown/html
  2012-05-06 17:27 context to markdown/html Idris Samawi Hamid ادريس   سماوي حامد
@ 2012-05-06 20:29 ` Aditya Mahajan
  2012-05-06 21:27   ` Idris Samawi Hamid ادريس   سماوي حامد
  0 siblings, 1 reply; 10+ messages in thread
From: Aditya Mahajan @ 2012-05-06 20:29 UTC (permalink / raw)
  To: Idris Samawi Hamid ادريس  
	سماوي حامد
  Cc: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1935 bytes --]

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

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: context to markdown/html
  2012-05-06 20:29 ` Aditya Mahajan
@ 2012-05-06 21:27   ` Idris Samawi Hamid ادريس   سماوي حامد
  2012-05-06 22:37     ` Aditya Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Idris Samawi Hamid ادريس   سماوي حامد @ 2012-05-06 21:27 UTC (permalink / raw)
  To: Aditya Mahajan; +Cc: mailing list for ConTeXt users

On Sun, 06 May 2012 14:29:58 -0600, Aditya Mahajan <adityam@umich.edu>  
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.

>> 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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: context to markdown/html
  2012-05-06 21:27   ` Idris Samawi Hamid ادريس   سماوي حامد
@ 2012-05-06 22:37     ` Aditya Mahajan
  2012-05-06 22:46       ` Idris Samawi Hamid ادريس   سماوي حامد
  0 siblings, 1 reply; 10+ messages in thread
From: Aditya Mahajan @ 2012-05-06 22:37 UTC (permalink / raw)
  To: Idris Samawi Hamid ادريس  
	سماوي حامد
  Cc: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1537 bytes --]

On Sun, 6 May 2012, Idris Samawi Hamid ادريس   سماوي حامد wrote:

> On Sun, 06 May 2012 14:29:58 -0600, Aditya Mahajan <adityam@umich.edu> 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

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: context to markdown/html
  2012-05-06 22:37     ` Aditya Mahajan
@ 2012-05-06 22:46       ` Idris Samawi Hamid ادريس   سماوي حامد
  2012-05-07  4:52         ` Aditya Mahajan
  0 siblings, 1 reply; 10+ messages in thread
From: Idris Samawi Hamid ادريس   سماوي حامد @ 2012-05-06 22:46 UTC (permalink / raw)
  To: Aditya Mahajan; +Cc: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 1916 bytes --]

On Sun, 06 May 2012 16:37:18 -0600, Aditya Mahajan <adityam@umich.edu>
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!

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
=====================================================

[-- Attachment #2: xml-bib.tex --]
[-- Type: application/x-tex, Size: 1099 bytes --]

[-- Attachment #3: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: context to markdown/html
  2012-05-06 22:46       ` Idris Samawi Hamid ادريس   سماوي حامد
@ 2012-05-07  4:52         ` Aditya Mahajan
  2012-05-07 18:07           ` Idris Samawi Hamid ادريس   سماوي حامد
  0 siblings, 1 reply; 10+ messages in thread
From: Aditya Mahajan @ 2012-05-07  4:52 UTC (permalink / raw)
  To: Idris Samawi Hamid ادريس  
	سماوي حامد
  Cc: mailing list for ConTeXt users

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1053 bytes --]

On Sun, 6 May 2012, Idris Samawi Hamid ادريس   سماوي حامد wrote:

> On Sun, 06 May 2012 16:37:18 -0600, Aditya Mahajan <adityam@umich.edu>
> 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

[-- Attachment #2: Type: text/plain, Size: 485 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: context to markdown/html
  2012-05-07  4:52         ` Aditya Mahajan
@ 2012-05-07 18:07           ` Idris Samawi Hamid ادريس   سماوي حامد
  2012-05-07 18:24             ` Hans Hagen
  0 siblings, 1 reply; 10+ messages in thread
From: Idris Samawi Hamid ادريس   سماوي حامد @ 2012-05-07 18:07 UTC (permalink / raw)
  To: Aditya Mahajan

On Sun, 06 May 2012 22:52:50 -0600, Aditya Mahajan <adityam@umich.edu>
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.

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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: context to markdown/html
  2012-05-07 18:07           ` Idris Samawi Hamid ادريس   سماوي حامد
@ 2012-05-07 18:24             ` Hans Hagen
  2012-05-07 18:37               ` Idris Samawi Hamid ادريس   سماوي حامد
  0 siblings, 1 reply; 10+ messages in thread
From: Hans Hagen @ 2012-05-07 18:24 UTC (permalink / raw)
  To: mailing list for ConTeXt users
  Cc: Idris Samawi Hamid ادريس
	سماوي حامد

On 7-5-2012 20:07, Idris Samawi Hamid ادريس   سماوي حامد wrote:
> On Sun, 06 May 2012 22:52:50 -0600, Aditya Mahajan <adityam@umich.edu>
> 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
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: context to markdown/html
  2012-05-07 18:24             ` Hans Hagen
@ 2012-05-07 18:37               ` Idris Samawi Hamid ادريس   سماوي حامد
  2012-05-07 18:41                 ` Idris Samawi Hamid ادريس   سماوي حامد
  0 siblings, 1 reply; 10+ messages in thread
From: Idris Samawi Hamid ادريس   سماوي حامد @ 2012-05-07 18:37 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Hans Hagen

On Mon, 07 May 2012 12:24:44 -0600, Hans Hagen <pragma@wxs.nl> wrote:

> 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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: context to markdown/html
  2012-05-07 18:37               ` Idris Samawi Hamid ادريس   سماوي حامد
@ 2012-05-07 18:41                 ` Idris Samawi Hamid ادريس   سماوي حامد
  0 siblings, 0 replies; 10+ messages in thread
From: Idris Samawi Hamid ادريس   سماوي حامد @ 2012-05-07 18:41 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Hans Hagen

On Mon, 07 May 2012 12:37:19 -0600, Idris Samawi Hamid ادريس   سماوي حامد  
<ishamid@colostate.edu> wrote:

> [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
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-05-07 18:41 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-06 17:27 context to markdown/html Idris Samawi Hamid ادريس   سماوي حامد
2012-05-06 20:29 ` Aditya Mahajan
2012-05-06 21:27   ` Idris Samawi Hamid ادريس   سماوي حامد
2012-05-06 22:37     ` Aditya Mahajan
2012-05-06 22:46       ` Idris Samawi Hamid ادريس   سماوي حامد
2012-05-07  4:52         ` Aditya Mahajan
2012-05-07 18:07           ` Idris Samawi Hamid ادريس   سماوي حامد
2012-05-07 18:24             ` Hans Hagen
2012-05-07 18:37               ` Idris Samawi Hamid ادريس   سماوي حامد
2012-05-07 18:41                 ` Idris Samawi Hamid ادريس   سماوي حامد

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).