public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Default syntax for code blocks?
@ 2020-11-21 17:34 Nick Moffitt
       [not found] ` <20201121173412.GP4166-iTLVOByc1N8@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Moffitt @ 2020-11-21 17:34 UTC (permalink / raw)
  To: pandoc-discuss

Is there an easy way to specify that all code blocks (fenced, `inline`, etc) are treated by the same syntax highlighter?

I am working on a document that has a lot of Scheme code, and it's rather infuriating to have to do things like `12`{.scheme} to get numbers formatted in paragraphs the way they are in the larger fenced code blocks.  I find myself taking shortcuts like `myfuncname` to save typing, but have to track down evry `else`{.scheme} so things are consistent.  I'm finding myself going mad when examples like `(this and that atom)` don't render the same as `(this and that atom)`{.scheme} because `and` is a reserved word.

I'd find my document much easier to work on if I could just say "everyting in backticks is scheme.  Format it."

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20201121173412.GP4166%40zork.net.


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

* Re: Default syntax for code blocks?
       [not found] ` <20201121173412.GP4166-iTLVOByc1N8@public.gmane.org>
@ 2020-11-21 21:01   ` John MacFarlane
       [not found]     ` <m28saufmps.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: John MacFarlane @ 2020-11-21 21:01 UTC (permalink / raw)
  To: Nick Moffitt, pandoc-discuss


There is an option to set the default syntax for indented
code blocks. So, you could just use indented blocks.

To add a default class to all code blocks that lack one,
you could use a simple lua filter.

Nick Moffitt <nick-iTLVOByc1N8@public.gmane.org> writes:

> Is there an easy way to specify that all code blocks (fenced, `inline`, etc) are treated by the same syntax highlighter?
>
> I am working on a document that has a lot of Scheme code, and it's rather infuriating to have to do things like `12`{.scheme} to get numbers formatted in paragraphs the way they are in the larger fenced code blocks.  I find myself taking shortcuts like `myfuncname` to save typing, but have to track down evry `else`{.scheme} so things are consistent.  I'm finding myself going mad when examples like `(this and that atom)` don't render the same as `(this and that atom)`{.scheme} because `and` is a reserved word.
>
> I'd find my document much easier to work on if I could just say "everyting in backticks is scheme.  Format it."
>
> -- 
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20201121173412.GP4166%40zork.net.

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/m28saufmps.fsf%40MacBook-Pro.hsd1.ca.comcast.net.


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

* Re: Default syntax for code blocks?
       [not found]     ` <m28saufmps.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
@ 2020-11-21 21:03       ` Nick Moffitt
       [not found]         ` <20201121210354.GQ4166-iTLVOByc1N8@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Nick Moffitt @ 2020-11-21 21:03 UTC (permalink / raw)
  To: pandoc-discuss

I can't use indented code blocks inside of paragraphs, headings, and definition lists, surely?

What would such a lua filter look like?  Is there any example out there that makes it clear how to do such a thing?

On 21Nov2020 01:01pm (-0800), John MacFarlane wrote:
> 
> There is an option to set the default syntax for indented
> code blocks. So, you could just use indented blocks.
> 
> To add a default class to all code blocks that lack one,
> you could use a simple lua filter.
> 
> Nick Moffitt <nick-iTLVOByc1N8@public.gmane.org> writes:
> 
> > Is there an easy way to specify that all code blocks (fenced, `inline`, etc) are treated by the same syntax highlighter?
> >
> > I am working on a document that has a lot of Scheme code, and it's rather infuriating to have to do things like `12`{.scheme} to get numbers formatted in paragraphs the way they are in the larger fenced code blocks.  I find myself taking shortcuts like `myfuncname` to save typing, but have to track down evry `else`{.scheme} so things are consistent.  I'm finding myself going mad when examples like `(this and that atom)` don't render the same as `(this and that atom)`{.scheme} because `and` is a reserved word.
> >
> > I'd find my document much easier to work on if I could just say "everyting in backticks is scheme.  Format it."
> >
> > -- 
> > 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20201121173412.GP4166%40zork.net.

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20201121210354.GQ4166%40zork.net.


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

* Re: Default syntax for code blocks?
       [not found]         ` <20201121210354.GQ4166-iTLVOByc1N8@public.gmane.org>
