From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.text.pandoc/14738 Path: news.gmane.org!not-for-mail From: Matt Haggard Newsgroups: gmane.text.pandoc Subject: Re: Can I eliminate newlines between elements in generated HTML? Date: Fri, 8 Apr 2016 09:40:43 -0700 (PDT) Message-ID: References: <5f012215-b6af-4fa3-b8a7-e8ba2b51ac9b@googlegroups.com> Reply-To: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_358_1220056064.1460133643248" X-Trace: ger.gmane.org 1460133647 29022 80.91.229.3 (8 Apr 2016 16:40:47 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 8 Apr 2016 16:40:47 +0000 (UTC) To: pandoc-discuss Original-X-From: pandoc-discuss+bncBDDMH3V6RIBRBC56T64AKGQEDAHXLWQ-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Fri Apr 08 18:40:47 2016 Return-path: Envelope-to: gtp-pandoc-discuss@m.gmane.org Original-Received: from mail-io0-f190.google.com ([209.85.223.190]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aoZSe-0006G8-Py for gtp-pandoc-discuss@m.gmane.org; Fri, 08 Apr 2016 18:40:45 +0200 Original-Received: by mail-io0-f190.google.com with SMTP id v3sf36751257ioe.0 for ; Fri, 08 Apr 2016 09:40:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20120806; h=sender:date:from:to:message-id:in-reply-to:references:subject :mime-version:x-original-sender:reply-to:precedence:mailing-list :list-id:x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=zKtlYIHPW1X+kPHY4hQ1uP2Y9djmgY8soFYxbQaudpA=; b=ULXdS2SmCkZKoH2oPuPwhiJ4FTeAD/V1rwLVjrMtDzjblcOBCMDIpTv/UC8dtZrJZd iVNFle7dyNsRDAsf2Pu8dWiwnjeXxeRXbtyCcMEDQaqIvm3KMMESFOawUPW2w4cRRKdR 0o/jVWusSssoGIWx/oCmnICM15DkYlGeoSm/bRhd1GVbcjymil7orhB70DMWcZ2kPoio 8IV0Ssw338pnkdegEiMmcoyI8BU0gXGTxJ9SUBaWXHo96rBNznzv56Yf21r341AuGZkL dXs1tAEBya3fn0ijeBrt50wvVUYsu6H2ZVV4SZuwxhL848AzBQRY/ZcIhLefnvsRWXzI Vltw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:message-id:in-reply-to:references:subject:mime-version :x-original-sender:reply-to:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=zKtlYIHPW1X+kPHY4hQ1uP2Y9djmgY8soFYxbQaudpA=; b=yWkaCPeQt+wE64UNjFA21cC8hqfN5V83TfXiVXoFMk3+Xaw4Tr8aE7IXkWt/8XlUwk KROdSFj6sP6hK/GgsrQAeqebs8NZB9Q4cVWPWlve2qR3sgcaHkMrntRx13frFU19CT0B 0m2b/ObA4Lu33fm/fP5JZ4N4X0TZ55KceiMzBX++tZY0t4t4dagX/Q+3w8aKhJ7X6wPc r5zilQ8YJxtDeQ1IOdNCRxE7GCvagvDCrvJcqFTbwTiLnNLF6RRUBzB8egn5iTrpHGVW 360kxyUyzYlkiUEKLWgUAm8TN6FJErQGu7piQHxOO9ZeoTa3wCdjfR7qClqB3g5jpH2z 39Iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=sender:x-gm-message-state:date:from:to:message-id:in-reply-to :references:subject:mime-version:x-original-sender:reply-to :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=zKtlYIHPW1X+kPHY4hQ1uP2Y9djmgY8soFYxbQaudpA=; b=eWOxQKDJ62aREvWQpi1Kle7pwkQW0KdQA4A6tH3q+gnxouMrrurAqWwKvRM9LqcECN JZuSxxw8w7rjk8COW6dGCLxO3yUhcm8+ufUIbsiOFmHkfDIGr1zezmadkYiB2fkdjHKg b4306aqx2/Pfga5Dfq4VGCrVSG9qscTUCjdf+IHNE3GMhg7EWXOJO92ckjLMG1vVNj7h CsEV5VWdy6H3voa5PCwMxQjQ1jURrHrbs6pfSyykA2MDoQl8PDacH1hbbMPUf0mnmNi5 oo2kiuUazKAi1/EwWrPlH7yy08MAJgDxfvCO9GR9fHSo88hRFa2D094OQcEfAd/4koxl qGvg== Original-Sender: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Gm-Message-State: AD7BkJIcWaGFHc8JsJUSfkDeXGwpnPChaX5XfQMf4uPKXGyY4RMcDHcsWW7AdZff9SeFHg== X-Received: by 10.182.102.73 with SMTP id fm9mr114178obb.9.1460133644049; Fri, 08 Apr 2016 09:40:44 -0700 (PDT) X-BeenThere: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Original-Received: by 10.182.63.35 with SMTP id d3ls265847obs.20.gmail; Fri, 08 Apr 2016 09:40:43 -0700 (PDT) X-Received: by 10.182.40.227 with SMTP id a3mr113240obl.14.1460133643576; Fri, 08 Apr 2016 09:40:43 -0700 (PDT) In-Reply-To: X-Original-Sender: haggardii-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org Precedence: list Mailing-list: list pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org; contact pandoc-discuss+owners-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org List-ID: X-Spam-Checked-In-Group: pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org X-Google-Group-Id: 1007024079513 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Xref: news.gmane.org gmane.text.pandoc:14738 Archived-At: ------=_Part_358_1220056064.1460133643248 Content-Type: multipart/alternative; boundary="----=_Part_359_229198503.1460133643248" ------=_Part_359_229198503.1460133643248 Content-Type: text/plain; charset=UTF-8 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. ------=_Part_359_229198503.1460133643248 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
I've found a solution that I like (and doesn't inv= olve complicating pandoc).

