* Keeping minimal Markdown formatting in text across multiple output formats @ 2018-09-21 4:04 David S [not found] ` <4b684380-6706-48c1-9c4a-83d1273d8ed9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: David S @ 2018-09-21 4:04 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 1324 bytes --] What's the best way to preserve formatting information when using pandoc to convert Markdown to multiple output formats? For example, say there's a little bit of text that I want colored red and I use \textcolor{red}{this is red text} which works perfectly when exporting to PDF (via latex), but the text is just dropped when I convert to HTML. I know in HTML I can use spans, but then I lose the formatting if I also want to export to DOCX at the same time as PDF and HTML. Likewise, I know I can define a style in a DOCX template and then add a named style for things in red, but I don't think this will work for PDF output. Is there a filter to help preserve (or at least, not omit) minimally marked up text for multiple output formats? -- 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/4b684380-6706-48c1-9c4a-83d1273d8ed9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 1790 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <4b684380-6706-48c1-9c4a-83d1273d8ed9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Keeping minimal Markdown formatting in text across multiple output formats [not found] ` <4b684380-6706-48c1-9c4a-83d1273d8ed9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2018-09-21 4:48 ` John MacFarlane [not found] ` <m2d0t7wj5j.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: John MacFarlane @ 2018-09-21 4:48 UTC (permalink / raw) To: David S, pandoc-discuss You can use "native spans" in pandoc's markdown. They are represented in the AST, and they'll be rendered as span elements in HTML. For other formats, you will need to use a filter to produce the right output. [this is red text]{.red} In HTML this will be: <span class="red">this is red text</span> and you can use CSS to make it red. For LaTeX output, you could use this lua filter (untested): function Span(el) if el.classes[1] == 'red' then return { pandoc.rawInline('tex', '\textcolor{red}{'), el, pandoc.rawInline('tex', '}') end end So you might need a bit of customization using lua filters for the various output formats you're targeting. David S <slochower-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > What's the best way to preserve formatting information when using pandoc to > convert Markdown to multiple output formats? > > For example, say there's a little bit of text that I want colored red and I > use \textcolor{red}{this is red text} which works perfectly when exporting > to PDF (via latex), but the text is just dropped when I convert to HTML. I > know in HTML I can use spans, but then I lose the formatting if I also want > to export to DOCX at the same time as PDF and HTML. Likewise, I know I can > define a style in a DOCX template and then add a named style for things in > red, but I don't think this will work for PDF output. > > Is there a filter to help preserve (or at least, not omit) minimally marked > up text for multiple output formats? > > -- > 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/4b684380-6706-48c1-9c4a-83d1273d8ed9%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <m2d0t7wj5j.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>]
* Re: Keeping minimal Markdown formatting in text across multiple output formats [not found] ` <m2d0t7wj5j.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> @ 2018-09-21 5:12 ` David S [not found] ` <84dc8592-1848-433b-8ab1-58ea8514b703-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: David S @ 2018-09-21 5:12 UTC (permalink / raw) To: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 1364 bytes --] On Thursday, September 20, 2018 at 9:48:24 PM UTC-7, John MacFarlane wrote: > > > You can use "native spans" in pandoc's markdown. They > are represented in the AST, and they'll be rendered as > span elements in HTML. For other formats, you will > need to use a filter to produce the right output. > > [this is red text]{.red} > Thanks, I didn't realize this. > > > function Span(el) > if el.classes[1] == 'red' then > return { pandoc.rawInline('tex', '\textcolor{red}{'), > el, pandoc.rawInline('tex', '}') > end > end > Hm, I think there's a missing `}` for the return statement and then when I tried it, I received `attempt to call a nil value (field 'rawInline')`. My lua knowledge is essentially zero, so I'm not very much help debugging. -- 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/84dc8592-1848-433b-8ab1-58ea8514b703%40googlegroups.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 2233 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <84dc8592-1848-433b-8ab1-58ea8514b703-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>]
* Re: Keeping minimal Markdown formatting in text across multiple output formats [not found] ` <84dc8592-1848-433b-8ab1-58ea8514b703-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> @ 2018-09-21 17:06 ` John MacFarlane [not found] ` <yh480kk1nebx0u.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: John MacFarlane @ 2018-09-21 17:06 UTC (permalink / raw) To: David S, pandoc-discuss David S <slochower-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > Hm, I think there's a missing `}` for the return statement and then when I > tried it, I received `attempt to call a nil value (field 'rawInline')`. My > lua knowledge is essentially zero, so I'm not very much help debugging. Sorry, I shouldn't have posted without testing. Here's a better version: function Span(el) if el.classes[1] == 'red' and FORMAT == 'latex' then return { pandoc.RawInline('latex', '\\textcolor{red}{'), el, pandoc.RawInline('latex', '}') } end end ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <yh480kk1nebx0u.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>]
* Re: Keeping minimal Markdown formatting in text across multiple output formats [not found] ` <yh480kk1nebx0u.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> @ 2018-09-21 21:35 ` David Slochower [not found] ` <EF140339-8C11-4FF3-99F6-5B876ACAABCB-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: David Slochower @ 2018-09-21 21:35 UTC (permalink / raw) To: John MacFarlane; +Cc: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 1347 bytes --] On 21 Sep 2018, at 10:06, John MacFarlane wrote: > function Span(el) > if el.classes[1] == 'red' and FORMAT == 'latex' then > return { pandoc.RawInline('latex', '\\textcolor{red}{'), > el, pandoc.RawInline('latex', '}') } > end > end Thanks John! That works, mostly. However, it seems incompatible with `pandoc-fignos`. If there is a reference in the span then the figure reference is missing and the `{.red}` stays in the intermediary `tex`: ```latex of the molecule (Figure {\textbf{???}}).}\{.red\} ``` This also happens in HTML: ```html data-reference-id="fig:motor-diagram"><strong>???</strong></span>).</sup></span>{.red}</p> ``` I’ve tried putting the lua filter after `pandoc-fignos` but it had no effect. -- 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/EF140339-8C11-4FF3-99F6-5B876ACAABCB%40gmail.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #2: Type: text/html, Size: 3170 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <EF140339-8C11-4FF3-99F6-5B876ACAABCB-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: Keeping minimal Markdown formatting in text across multiple output formats [not found] ` <EF140339-8C11-4FF3-99F6-5B876ACAABCB-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2018-09-21 22:27 ` John MacFarlane [not found] ` <yh480kr2hma3ko.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: John MacFarlane @ 2018-09-21 22:27 UTC (permalink / raw) To: David Slochower; +Cc: pandoc-discuss "David Slochower" <slochower-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > On 21 Sep 2018, at 10:06, John MacFarlane wrote: > >> function Span(el) >> if el.classes[1] == 'red' and FORMAT == 'latex' then >> return { pandoc.RawInline('latex', '\\textcolor{red}{'), >> el, pandoc.RawInline('latex', '}') } >> end >> end > > Thanks John! That works, mostly. However, it seems incompatible with > `pandoc-fignos`. If there is a reference in the span then the figure > reference is missing and the `{.red}` stays in the intermediary `tex`: Yes, you just have to improve it a bit like this: function includes(tbl, x) for _, y in ipairs(tbl) do if y == x then return true end end return false end function Span(el) if el.classes:includes('red') and FORMAT == 'latex' then return { pandoc.RawInline('latex', '\\textcolor{red}{'), el, pandoc.RawInline('latex', '}') } end end ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <yh480kr2hma3ko.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>]
* Re: Keeping minimal Markdown formatting in text across multiple output formats [not found] ` <yh480kr2hma3ko.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> @ 2018-09-22 0:40 ` David Slochower [not found] ` <7512A0A8-C621-4E38-8917-43917E0535CB-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: David Slochower @ 2018-09-22 0:40 UTC (permalink / raw) To: John MacFarlane; +Cc: pandoc-discuss [-- Attachment #1.1: Type: text/plain, Size: 3112 bytes --] It seems this still isn’t quite right. Apologies for dragging this on. A minimal reproducible example is a Markdown file like so: ```Markdown ![Caption](motor.png){#fig:asdf} [Here's text without a referene and it is red.]{.red} [Here's a reference to a figure @fig:asdf and this text should be red.]{.red} ``` After calling ``` pandoc --from=markdown --output=tmp.pdf --lua-filter=latex-color.lua --filter=pandoc-fignos --variable colorlinks="blue" tmp.md ``` where `latex-color.lua` has the contents from your last email and `—variable colorlinks=“blue”` forces `pandoc` to load the color packages, I see a PDF that looks like this: ![](cid:C6BA6071-41DE-4B70-A622-22CE8CBE1A22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org "PastedImage.png") Native AST output shows `”{.red}”` as a string: ``` ,Para [Cite [Citation {citationId = "fig:asdf", citationPrefix = [Str "Here\8217s",Space,Str "a",Space,Str "reference",Space,Str "to",Space,Str "a",Space,Str "figure"], citationSuffix = [Space,Str "and",Space,Str "this",Space,Str "text",Space,Str "should",Space,Str "be",Space,Str "red."], citationMode = NormalCitation, citationNoteNum = 0, citationHash = 0}] [Str "[Here's",Space,Str "a",Space,Str "reference",Space,Str "to",Space,Str "a",Space,Str "figure",Space,Str "@fig:asdf",Space,Str "and",Space,Str "this",Space,Str "text",Space,Str "should",Space,Str "be",Space,Str "red.]"],Str "{.red}"]] ``` On 21 Sep 2018, at 15:27, John MacFarlane wrote: > "David Slochower" <slochower-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > >> On 21 Sep 2018, at 10:06, John MacFarlane wrote: >> >>> function Span(el) >>> if el.classes[1] == 'red' and FORMAT == 'latex' then >>> return { pandoc.RawInline('latex', '\\textcolor{red}{'), >>> el, pandoc.RawInline('latex', '}') } >>> end >>> end >> >> Thanks John! That works, mostly. However, it seems incompatible with >> `pandoc-fignos`. If there is a reference in the span then the figure >> reference is missing and the `{.red}` stays in the intermediary >> `tex`: > > Yes, you just have to improve it a bit like this: > > function includes(tbl, x) > for _, y in ipairs(tbl) do > if y == x then return true end > end > return false > end > > function Span(el) > if el.classes:includes('red') and FORMAT == 'latex' then > return { pandoc.RawInline('latex', '\\textcolor{red}{'), > el, pandoc.RawInline('latex', '}') } > end > end -- 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/7512A0A8-C621-4E38-8917-43917E0535CB%40gmail.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #1.2: Type: text/html, Size: 4878 bytes --] [-- Attachment #2: PastedImage.png --] [-- Type: image/png, Size: 42853 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <7512A0A8-C621-4E38-8917-43917E0535CB-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: Keeping minimal Markdown formatting in text across multiple output formats [not found] ` <7512A0A8-C621-4E38-8917-43917E0535CB-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2018-09-22 4:03 ` John MacFarlane [not found] ` <m2a7oaw544.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: John MacFarlane @ 2018-09-22 4:03 UTC (permalink / raw) To: David Slochower; +Cc: pandoc-discuss You can see what's going on by doing `pandoc -t native` on [Here's a reference to a figure @fig:asdf and this text should be red.]{.red} You'll then see that this gets parsed as a Cite element rather than a Span. That's because of the citation reference @fig:asdf contained in it. The part before is parsed as the citation prefix; the part after is the suffix. Citations, unlike spans, don't take attributes. A minimal change that would make this parse as a span would be to change `@fig:asdf` to `[@fig:asdf]`. "David Slochower" <slochower-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > It seems this still isn’t quite right. Apologies for dragging this on. > > A minimal reproducible example is a Markdown file like so: > > ```Markdown > ![Caption](motor.png){#fig:asdf} > > [Here's text without a referene and it is red.]{.red} > > [Here's a reference to a figure @fig:asdf and this text should be > red.]{.red} > ``` > > After calling > > ``` > pandoc --from=markdown --output=tmp.pdf --lua-filter=latex-color.lua > --filter=pandoc-fignos --variable colorlinks="blue" tmp.md > ``` > > where `latex-color.lua` has the contents from your last email and > `—variable colorlinks=“blue”` forces `pandoc` to load the color > packages, I see a PDF that looks like this: > > ![](cid:C6BA6071-41DE-4B70-A622-22CE8CBE1A22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > "PastedImage.png") > > Native AST output shows `”{.red}”` as a string: > > ``` > ,Para [Cite [Citation {citationId = "fig:asdf", citationPrefix = [Str > "Here\8217s",Space,Str "a",Space,Str "reference",Space,Str > "to",Space,Str "a",Space,Str "figure"], citationSuffix = [Space,Str > "and",Space,Str "this",Space,Str "text",Space,Str "should",Space,Str > "be",Space,Str "red."], citationMode = NormalCitation, citationNoteNum = > 0, citationHash = 0}] [Str "[Here's",Space,Str "a",Space,Str > "reference",Space,Str "to",Space,Str "a",Space,Str "figure",Space,Str > "@fig:asdf",Space,Str "and",Space,Str "this",Space,Str "text",Space,Str > "should",Space,Str "be",Space,Str "red.]"],Str "{.red}"]] > ``` > > On 21 Sep 2018, at 15:27, John MacFarlane wrote: > >> "David Slochower" <slochower-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: >> >>> On 21 Sep 2018, at 10:06, John MacFarlane wrote: >>> >>>> function Span(el) >>>> if el.classes[1] == 'red' and FORMAT == 'latex' then >>>> return { pandoc.RawInline('latex', '\\textcolor{red}{'), >>>> el, pandoc.RawInline('latex', '}') } >>>> end >>>> end >>> >>> Thanks John! That works, mostly. However, it seems incompatible with >>> `pandoc-fignos`. If there is a reference in the span then the figure >>> reference is missing and the `{.red}` stays in the intermediary >>> `tex`: >> >> Yes, you just have to improve it a bit like this: >> >> function includes(tbl, x) >> for _, y in ipairs(tbl) do >> if y == x then return true end >> end >> return false >> end >> >> function Span(el) >> if el.classes:includes('red') and FORMAT == 'latex' then >> return { pandoc.RawInline('latex', '\\textcolor{red}{'), >> el, pandoc.RawInline('latex', '}') } >> end >> end > > -- > 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/7512A0A8-C621-4E38-8917-43917E0535CB%40gmail.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/m2a7oaw544.fsf%40johnmacfarlane.net. For more options, visit https://groups.google.com/d/optout. ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <m2a7oaw544.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org>]
* Re: Keeping minimal Markdown formatting in text across multiple output formats [not found] ` <m2a7oaw544.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> @ 2018-09-22 4:22 ` David Slochower [not found] ` <06D62ED6-4EAF-4D38-A16C-4837FA6F7963-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 0 siblings, 1 reply; 10+ messages in thread From: David Slochower @ 2018-09-22 4:22 UTC (permalink / raw) To: John MacFarlane; +Cc: pandoc-discuss [-- Attachment #1: Type: text/plain, Size: 4502 bytes --] On 21 Sep 2018, at 21:03, John MacFarlane wrote: > Citations, unlike spans, don't take attributes. Ah, that’s what I was missing. > > A minimal change that would make this parse as a span > would be to change `@fig:asdf` to `[@fig:asdf]`. I agree this colors the text red, although the reference is not resolved. To be clear, I now have the `@fig` reference in double brackets. ``` [Here's a reference to a figure [@fig:asdf] and this text should be red.]{.red} ``` > > "David Slochower" <slochower-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > >> It seems this still isn’t quite right. Apologies for dragging this >> on. >> >> A minimal reproducible example is a Markdown file like so: >> >> ```Markdown >> ![Caption](motor.png){#fig:asdf} >> >> [Here's text without a referene and it is red.]{.red} >> >> [Here's a reference to a figure @fig:asdf and this text should be >> red.]{.red} >> ``` >> >> After calling >> >> ``` >> pandoc --from=markdown --output=tmp.pdf --lua-filter=latex-color.lua >> --filter=pandoc-fignos --variable colorlinks="blue" tmp.md >> ``` >> >> where `latex-color.lua` has the contents from your last email and >> `—variable colorlinks=“blue”` forces `pandoc` to load the color >> packages, I see a PDF that looks like this: >> >> ![](cid:C6BA6071-41DE-4B70-A622-22CE8CBE1A22-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org >> "PastedImage.png") >> >> Native AST output shows `”{.red}”` as a string: >> >> ``` >> ,Para [Cite [Citation {citationId = "fig:asdf", citationPrefix = [Str >> "Here\8217s",Space,Str "a",Space,Str "reference",Space,Str >> "to",Space,Str "a",Space,Str "figure"], citationSuffix = [Space,Str >> "and",Space,Str "this",Space,Str "text",Space,Str "should",Space,Str >> "be",Space,Str "red."], citationMode = NormalCitation, >> citationNoteNum = >> 0, citationHash = 0}] [Str "[Here's",Space,Str "a",Space,Str >> "reference",Space,Str "to",Space,Str "a",Space,Str "figure",Space,Str >> "@fig:asdf",Space,Str "and",Space,Str "this",Space,Str >> "text",Space,Str >> "should",Space,Str "be",Space,Str "red.]"],Str "{.red}"]] >> ``` >> >> On 21 Sep 2018, at 15:27, John MacFarlane wrote: >> >>> "David Slochower" <slochower-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: >>> >>>> On 21 Sep 2018, at 10:06, John MacFarlane wrote: >>>> >>>>> function Span(el) >>>>> if el.classes[1] == 'red' and FORMAT == 'latex' then >>>>> return { pandoc.RawInline('latex', '\\textcolor{red}{'), >>>>> el, pandoc.RawInline('latex', '}') } >>>>> end >>>>> end >>>> >>>> Thanks John! That works, mostly. However, it seems incompatible >>>> with >>>> `pandoc-fignos`. If there is a reference in the span then the >>>> figure >>>> reference is missing and the `{.red}` stays in the intermediary >>>> `tex`: >>> >>> Yes, you just have to improve it a bit like this: >>> >>> function includes(tbl, x) >>> for _, y in ipairs(tbl) do >>> if y == x then return true end >>> end >>> return false >>> end >>> >>> function Span(el) >>> if el.classes:includes('red') and FORMAT == 'latex' then >>> return { pandoc.RawInline('latex', '\\textcolor{red}{'), >>> el, pandoc.RawInline('latex', '}') } >>> end >>> end >> >> -- >> 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/7512A0A8-C621-4E38-8917-43917E0535CB%40gmail.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/06D62ED6-4EAF-4D38-A16C-4837FA6F7963%40gmail.com. For more options, visit https://groups.google.com/d/optout. [-- Attachment #2: Type: text/html, Size: 6777 bytes --] ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <06D62ED6-4EAF-4D38-A16C-4837FA6F7963-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>]
* Re: Keeping minimal Markdown formatting in text across multiple output formats [not found] ` <06D62ED6-4EAF-4D38-A16C-4837FA6F7963-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> @ 2018-09-22 18:21 ` John MacFarlane 0 siblings, 0 replies; 10+ messages in thread From: John MacFarlane @ 2018-09-22 18:21 UTC (permalink / raw) To: David Slochower; +Cc: pandoc-discuss "David Slochower" <slochower-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes: > I agree this colors the text red, although the reference is not > resolved. To be clear, I now have the `@fig` reference in double > brackets. > > ``` > [Here's a reference to a figure [@fig:asdf] and this text should be > red.]{.red} > ``` OK, this has to do with the way pandoc-crossref is overloading citation syntax; I'm not familiar with the details of this tool, so you may have to seek advice from its author. ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2018-09-22 18:21 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-09-21 4:04 Keeping minimal Markdown formatting in text across multiple output formats David S [not found] ` <4b684380-6706-48c1-9c4a-83d1273d8ed9-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2018-09-21 4:48 ` John MacFarlane [not found] ` <m2d0t7wj5j.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 2018-09-21 5:12 ` David S [not found] ` <84dc8592-1848-433b-8ab1-58ea8514b703-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> 2018-09-21 17:06 ` John MacFarlane [not found] ` <yh480kk1nebx0u.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 2018-09-21 21:35 ` David Slochower [not found] ` <EF140339-8C11-4FF3-99F6-5B876ACAABCB-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2018-09-21 22:27 ` John MacFarlane [not found] ` <yh480kr2hma3ko.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 2018-09-22 0:40 ` David Slochower [not found] ` <7512A0A8-C621-4E38-8917-43917E0535CB-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2018-09-22 4:03 ` John MacFarlane [not found] ` <m2a7oaw544.fsf-pgq/RBwaQ+zq8tPRBa0AtqxOck334EZe@public.gmane.org> 2018-09-22 4:22 ` David Slochower [not found] ` <06D62ED6-4EAF-4D38-A16C-4837FA6F7963-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 2018-09-22 18:21 ` 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).