@ 2020-11-21 21:50           ` Nick Moffitt
  2020-11-28 20:35           ` John Gabriele
  1 sibling, 0 replies; 5+ messages in thread
From: Nick Moffitt @ 2020-11-21 21:50 UTC (permalink / raw)
  To: pandoc-discuss

I was sceptical, as while I love lua, the AST API has always baffled me in pandoc. But it really was simple in the end!

```{.lua}
function Code (el)                                                              
	table.insert(el.classes, "scheme")                                                                  
	return el                                                                     
end                                                                                
function CodeBlock (el)                                                         
	table.insert(el.classes, "scheme")                                            
	return el                                                                     
end
```


On 21Nov2020 09:03pm (+0000), Nick Moffitt wrote:
> I can't use indented code blocks inside of paragraphs, headings, and definition lists, surely?
> 
> What would such a lua filter look like?  Is there any example out there that makes it clear how to do such a thing?
> 
> On 21Nov2020 01:01pm (-0800), John MacFarlane wrote:
> > 
> > There is an option to set the default syntax for indented
> > code blocks. So, you could just use indented blocks.
> > 
> > To add a default class to all code blocks that lack one,
> > you could use a simple lua filter.
> > 
> > Nick Moffitt <nick-iTLVOByc1N8@public.gmane.org> writes:
> > 
> > > Is there an easy way to specify that all code blocks (fenced, `inline`, etc) are treated by the same syntax highlighter?
> > >
> > > I am working on a document that has a lot of Scheme code, and it's rather infuriating to have to do things like `12`{.scheme} to get numbers formatted in paragraphs the way they are in the larger fenced code blocks.  I find myself taking shortcuts like `myfuncname` to save typing, but have to track down evry `else`{.scheme} so things are consistent.  I'm finding myself going mad when examples like `(this and that atom)` don't render the same as `(this and that atom)`{.scheme} because `and` is a reserved word.
> > >
> > > I'd find my document much easier to work on if I could just say "everyting in backticks is scheme.  Format it."
> > >
> > > -- 
> > > 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20201121173412.GP4166%40zork.net.
> 
> -- 
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20201121210354.GQ4166%40zork.net.

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/20201121215008.GF4166%40zork.net.


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

* Re: Default syntax for code blocks?
       [not found]         ` <20201121210354.GQ4166-iTLVOByc1N8@public.gmane.org>
  2020-11-21 21:50           ` Nick Moffitt
@ 2020-11-28 20:35           ` John Gabriele
  1 sibling, 0 replies; 5+ messages in thread
From: John Gabriele @ 2020-11-28 20:35 UTC (permalink / raw)
  To: 'Oliver Demetz' via pandoc-discuss

On Sat, Nov 21, 2020, at 4:03 PM, Nick Moffitt wrote:
> I can't use indented code blocks inside of paragraphs, headings, and 
> definition lists, surely?
> 

Hi Nick,

Sorry to comment so late on this, but terminology note for posterity on this thread: "block" refers to what gives you a div (as opposed to a span). That is to say, there's two kinds of syntax here:

  * inline (`code`, *italics*, etc.) (for spans)
  * block (for divs), of which you have two kinds:
      + side-marked (indented, for code), `>` for blockquote
      + delimited, or "fenced" (`~~~for code blocks~~~` (or backticks))

-- John


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

end of thread, other threads:[~2020-11-28 20:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-21 17:34 Default syntax for code blocks? Nick Moffitt
     [not found] ` <20201121173412.GP4166-iTLVOByc1N8@public.gmane.org>
2020-11-21 21:01   ` John MacFarlane
     [not found]     ` <m28saufmps.fsf-jF64zX8BO08an7k8zZ43ob9bIa4KchGshsV+eolpW18@public.gmane.org>
2020-11-21 21:03       ` Nick Moffitt
     [not found]         ` <20201121210354.GQ4166-iTLVOByc1N8@public.gmane.org>
2020-11-21 21:50           ` Nick Moffitt
2020-11-28 20:35           ` John Gabriele

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).