[racket users] Pollen tag question

44 views
Skip to first unread message

Kevin Forchione

unread,
Oct 30, 2020, 12:04:56 AM10/30/20
to Racket-Users List
Hi guys,
I’ve noticed that the elements being sent to a pollen tag don’t preserve the spacing when the text spans multiple lines for any space occurring before characters on the subsequent line, although does preserve the spacing between characters on that line.Is thes intentional?

For example: Racket 7.8 [cs], latest pollen version:

◊vb{ A B
C D}

Regardless of how many spaces are before the C, the tag elements will only return a single space, although it preserves the spacing between C and D.

Is that the expected result? It seems counter intuitive, as the spacing before A is preserved.

Kevin

Sorawee Porncharoenwase

unread,
Oct 30, 2020, 12:20:12 AM10/30/20
to Kevin Forchione, Racket-Users List

I think the issue is with vb. How does it work?

If you try

#lang pollen

@(define (vb . s) s)

◊vb{     A     B
               C     D}

you will find that it outputs:

'(vb "     A     B"
     "\n" 
     "           " 
     "C     D")

The third element is the space before “C”. It's not discarded.

Also notice that the "start" of the line is at the marker shown below

#lang pollen

@(define (vb . s) s)

◊vb{     A     B
 >>>           C     D}
This is due to how @ syntax works.

--
You received this message because you are subscribed to the Google Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to racket-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/2ECCF698-BD5D-4421-B28A-EC74471715B6%40gmail.com.

Sorawee Porncharoenwase

unread,
Oct 30, 2020, 12:21:57 AM10/30/20
to Kevin Forchione, Racket-Users List

Whoops. I meant:

#lang pollen 

◊(define (vb . s) s)

◊vb{     A     B
               C     D}

and the output is:

'("     A     B" "\n" "           " "C     D")

Kevin Forchione

unread,
Oct 30, 2020, 12:05:37 PM10/30/20
to Sorawee Porncharoenwase, Racket-Users List
Here’s my pollen.rkt:

#lang racket/base
(require pollen/decode pollen/misc/tutorial txexpr
         #;(only-in racket make-list string->number))
(provide (all-defined-out))
(define (root . elements)
   (txexpr 'root empty (decode-elements elements
     #:txexpr-elements-proc decode-paragraphs
     #:string-proc (compose1 smart-quotes smart-dashes))))

And  here’s an initial test.html.pm:


#lang pollen

       A       B
       C       D

Which produces
'(root "A       B" (br) "C       D")

Now if I add the vb as you’ve done, but don’t use the tag:

#lang pollen
◊(define (vb . s) s)

       A       B
       C       D

I get this:
'(root "A       B" (br) "       " "C       D")


Kevin


Kevin Forchione

unread,
Oct 30, 2020, 12:32:45 PM10/30/20
to Sorawee Porncharoenwase, Racket-Users List
If I remove my pollen.rkt from the directory and use:

#lang pollen



A B
C D

I get:
'(root "A B" "\n" "C D”)

But if I use:
#lang pollen
◊(define foo "foo")


A B
C D

I get:
'(root " " "A B" "\n" " " "C D")

Ievin

Matthew Butterick

unread,
Oct 30, 2020, 3:25:35 PM10/30/20
to Kevin Forchione, Racket-Users List


On Oct 29, 2020, at 9:04 PM, Kevin Forchione <lys...@gmail.com> wrote:

I’ve noticed that the elements being sent to a pollen tag don’t preserve the spacing when the text spans multiple lines for any space occurring before characters on the subsequent line, although does preserve the spacing between characters on that line.Is thes intentional?


Yes:

"Spaces at the beginning of body lines do not appear in the resulting S-expressions, but the column of each line is noticed, and all-space indentation strings are added so the result has the same indentation … If the first string came from the opening { line, it is not prepended with an indentation"


Kevin Forchione

unread,
Oct 30, 2020, 4:46:55 PM10/30/20
to Matthew Butterick, Racket-Users List


On Oct 30, 2020, at 12:25 PM, Matthew Butterick <m...@mbtype.com> wrote:

Spaces at the beginning of body lines do not appear in the resulting S-expressions, but the column of each line is noticed, and all-space indentation strings are added so the result has the same indentation … If the first string came from the opening { line, it is not prepended with an indentation”

Thanks, Matthew! Understanding dawns. So the padding of lines is relative to the “{“ and not from the beginning of the editor line as I was assuming. How very clever. That makes alignment much easier than I’d thought!  

Is this mentioned anywhere in the pollen tutorials? I must have missed it.

Kevin 
T

Matthew Butterick

unread,
Oct 30, 2020, 5:48:06 PM10/30/20
to Kevin Forchione, Racket-Users List


On Oct 30, 2020, at 1:46 PM, Kevin Forchione <lys...@gmail.com> wrote:

Thanks, Matthew! Understanding dawns. So the padding of lines is relative to the “{“ and not from the beginning of the editor line as I was assuming. How very clever. That makes alignment much easier than I’d thought!  

Is this mentioned anywhere in the pollen tutorials? I must have missed it.

Yes:

"The Pollen language is a variant of Racket’s own text-processing language, called Scribble. Thus, most things that can be done with Scribble syntax can also be done with Pollen syntax. For the sake of clarity & brevity, I’ve only shown you the highlights here. But if you want the full story, see @ Syntax in the Scribble documentation."

Reply all
Reply to author
Forward
0 new messages