public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* Suppress newlines for RawBlock
@ 2020-04-23  5:13 Dave Jarvis
       [not found] ` <6e342237-d526-4a6d-b637-e2d824f3fdba-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Jarvis @ 2020-04-23  5:13 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 1663 bytes --]

Hey there!

Consider the following Markdown:

::: title
Novel Name
:::

::: author
Author Name
:::

This is run through some code that produces the following TeX code:

\startbooktitle

Novel Name

\stopbooktitle

\startbookauthor

Author Name

\stopbookauthor

When typeset, this produces:

\par Novel Name \par
\par Author Name \par

However, there were no line breaks in the original div element, so it was a 
bit of a surprise to see the blank lines in the output.

Is there a way to suppress the internal newlines to generate the blocks 
without the new lines? Such as:

\startbooktitle
Novel Name
\stopbooktitle

\startbookauthor
Author Name
\stopbookauthor

The lua filter code that generates the ConTeXt macro follows:

function Div( element )
  local annotation = element.classes:find_if( matches )

  if annotation then
    annotation = annotation:gsub( "[^%w]*", "" )

    return {
      context( "\\start", annotation ),
      element,
      context( "\\stop", annotation )
    }
  end
end

function matches( s )
  return s:match( "^%a+" )
end

function context( macro, annotation )
  return pandoc.RawBlock( "context", macro .. "book" .. annotation )
end

What--if anything--can be changed in the code to suppress the newlines?

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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6e342237-d526-4a6d-b637-e2d824f3fdba%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 4296 bytes --]

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

* Re: Suppress newlines for RawBlock
       [not found] ` <6e342237-d526-4a6d-b637-e2d824f3fdba-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2020-04-23  5:38   ` John MacFarlane
  0 siblings, 0 replies; 2+ messages in thread
From: John MacFarlane @ 2020-04-23  5:38 UTC (permalink / raw)
  To: Dave Jarvis, pandoc-discuss


The LaTeX writer puts blank lines between all block-level
elements.  What you could do is create a filter that consolidates
adjacent raw blocks into a single raw block.

Dave Jarvis <dave.jarvis-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:

> Hey there!
>
> Consider the following Markdown:
>
> ::: title
> Novel Name
> :::
>
> ::: author
> Author Name
> :::
>
> This is run through some code that produces the following TeX code:
>
> \startbooktitle
>
> Novel Name
>
> \stopbooktitle
>
> \startbookauthor
>
> Author Name
>
> \stopbookauthor
>
> When typeset, this produces:
>
> \par Novel Name \par
> \par Author Name \par
>
> However, there were no line breaks in the original div element, so it was a 
> bit of a surprise to see the blank lines in the output.
>
> Is there a way to suppress the internal newlines to generate the blocks 
> without the new lines? Such as:
>
> \startbooktitle
> Novel Name
> \stopbooktitle
>
> \startbookauthor
> Author Name
> \stopbookauthor
>
> The lua filter code that generates the ConTeXt macro follows:
>
> function Div( element )
>   local annotation = element.classes:find_if( matches )
>
>   if annotation then
>     annotation = annotation:gsub( "[^%w]*", "" )
>
>     return {
>       context( "\\start", annotation ),
>       element,
>       context( "\\stop", annotation )
>     }
>   end
> end
>
> function matches( s )
>   return s:match( "^%a+" )
> end
>
> function context( macro, annotation )
>   return pandoc.RawBlock( "context", macro .. "book" .. annotation )
> end
>
> What--if anything--can be changed in the code to suppress the newlines?
>
> 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 view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/6e342237-d526-4a6d-b637-e2d824f3fdba%40googlegroups.com.


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

end of thread, other threads:[~2020-04-23  5:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23  5:13 Suppress newlines for RawBlock Dave Jarvis
     [not found] ` <6e342237-d526-4a6d-b637-e2d824f3fdba-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2020-04-23  5:38   ` 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).