Re: [pollen] Excessive spaces in pre

2016-12-29 Thread Matthew Butterick
One can also produce the same behavior in `#lang scribble/text`:

#lang scribble/text
@(require pollen/template/html)
@(define (test)
(->html `(pre " 1\n 2\n 3\n 4")))
@(define (iden . s) s)
  @iden{@(test)}

Given that this is not a Pollen problem per se, you might get a more satisfying 
answer by posting on issue on the `racket/scribble` repo (I do, sometimes) and 
see what they say. If the scribble authors agree it's a bug, and repair it, 
then the fix will flow into Pollen too.


> On Dec 29, 2016, at 10:54 AM, sorawee_porncharoenw...@brown.edu wrote:
> 
> Kind of. Here's an example:
> 
>   @(define (test)
> (->html `(pre " 1\n 2\n 3\n 4")))
>   @(define (iden . s) s)
>   @iden{@(test)}
> 
> which results in
> 
> 1
>   2
>   3
>   4
> 
> while 
> 
>   @(define (test)
> (->html `(pre " 1\n 2\n 3\n 4")))
>   @(define (iden . s) s)
> @iden{@(test)}
> 
> results in:
> 
> 1
> 2
> 3
> 4
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[pollen] Re: Excessive spaces in pre

2016-12-29 Thread sorawee_porncharoenwase
Kind of. Here's an example:

  @(define (test)
(->html `(pre " 1\n 2\n 3\n 4")))
  @(define (iden . s) s)
  @iden{@(test)}

which results in

1
  2
  3
  4

while 

  @(define (test)
(->html `(pre " 1\n 2\n 3\n 4")))
  @(define (iden . s) s)
@iden{@(test)}

results in:

1
2
3
4


On Thursday, December 29, 2016 at 1:21:35 PM UTC-5, m...@mbtype.com wrote:
>
> Here's the documentation of that behavior (this page is linked from within 
> the Pollen docs too):
>
>
> http://docs.racket-lang.org/scribble/reader.html#%28part._.Spaces__.Newlines__and_.Indentation%29
>
> I agree that it's confusing if you don't know to expect. But does it 
> surface in any situation other than the slightly oddball case of putting 
> spaces in front of a `when/splice`?
>
>
>
> On Sunday, December 25, 2016 at 12:40:46 AM UTC-8, 
> sorawee_por...@brown.edu wrote:
>>
>>   ◊(define test `(pre " 1\n 2\n 3\n 4"))
>>   ◊(->html test)
>>   ◊when/splice[#t]{◊(->html test)}
>>
>> in the template file results in:
>>
>> 1
>> 2
>> 3
>> 4
>>
>> 1
>>   2
>>   3
>>   4
>>
>> while:
>>
>> ◊(define test `(pre " 1\n 2\n 3\n 4"))
>> ◊(->html test)
>> ◊when/splice[#t]{◊(->html test)}
>>
>> results in:
>>
>> 1
>> 2
>> 3
>> 4
>>
>> 1
>> 2
>> 3
>> 4
>>
>> This causes wrong code display in some sites. For example, see 
>> http://mstill.io/blog/pollen-count.html
>>
>> I think I know why this happens: @-reader is trying to be smart, but it 
>> causes this unexpected behavior. Is this a known issue? I think it would be 
>> really great to have this documented somewhere so that people won't have to 
>> scratch their head.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] How to access a pollen source's path in pollen.rkt

2016-12-29 Thread Matthew Butterick

> On Dec 29, 2016, at 9:50 AM, Alexander George McKenzie  
> wrote:
> 
> I know it's possible to pass it in using (current-contract-region), but 
> that's a bit unwieldy.

Out of curiosity, why would you use that, rather than the `here-path` value in 
`metas`?



> Example: you define an ◊image function in pollen.rkt that pulls in images 
> from different directories based on which chapter the current pollen source 
> belongs to. You'd rather not have to call 
> ◊image[(current-contract-region)]{hamster.jpg} because it ruins the aesthetic 
> grace of your pollen file ;) 

I would probably convert `image` into a macro that expands into a function call 
that secretly passes `here-path` as an argument. An example of this approach:

https://groups.google.com/d/msg/pollenpub/KpcOlLUdQcg/jE1e2WrwAgAJ


-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[pollen] Re: Excessive spaces in pre

2016-12-29 Thread mb
Here's the documentation of that behavior (this page is linked from within 
the Pollen docs too):

http://docs.racket-lang.org/scribble/reader.html#%28part._.Spaces__.Newlines__and_.Indentation%29

I agree that it's confusing if you don't know to expect. But does it 
surface in any situation other than the slightly oddball case of putting 
spaces in front of a `when/splice`?



On Sunday, December 25, 2016 at 12:40:46 AM UTC-8, sorawee_por...@brown.edu 
wrote:
>
>   ◊(define test `(pre " 1\n 2\n 3\n 4"))
>   ◊(->html test)
>   ◊when/splice[#t]{◊(->html test)}
>
> in the template file results in:
>
> 1
> 2
> 3
> 4
>
> 1
>   2
>   3
>   4
>
> while:
>
> ◊(define test `(pre " 1\n 2\n 3\n 4"))
> ◊(->html test)
> ◊when/splice[#t]{◊(->html test)}
>
> results in:
>
> 1
> 2
> 3
> 4
>
> 1
> 2
> 3
> 4
>
> This causes wrong code display in some sites. For example, see 
> http://mstill.io/blog/pollen-count.html
>
> I think I know why this happens: @-reader is trying to be smart, but it 
> causes this unexpected behavior. Is this a known issue? I think it would be 
> really great to have this documented somewhere so that people won't have to 
> scratch their head.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[pollen] How to access a pollen source's path in pollen.rkt

2016-12-29 Thread Alexander George McKenzie
Hello everyone —

Is there a way to access a pollen file's source path directly in the 
pollen.rkt? 

I know it's possible to pass it in using (current-contract-region), but 
that's a bit unwieldy.

Example: you define an ◊image function in pollen.rkt that pulls in images 
from different directories based on which chapter the current pollen source 
belongs to. You'd rather not have to call 
◊image[(current-contract-region)]{hamster.jpg} because it ruins the 
aesthetic grace of your pollen file ;) 

Is there a module I can require in pollen.rkt that will help me out?

Any suggestions warmly appreciated!

-A

-- 
You received this message because you are subscribed to the Google Groups 
"Pollen" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to pollenpub+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.