=C2=A0 =C2=A0 pip install htm= lmin
=C2=A0 =C2=A0=C2=A0echo -e '<div><pre><co= de>hello</code></pre><pre><code>world</code&g= t;</pre></div>' | pandoc -t html5 | htmlmin -s
To answer your question:

We write mar= kdown by hand, which contains code blocks full of custom elements (for high= lighting). =C2=A0Our custom format is <r:b>bold</r:b> within th= e codeblock. =C2=A0Using a pandoc filter, those custom blocks get turned in= to this HTML:

=C2=A0 =C2=A0 <pre class=3D"= bold"><code>bold</code></pre>

We then use=C2=A0http://www.princexml.com/ to convert from HTML to a = PDF.

Thanks!

On Friday, April 8, 2016 at 10:35:10 AM UTC-6, M= atthew 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 <hagg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> w= rote:
> 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.). =C2=A0We go markdown -> html -> pdf and have noti= ced that sometimes there
>> is an extra erroneous space between these custom elements in t= he final PDF.
>> This breaks copying and pasting.
>>
>> It's because pandoc adds newlines between some elements in= the generated
>> HTML. =C2=A0This shows and example:
>>
>> echo -e
>> '<div><pre><code>hello</code><<= wbr>/pre><pre><code>world</code></pre></= div>' |
>> pandoc -t html5
>>
>> <div>
>>
>> <pre><code>hello</code></pre>
>>
>> <pre><code>world</code></pre>
>>
>> </div>
>>
>>
>> Is there a way I can get the output of the above to instead be= this? =C2=A0(or
>> even match the original input string)
>>
>> echo -e
>> '<div><pre><code>hello</code><<= wbr>/pre><pre><code>world</code></pre></= div>' |
>> pandoc -t html5
>>
>> <div>
>>
>> <pre><code>hello</code></pre><= pre><code>world</code></pre>
>>
>> </div>
>>
>>
>> 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...@googlegroups.com.
> To post to this group, send email to pandoc-...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/pandoc-discuss/5f= 012215-b6af-4fa3-b8a7-e8ba2b51ac9b%40googlegroups.com.
>
> For more options, visit https://groups.go= ogle.com/d/optout.

--
You received this message because you are subscribed to the Google Groups &= quot;pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to pand= oc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@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.co= m.
For more options, visit http= s://groups.google.com/d/optout.
------=_Part_359_229198503.1460133643248-- ------=_Part_358_1220056064.1460133643248--