* Code blocks in latex @ 2019-05-29 23:22 Umut Acar [not found] ` <b08442d7-e415-4491-b841-705cf46ddc1f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Umut Acar @ 2019-05-29 23:22 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 328 bytes --] Is it possible to specify a programming language for lstlisting environments in latex? This is for latex to html translation with syntax highlighting. I got good results with markdown and html translation by using Kate XML specifications but the analogous approach doesn't seem to work with latex and lstlistings. Thank you! ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <b08442d7-e415-4491-b841-705cf46ddc1f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Code blocks in latex [not found] ` <b08442d7-e415-4491-b841-705cf46ddc1f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2019-05-30 5:20 ` John MacFarlane [not found] ` <m2zhn4iklq.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: John MacFarlane @ 2019-05-30 5:20 UTC (permalink / raw) To: Umut Acar, pandoc-discuss Yes, you can. Not as many languages are supported. Umut Acar <umutacar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > Is it possible to specify a programming language for lstlisting environments in latex? This is for latex to html translation with syntax highlighting. > > I got good results with markdown and html translation by using Kate XML specifications but the analogous approach doesn't seem to work with latex and lstlistings. > > Thank you! > > -- > You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/b08442d7-e415-4491-b841-705cf46ddc1f%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <m2zhn4iklq.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>]
* Re: Code blocks in latex [not found] ` <m2zhn4iklq.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> @ 2019-05-30 14:07 ` Umut Acar [not found] ` <532362a8-94bf-4c7a-846e-896951036b5c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Umut Acar @ 2019-05-30 14:07 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 2186 bytes --] Indeed, it works for quite a few standard languages but are custom language definitions supported? In markdown -->html conversion via custom XML spec's (Kate) seems possible. I got good results with that. Is this not supported for LaTeX --> html? BTW, in case this question seems esoteric: I wish to use pandoc for teaching computer science courses, where we define our own languages for instructional purposes. On Thursday, May 30, 2019 at 1:21:04 AM UTC-4, John MacFarlane wrote: > > > Yes, you can. Not as many languages are supported. > > Umut Acar <umut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: > > > Is it possible to specify a programming language for lstlisting > environments in latex? This is for latex to html translation with syntax > highlighting. > > > > I got good results with markdown and html translation by using Kate XML > specifications but the analogous approach doesn't seem to work with latex > and lstlistings. > > > > Thank you! > > > > -- > > You received this message because you are subscribed to the Google > Groups "pandoc-discuss" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org <javascript:>. > > To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > <javascript:>. > > To view this discussion on the web visit > https://groups.google.com/d/msgid/pandoc-discuss/b08442d7-e415-4491-b841-705cf46ddc1f%40googlegroups.com. > > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/532362a8-94bf-4c7a-846e-896951036b5c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 4128 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <532362a8-94bf-4c7a-846e-896951036b5c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Code blocks in latex [not found] ` <532362a8-94bf-4c7a-846e-896951036b5c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2019-05-30 17:37 ` John MacFarlane [not found] ` <yh480kef4f6dy1.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: John MacFarlane @ 2019-05-30 17:37 UTC (permalink / raw) To: Umut Acar, pandoc-discuss Umut Acar <umutacar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > Indeed, it works for quite a few standard languages but are custom language > definitions supported? In markdown -->html conversion via custom XML > spec's (Kate) seems possible. I got good results with that. Is this not > supported for LaTeX --> html? To be clear, do I understand correctly that you're converting from LaTeX to HTML, and you want LaTeX lstlistings environments to be converted with highlighting? That will work with recognized languages (those that lstlisting environment supports). And you can make it work with unrecognized languages, by using a filter. Note: % pandoc -f latex -t native \begin{lstlisting}[language=foobar] hi = 3 \end{lstlisting} ^D [CodeBlock ("",[],[("language","foobar")]) "hi = 3"] What you need to do highlighting (using --syntax-definitio=foobar.xml) is rather [CodeBlock ("",["foobar"],[]) "hi = 3"] The solution is to use a simple lua filter that finds code blocks with a language attribute and makes its value a class. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <yh480kef4f6dy1.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>]
* Re: Code blocks in latex [not found] ` <yh480kef4f6dy1.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> @ 2019-05-30 17:38 ` John MacFarlane [not found] ` <yh480kblzj6dwt.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: John MacFarlane @ 2019-05-30 17:38 UTC (permalink / raw) To: Umut Acar, pandoc-discuss John MacFarlane <jgm-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes: > Umut Acar <umutacar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > >> Indeed, it works for quite a few standard languages but are custom language >> definitions supported? In markdown -->html conversion via custom XML >> spec's (Kate) seems possible. I got good results with that. Is this not >> supported for LaTeX --> html? > > To be clear, do I understand correctly that you're > converting from LaTeX to HTML, and you want LaTeX > lstlistings environments to be converted with > highlighting? > > That will work with recognized languages (those that > lstlisting environment supports). And you can make > it work with unrecognized languages, by using a filter. > Note: > > % pandoc -f latex -t native > \begin{lstlisting}[language=foobar] > hi = 3 > \end{lstlisting} > ^D > [CodeBlock ("",[],[("language","foobar")]) "hi = 3"] > > What you need to do highlighting (using > --syntax-definitio=foobar.xml) is rather > > [CodeBlock ("",["foobar"],[]) "hi = 3"] > > The solution is to use a simple lua filter > that finds code blocks with a language attribute and > makes its value a class. Ultimately we may want to change pandoc so it recognizes a language attribute if there is no relevant class (feel free to put up an issue about this), but this will work for now. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <yh480kblzj6dwt.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>]
* Re: Code blocks in latex [not found] ` <yh480kblzj6dwt.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> @ 2019-05-30 22:42 ` Umut Acar [not found] ` <d2d76f3d-e69a-4c98-81a7-4671370cbb66-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Umut Acar @ 2019-05-30 22:42 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 2296 bytes --] Yes, I wish to convert from latex to xml. I don't know much about pandoc filters and lua but they seem cool. I will see if I can get this to work. On Thursday, May 30, 2019 at 1:38:40 PM UTC-4, John MacFarlane wrote: > > John MacFarlane <j...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org <javascript:>> writes: > > > Umut Acar <umut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> writes: > > > >> Indeed, it works for quite a few standard languages but are custom > language > >> definitions supported? In markdown -->html conversion via custom XML > >> spec's (Kate) seems possible. I got good results with that. Is this not > >> supported for LaTeX --> html? > > > > To be clear, do I understand correctly that you're > > converting from LaTeX to HTML, and you want LaTeX > > lstlistings environments to be converted with > > highlighting? > > > > That will work with recognized languages (those that > > lstlisting environment supports). And you can make > > it work with unrecognized languages, by using a filter. > > Note: > > > > % pandoc -f latex -t native > > \begin{lstlisting}[language=foobar] > > hi = 3 > > \end{lstlisting} > > ^D > > [CodeBlock ("",[],[("language","foobar")]) "hi = 3"] > > > > What you need to do highlighting (using > > --syntax-definitio=foobar.xml) is rather > > > > [CodeBlock ("",["foobar"],[]) "hi = 3"] > > > > The solution is to use a simple lua filter > > that finds code blocks with a language attribute and > > makes its value a class. > > Ultimately we may want to change pandoc so it > recognizes a language attribute if there is no > relevant class (feel free to put up an issue > about this), but this will work for now. > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/d2d76f3d-e69a-4c98-81a7-4671370cbb66%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 3542 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <d2d76f3d-e69a-4c98-81a7-4671370cbb66-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Code blocks in latex [not found] ` <d2d76f3d-e69a-4c98-81a7-4671370cbb66-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2019-05-30 22:43 ` Umut Acar [not found] ` <19bc9d9e-44b6-4a77-a35d-6ae712e1cfb2-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Umut Acar @ 2019-05-30 22:43 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 2432 bytes --] i meant latex to html if that matters. On Thursday, May 30, 2019 at 6:42:47 PM UTC-4, Umut Acar wrote: > > Yes, I wish to convert from latex to xml. I don't know much about pandoc > filters and lua but they seem cool. I will see if I can get this to > work. > > > On Thursday, May 30, 2019 at 1:38:40 PM UTC-4, John MacFarlane wrote: >> >> John MacFarlane <j...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes: >> >> > Umut Acar <umut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: >> > >> >> Indeed, it works for quite a few standard languages but are custom >> language >> >> definitions supported? In markdown -->html conversion via custom XML >> >> spec's (Kate) seems possible. I got good results with that. Is this >> not >> >> supported for LaTeX --> html? >> > >> > To be clear, do I understand correctly that you're >> > converting from LaTeX to HTML, and you want LaTeX >> > lstlistings environments to be converted with >> > highlighting? >> > >> > That will work with recognized languages (those that >> > lstlisting environment supports). And you can make >> > it work with unrecognized languages, by using a filter. >> > Note: >> > >> > % pandoc -f latex -t native >> > \begin{lstlisting}[language=foobar] >> > hi = 3 >> > \end{lstlisting} >> > ^D >> > [CodeBlock ("",[],[("language","foobar")]) "hi = 3"] >> > >> > What you need to do highlighting (using >> > --syntax-definitio=foobar.xml) is rather >> > >> > [CodeBlock ("",["foobar"],[]) "hi = 3"] >> > >> > The solution is to use a simple lua filter >> > that finds code blocks with a language attribute and >> > makes its value a class. >> >> Ultimately we may want to change pandoc so it >> recognizes a language attribute if there is no >> relevant class (feel free to put up an issue >> about this), but this will work for now. >> > -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/19bc9d9e-44b6-4a77-a35d-6ae712e1cfb2%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 3424 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <19bc9d9e-44b6-4a77-a35d-6ae712e1cfb2-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Code blocks in latex [not found] ` <19bc9d9e-44b6-4a77-a35d-6ae712e1cfb2-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2019-05-31 4:18 ` Umut Acar [not found] ` <39924eae-9f8c-4597-bd01-11427cf5232b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Umut Acar @ 2019-05-31 4:18 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 2678 bytes --] I hacked up a lua filter that appears to work. Thank you! Issue opened here: https://github.com/jgm/pandoc/issues/5540 On Thursday, May 30, 2019 at 6:43:26 PM UTC-4, Umut Acar wrote: > > i meant latex to html if that matters. > > On Thursday, May 30, 2019 at 6:42:47 PM UTC-4, Umut Acar wrote: >> >> Yes, I wish to convert from latex to xml. I don't know much about pandoc >> filters and lua but they seem cool. I will see if I can get this to >> work. >> >> >> On Thursday, May 30, 2019 at 1:38:40 PM UTC-4, John MacFarlane wrote: >>> >>> John MacFarlane <j...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes: >>> >>> > Umut Acar <umut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: >>> > >>> >> Indeed, it works for quite a few standard languages but are custom >>> language >>> >> definitions supported? In markdown -->html conversion via custom XML >>> >> spec's (Kate) seems possible. I got good results with that. Is this >>> not >>> >> supported for LaTeX --> html? >>> > >>> > To be clear, do I understand correctly that you're >>> > converting from LaTeX to HTML, and you want LaTeX >>> > lstlistings environments to be converted with >>> > highlighting? >>> > >>> > That will work with recognized languages (those that >>> > lstlisting environment supports). And you can make >>> > it work with unrecognized languages, by using a filter. >>> > Note: >>> > >>> > % pandoc -f latex -t native >>> > \begin{lstlisting}[language=foobar] >>> > hi = 3 >>> > \end{lstlisting} >>> > ^D >>> > [CodeBlock ("",[],[("language","foobar")]) "hi = 3"] >>> > >>> > What you need to do highlighting (using >>> > --syntax-definitio=foobar.xml) is rather >>> > >>> > [CodeBlock ("",["foobar"],[]) "hi = 3"] >>> > >>> > The solution is to use a simple lua filter >>> > that finds code blocks with a language attribute and >>> > makes its value a class. >>> >>> Ultimately we may want to change pandoc so it >>> recognizes a language attribute if there is no >>> relevant class (feel free to put up an issue >>> about this), but this will work for now. >>> >> -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/39924eae-9f8c-4597-bd01-11427cf5232b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 3839 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <39924eae-9f8c-4597-bd01-11427cf5232b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Code blocks in latex [not found] ` <39924eae-9f8c-4597-bd01-11427cf5232b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2019-06-01 7:19 ` Pranesh Prakash [not found] ` <32793437-9280-4686-bd84-c7425e893d87-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: Pranesh Prakash @ 2019-06-01 7:19 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 4218 bytes --] This might be of use to someone else reading this thread later. I recently did MD -> PDF via LaTex and did the custom highlighting in the following manner. I indicated the language in the beginning of the code block: ``` {.xml} Then I created an xml.tex file with the following content: % Contents of xml.tex \usepackage{xcolor} \definecolor{maroon}{rgb}{0.5,0,0} \definecolor{darkgreen}{rgb}{0,0.5,0} \lstdefinelanguage{xml} { morestring=[s]{"}{"}, morecomment=[s]{?}{?}, morecomment=[s]{!--}{--}, commentstyle=\color{gray}, moredelim=[s][\color{black}]{>}{<}, moredelim=[s][\color{red}]{\ }{=}, stringstyle=\color{blue}, identifierstyle=\color{maroon} } \lstset{ basicstyle=\ttfamily, columns=fullflexible, showstringspaces=false, commentstyle=\color{gray}\upshape, numbers=left, numberstyle=\footnotesize, backgroundcolor=\color[RGB]{248,248,248}, breaklines=true, breakatwhitespace=true, breakautoindent=true, escapeinside={\%*}{*)}, } Then I called pandoc using the line: $ pandoc -f markdown+smart+raw_tex article.md --standalone --listings -H xml .tex -H footnotes.tex --bibliography biblio.bib --csl chicago-fullnote- bibliography.csl -o article.pdf That generated the right highlighting in the PDF file. When I tried generating an HTML file, the custom highlighting did not carry over, though the XML syntax was highlighted. Regards, Pranesh On Friday, 31 May 2019 09:48:40 UTC+5:30, Umut Acar wrote: > > I hacked up a lua filter that appears to work. Thank you! Issue opened > here: > https://github.com/jgm/pandoc/issues/5540 > > > On Thursday, May 30, 2019 at 6:43:26 PM UTC-4, Umut Acar wrote: >> >> i meant latex to html if that matters. >> >> On Thursday, May 30, 2019 at 6:42:47 PM UTC-4, Umut Acar wrote: >>> >>> Yes, I wish to convert from latex to xml. I don't know much about >>> pandoc filters and lua but they seem cool. I will see if I can get this >>> to work. >>> >>> >>> On Thursday, May 30, 2019 at 1:38:40 PM UTC-4, John MacFarlane wrote: >>>> >>>> John MacFarlane <j...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes: >>>> >>>> > Umut Acar <umut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: >>>> > >>>> >> Indeed, it works for quite a few standard languages but are custom >>>> language >>>> >> definitions supported? In markdown -->html conversion via custom >>>> XML >>>> >> spec's (Kate) seems possible. I got good results with that. Is this >>>> not >>>> >> supported for LaTeX --> html? >>>> > >>>> > To be clear, do I understand correctly that you're >>>> > converting from LaTeX to HTML, and you want LaTeX >>>> > lstlistings environments to be converted with >>>> > highlighting? >>>> > >>>> > That will work with recognized languages (those that >>>> > lstlisting environment supports). And you can make >>>> > it work with unrecognized languages, by using a filter. >>>> > Note: >>>> > >>>> > % pandoc -f latex -t native >>>> > \begin{lstlisting}[language=foobar] >>>> > hi = 3 >>>> > \end{lstlisting} >>>> > ^D >>>> > [CodeBlock ("",[],[("language","foobar")]) "hi = 3"] >>>> > >>>> > What you need to do highlighting (using >>>> > --syntax-definitio=foobar.xml) is rather >>>> > >>>> > [CodeBlock ("",["foobar"],[]) "hi = 3"] >>>> > >>>> > The solution is to use a simple lua filter >>>> > that finds code blocks with a language attribute and >>>> > makes its value a class. >>>> >>>> Ultimately we may want to change pandoc so it >>>> recognizes a language attribute if there is no >>>> relevant class (feel free to put up an issue >>>> about this), but this will work for now. >>>> >>> -- You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/32793437-9280-4686-bd84-c7425e893d87%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 19009 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <32793437-9280-4686-bd84-c7425e893d87-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Code blocks in latex [not found] ` <32793437-9280-4686-bd84-c7425e893d87-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2019-06-01 19:20 ` John MacFarlane 0 siblings, 0 replies; 10+ messages in thread From: John MacFarlane @ 2019-06-01 19:20 UTC (permalink / raw) To: Pranesh Prakash, pandoc-discuss --listings only works with LaTeX. Custom highlighting defined with the listings package won't carry over to other formats. Pranesh Prakash <the.solipsist-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > This might be of use to someone else reading this thread later. I recently > did MD -> PDF via LaTex and did the custom highlighting in the following > manner. > > I indicated the language in the beginning of the code block: > > ``` {.xml} > > > Then I created an xml.tex file with the following content: > > % Contents of xml.tex > \usepackage{xcolor} > \definecolor{maroon}{rgb}{0.5,0,0} > \definecolor{darkgreen}{rgb}{0,0.5,0} > \lstdefinelanguage{xml} > { > morestring=[s]{"}{"}, > morecomment=[s]{?}{?}, > morecomment=[s]{!--}{--}, > commentstyle=\color{gray}, > moredelim=[s][\color{black}]{>}{<}, > moredelim=[s][\color{red}]{\ }{=}, > stringstyle=\color{blue}, > identifierstyle=\color{maroon} > } > > > \lstset{ > basicstyle=\ttfamily, > columns=fullflexible, > showstringspaces=false, > commentstyle=\color{gray}\upshape, > numbers=left, > numberstyle=\footnotesize, > backgroundcolor=\color[RGB]{248,248,248}, > breaklines=true, > breakatwhitespace=true, > breakautoindent=true, > escapeinside={\%*}{*)}, > } > > > Then I called pandoc using the line: > > $ pandoc -f markdown+smart+raw_tex article.md --standalone --listings -H xml > .tex -H footnotes.tex --bibliography biblio.bib --csl chicago-fullnote- > bibliography.csl -o article.pdf > > That generated the right highlighting in the PDF file. > > When I tried generating an HTML file, the custom highlighting did not carry > over, though the XML syntax was highlighted. > > Regards, > Pranesh > > On Friday, 31 May 2019 09:48:40 UTC+5:30, Umut Acar wrote: >> >> I hacked up a lua filter that appears to work. Thank you! Issue opened >> here: >> https://github.com/jgm/pandoc/issues/5540 >> >> >> On Thursday, May 30, 2019 at 6:43:26 PM UTC-4, Umut Acar wrote: >>> >>> i meant latex to html if that matters. >>> >>> On Thursday, May 30, 2019 at 6:42:47 PM UTC-4, Umut Acar wrote: >>>> >>>> Yes, I wish to convert from latex to xml. I don't know much about >>>> pandoc filters and lua but they seem cool. I will see if I can get this >>>> to work. >>>> >>>> >>>> On Thursday, May 30, 2019 at 1:38:40 PM UTC-4, John MacFarlane wrote: >>>>> >>>>> John MacFarlane <j...-TVLZxgkOlNX2fBVCVOL8/A@public.gmane.org> writes: >>>>> >>>>> > Umut Acar <umut...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: >>>>> > >>>>> >> Indeed, it works for quite a few standard languages but are custom >>>>> language >>>>> >> definitions supported? In markdown -->html conversion via custom >>>>> XML >>>>> >> spec's (Kate) seems possible. I got good results with that. Is this >>>>> not >>>>> >> supported for LaTeX --> html? >>>>> > >>>>> > To be clear, do I understand correctly that you're >>>>> > converting from LaTeX to HTML, and you want LaTeX >>>>> > lstlistings environments to be converted with >>>>> > highlighting? >>>>> > >>>>> > That will work with recognized languages (those that >>>>> > lstlisting environment supports). And you can make >>>>> > it work with unrecognized languages, by using a filter. >>>>> > Note: >>>>> > >>>>> > % pandoc -f latex -t native >>>>> > \begin{lstlisting}[language=foobar] >>>>> > hi = 3 >>>>> > \end{lstlisting} >>>>> > ^D >>>>> > [CodeBlock ("",[],[("language","foobar")]) "hi = 3"] >>>>> > >>>>> > What you need to do highlighting (using >>>>> > --syntax-definitio=foobar.xml) is rather >>>>> > >>>>> > [CodeBlock ("",["foobar"],[]) "hi = 3"] >>>>> > >>>>> > The solution is to use a simple lua filter >>>>> > that finds code blocks with a language attribute and >>>>> > makes its value a class. >>>>> >>>>> Ultimately we may want to change pandoc so it >>>>> recognizes a language attribute if there is no >>>>> relevant class (feel free to put up an issue >>>>> about this), but this will work for now. >>>>> >>>> > > -- > You received this message because you are subscribed to the Google Groups "pandoc-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/32793437-9280-4686-bd84-c7425e893d87%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2019-06-01 19:20 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2019-05-29 23:22 Code blocks in latex Umut Acar [not found] ` <b08442d7-e415-4491-b841-705cf46ddc1f-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2019-05-30 5:20 ` John MacFarlane [not found] ` <m2zhn4iklq.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 2019-05-30 14:07 ` Umut Acar [not found] ` <532362a8-94bf-4c7a-846e-896951036b5c-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2019-05-30 17:37 ` John MacFarlane [not found] ` <yh480kef4f6dy1.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 2019-05-30 17:38 ` John MacFarlane [not found] ` <yh480kblzj6dwt.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 2019-05-30 22:42 ` Umut Acar [not found] ` <d2d76f3d-e69a-4c98-81a7-4671370cbb66-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2019-05-30 22:43 ` Umut Acar [not found] ` <19bc9d9e-44b6-4a77-a35d-6ae712e1cfb2-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2019-05-31 4:18 ` Umut Acar [not found] ` <39924eae-9f8c-4597-bd01-11427cf5232b-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2019-06-01 7:19 ` Pranesh Prakash [not found] ` <32793437-9280-4686-bd84-c7425e893d87-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2019-06-01 19:20 ` John MacFarlane
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).