I've found a solution that I like (and doesn't involve complicating pandoc). pip install htmlmin echo -e '
hello
world
' | pandoc -t html5 | htmlmin -s To answer your question: We write markdown by hand, which contains code blocks full of custom elements (for highlighting). Our custom format is bold within the codeblock. Using a pandoc filter, those custom blocks get turned into this HTML:
bold
We then use http://www.princexml.com/ to convert from HTML to a PDF. Thanks! On Friday, April 8, 2016 at 10:35:10 AM UTC-6, Matthew Pickering wrote: > > Can you please describe what you are doing? You mention that you're > going markdown -> html -> pdf (why?) > > The answer to your question is that pre is a block level element and > pandoc inserts newlines after each block from what I remember. > > On Fri, Apr 8, 2016 at 5:24 PM, Matt Haggard > wrote: > > Bah... google groups messed up the newlines, but maybe you get the idea? > > > > On Friday, April 8, 2016 at 10:23:55 AM UTC-6, Matt Haggard wrote: > >> > >> I have a filter that adds elements to code blocks (for bolding, > italics, > >> etc.). We go markdown -> html -> pdf and have noticed that sometimes > there > >> is an extra erroneous space between these custom elements in the final > PDF. > >> This breaks copying and pasting. > >> > >> It's because pandoc adds newlines between some elements in the > generated > >> HTML. This shows and example: > >> > >> echo -e > >> '
hello
world
' > | > >> pandoc -t html5 > >> > >>
> >> > >>
hello
> >> > >>
world
> >> > >>
> >> > >> > >> Is there a way I can get the output of the above to instead be this? > (or > >> even match the original input string) > >> > >> echo -e > >> '
hello
world
' > | > >> pandoc -t html5 > >> > >>
> >> > >>
hello
world
> >> > >>
> >> > >> > >> 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-discus...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org . > > To post to this group, send email to pandoc-...-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > > To view this discussion on the web visit > > > https://groups.google.com/d/msgid/pandoc-discuss/5f012215-b6af-4fa3-b8a7-e8ba2b51ac9b%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/b5fcdda1-aac1-4390-84ee-18d745e7a06c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.