Re: [pollen] Filenames in index.ptree

2016-07-20 Thread Matthew Butterick
AFAICT that's a bug (Pollen also permits the _ character to be used as an 
extension separator, and wasn't handling filenames like "foo_bar.html" 
properly). I've pushed a fix.


On Jul 19, 2016, at 11:14 PM, Chris Forster  wrote:

> Hi All,
> 
> Not totally sure if I'm doing something wrong here. I have a number of files 
> listed in an index.ptree file which have underscores in the names. For 
> instance:
> 
> - eliot_ulysses-order-myth.html.pm
> 
> When I start the pollen server, and visit the index.ptree file, it lists: 
> "eliot.ulysses-order-myth.html.pm (from eliot_ulysses-order-myth.poly.pm)" 
> which links to "http://localhost:8080/eliot.ulysses-order-myth.html;. If I 
> click this link, I get a 404... but if I visit instead 
> http://localhost:8080/eliot_ulysses-order-myth.html (note the first period 
> replaced with an underscore), it works. Are underscores somewhere in the 
> generation process being converted to periods? Should I not use underscores? 
> Or is this something else entirely?
> 
> Best,
> 
> Chris
> 
> -- 
> 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.

-- 
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] "cannot reference undefined identifier" when using eval in Pollen

2016-07-20 Thread Matthew Butterick

On Jul 19, 2016, at 9:42 PM, Joel Dueck  wrote:
> 
> So to that end I wrote the poly-branch-tag macro, a simplified version of 
> which is here:
> 
> (define-for-syntax site-poly-targets '(pdf html))
> 
> (define-syntax (poly-branch-tag stx)
>   (syntax-parse stx
> [(_ TAG:id)
>  (with-syntax ([POLY-FUNCS (for/list ([target (in-list 
> site-poly-targets)])
>  (list target (format-id stx "~a-~a" 
> target #'TAG)))])
>#'(define-tag-function (TAG attributes elems)
>(define poly-func (second (assq (current-poly-target) 
> 'POLY-FUNCS)))
>((eval poly-func) attributes elems)))]))

The problem is with 'POLY-FUNCS in the macro template. When you put the quote 
mark on the front, then everything inside POLY-FUNCS gets treated as a symbol. 
But in fact, you only want the target name to behave as a symbol, and you want 
your new function-name identifier to behave as a variable (that refers to your 
imported function). 

The solution is to match the target and function separately in your 
`with-syntax` pattern, and then only put the quote mark on the first one (once 
this problem is fixed, notice that the `eval` becomes unnecessary; notice also 
the use of the `...` matching operator so we can handle the new syntax bits in 
the template one at a time, rather than all at once):


#lang racket
(require rackunit (for-syntax syntax/parse racket/syntax) pollen/tag 
pollen/setup)

(define (html-bold . xs) "this is html-bold")
(define (pdf-bold . xs) "this is pdf-bold")

(define-for-syntax site-poly-targets '(pdf html))

(define-syntax (poly-branch-tag stx)
  (syntax-parse stx
[(_ TAG:id)
 (with-syntax ([((POLY-TARGET POLY-FUNC) ...) (for/list ([target (in-list 
site-poly-targets)])
(list target 
(format-id stx "~a-~a" target #'TAG)))])
   #'(define-tag-function (TAG attributes elems)
   (define poly-func (second (assq (current-poly-target) (list (list 
'POLY-TARGET POLY-FUNC) ...
   (poly-func attributes elems)))]))

(poly-branch-tag bold)

(check-equal? (bold "hi")
  "this is html-bold")

(check-equal? (parameterize ([current-poly-target 'pdf])
(bold "hi"))
  "this is pdf-bold")



Alternatively, you could write the `poly-branch-tag` macro using a `case` 
statement. No leading quote necessary for POLY-TARGET here, because `case` 
auto-quotes whatever is on the left side of each branch. (Notice again the use 
of `...` to repeat the branch with each target / function pair.)


(define-syntax (poly-branch-tag stx)
  (syntax-parse stx
[(_ TAG:id)
 (with-syntax ([((POLY-TARGET POLY-FUNC) ...) (for/list ([target (in-list 
site-poly-targets)])
 (list target 
(format-id stx "~a-~a" target #'TAG)))])
   #'(define (TAG . xs)
   (case (current-poly-target)
 [(POLY-TARGET) (apply POLY-FUNC xs)] ...)))]))
;;;







> I started by using the (case) branching, but I wanted a way to be able to add 
> output formats in the future without fiddling with the macro every time.
> 
> All of this seemed to be working fine in my single-file DrRacket test, but 
> when I try this in an actual Pollen project I get an error (see end of this 
> post). It complains that html-bold is undefined, but it is very clearly 
> defined in tags-html.rkt (which also contains a (provide (all-defined-out)) 
> directive). Indeed, I can change test.poly.pm to call html-bold directly and 
> that works. So calling html-bold directly works, but a macro that evaluates 
> to ((eval 'html-bold) args) doesn't. 
> 
> I feel I must be missing some nuance of the scope in which Pollen files work. 
> E.g., I can run the following in DrRacket:
> 
> (define (html-bold attrs elems)
>   `(strong ,@elems))
> ((eval 'html-bold) '() '("ahoy"))
> 
> But the following in test.poly.pm gives me the same error as I get when using 
> my macro:
> 
> #lang pollen
>  
> ◊(define (html-bold elems) `(strong ,@title))
> ◊((eval 'html-bold) '() '("ahoy"))
> 
> raco pollen render -t html posts/test.poly.pm
> rendering posts/test.poly.pm
> rendering: posts/test.poly.pm as test.html
> rendering: /template.html.p as /template.html
> html-bold: undefined;
>  cannot reference undefined identifier
>   context...:
>...n/pollen/tag.rkt:79:10
>(submod /Users/joel/Documents/code/thenotepad/posts/test.poly.pm g1083 
> inner): [running body]
>(submod /Users/joel/Documents/code/thenotepad/post/test.poly.pm g1083): 
> [traversing imports]
>/Users/joel/Documents/code/thenotepad/posts/test.poly.pm: [traversing 
> imports]
>
> /Users/joel/Library/Racket/6.4/pkgs/pollen/pollen/private/cache-utils.rkt:33:0:
>  path->hash
>
> /Users/joel/Library/Racket/6.4/pkgs/pollen/pollen/private/cache-utils.rkt:76:14:
>  temp16
>/Applications/Racket 

Re: [pollen] Deploying pollen server live

2016-08-19 Thread Matthew Butterick

On Aug 19, 2016, at 1:45 AM, Ifeoluwapo Eleyinafe  wrote:

> I am really new to programming but I can follow a few things.  Can anyone 
> please lay out a framework for deploying a book made using pollen live.  I'd 
> like to avoid the overhead of PHP, a database or a CMS.  Or is that 
> unavoidable?


You use Pollen to generate static files like HTML, CSS, JS etc. that you can 
then move onto a web server. There is no PHP, database, CMS (or even Racket) 
needed on the live server.

-- 
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] txexpr in attributes?

2016-09-10 Thread Matthew Butterick
1) if the citation is not a one-shot thing, I would recommend creating an 
external list of sources and making a reference into that list (rather than 
hard-coding it into the tag)

2) either way, rather than using a #:source attribute within `epigraph`, you 
could make a `source` subtag within, and then `epigraph` into tag function that 
decodes it (= maybe prints it; maybe discards it)

This is consistent with XML practice: it's typically a judgment call whether to 
use an attribute or subtag to represent a key/value pair. in this case, we can 
easily imagine that `source` would want to be a structured tag of its own. 

> On Sep 10, 2016, at 6:34 PM, Chris Forster  wrote:
> 
> 
> I am interested in creating a tag function that could accept as one of its 
> attributes, a complete txexpr; this txexpr could contain a citation for the 
> tagged material, or could offer a translation into another language. For 
> instance, providing source and language information for an epigraph: 
> 
> ◊epigraph[#:lang "gr" #:source (span "Aristotle, " ◊em{De Anima}" Book 1, 
> Chapter 4, 408b.18."]{ὁ δὲ νοῦς ἴσως θειότερόν τι καὶ ἀπαθές ἐστιν}
> 
> One could also imagine a "foreign" tag, that would allow one to include a 
> translation. This sort of complex information (textual citation, 
> translations, etc) is often not a string, but may require a full txexpr. (The 
> syntax in the above example, using a "span" is pretty ugly.)
> 
> With this structure, you could then convert this information into a footnote 
> for PDF or HTML, or discard it, etc.
> 
> Is using attributes on a tag not a good way to capture this sort of 
> information (I am coming to think it isn't). is there a better alternative I 
> should be exploring?
> -- 
> 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.

-- 
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] Pollen update: index pages for the project server

2016-08-17 Thread Matthew Butterick
I pushed an update today that improves the behavior of "/"-terminated URLs in 
the project server by using default index pages. The "index.html" case will 
work by default. I also added an `index-pages` setting to `pollen/setup` that 
will let you configure the names of the default pages that the project server 
will use.

This is just a convenience within the project server so that "/"-terminated 
URLs will do something useful. It does not carry over to `raco pollen render`, 
nor a live web server (where the equivalent behavior would be implemented with 
an ".htaccess" file).

-- 
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] Modifying output filenames (extensionless urls)

2016-10-02 Thread Matthew Butterick
I think that's likely a bug. I'll look into it.

On Sat, Oct 1, 2016 at 10:24 PM, Alexander George McKenzie <
a.mcken...@gmail.com> wrote:

> Since avoiding the problem altogether should never be discounted — Can you
>> elaborate on why you're stripping the extensions after the fact rather than
>> just naming source files "foo.pm" => renders to "foo"? (If you want it
>> to use an HTML template, you could add a `template` meta to the source
>> file).
>>
>
> I tried this to start with, but it breaks pollen! Since the documentation
> always talks of relevant extensions, I assumed this use-case is not
> supported, hence I forget to mention it. To reproduce, create a file
> "hello.pp" with contents:
>
> #lang pollen
> Hello world!
>
> If I run "raco pollen render hello.pp", it explodes:
>
> rendering hello.pp
> rendering: /hello.pp as /hello
> ->symbol: Can't convert #f to symbol
>   context...:
>/Applications/Racket v6.4/collects/racket/private/more-scheme.rkt:163:2:
> select-handler/no-breaks
>render26
>render-from-source-or-output-path
>loop
>(submod 
> /Users/agmck/Library/Racket/6.4/pkgs/pollen/pollen/private/command.rkt
> raco): [running body]
>/Applications/Racket v6.4/collects/raco/raco.rkt: [running body]
>/Applications/Racket v6.4/collects/raco/main.rkt: [running body]
>
> Renaming the file to hello.pm and adding a custom template meta gives the
> same result. And even if this were to work, I think I would run into
> additional problems using poly output files (how to specify an empty
> poly-tagret).
>
> So yeah :D My current solution works, I was just curious if anyone had an
> alternative way of dealing with this. I could use the template to write all
> output to a separate file, but that's all I can think of.
>
> Cheers!
>
> Alexander
>
> PS. Enjoyed your racketcon talk and very much looking forward to the rest
> of beautiful racket.
>
>

-- 
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] Modifying output filenames (extensionless urls)

2016-10-01 Thread Matthew Butterick

On Sep 28, 2016, at 4:42 AM, Alexander George McKenzie  
wrote:

> Question #1: is there a way I can override the here, next, previous functions 
> in pollen.rkt (so in template.html I can just use ◊here instead of ◊(no-ext 
> here)?
> 
> 
> 
> Question #2: is there a better solution I am missing? I understand that I can 
> use template.html to save a copy of my output to an alternative filename 
> (like in the pdf output examples) but I will still break the functionality of 
> the pollen server if I change the navigation links while developing.
> 

Since avoiding the problem altogether should never be discounted — Can you 
elaborate on why you're stripping the extensions after the fact rather than 
just naming source files "foo.pm" => renders to "foo"? (If you want it to use 
an HTML template, you could add a `template` meta to the source file). 

-- 
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] Beautiful Racket

2016-10-14 Thread Matthew Butterick

On Oct 14, 2016, at 6:00 AM, Tom Brooke  wrote:

> I assume Beautiful Racket is written with Pollen. I looked at it a while back 
> and worked through the  the one section and I haven't checked again until 
> yesterday - Amazing. A beautiful sight and apparently it isn't finished yet.
> 
> If you are Matthew great job if you aren't Matthew check it out.
> 
> I know this has been discussed before but I would be interested in the 
> mechanics of deploying it and assuming it is becoming a book, moving from 
> Pollen to an Ebook or paper book.

Thank you Tom. Yes it is all Pollen (of course). When it's done I'll put up the 
source (though the basic template was derived from this [1])

As with Practical Typography, I consider the Pollen version to be the "real" 
book. Once I get Quad off the ground, I could see using that to make a PDF that 
could be printed on demand.



[1] http://unitscale.com/mb/technique/dual-typed-untyped-library.html

-- 
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 current output type from `pollen.rkt'?

2016-10-20 Thread Matthew Butterick

On Oct 20, 2016, at 8:33 AM, lfacc...@jhu.edu wrote:
> Use (current-poly-target). Notice that the files have extensions such as 
> .html.pm and .atom.pm, and not .poly.pm. This is no accident, since each file 
> only generates one output type. Thus, (current-poly-target) always answers 
> with the default output type, 'html.

`current-poly-target` is a Racket parameter, which is a special data type that 
allows imperative action from afar. Rather than rely on Pollen inferring the 
poly target from the filename, you can set it directly:

;; pollen.rkt
#lang racket/base
(provide (all-defined-out))

(require pollen/setup)
(define (foo . xs)
  (case (current-poly-target)
[(atom) 'do-atom-foo]
[else 'do-html-foo]))


;; index.anything.pm
#lang pollen

;; we won't use the variable `target`, 
;; but if we set the parameter without assigning it,
;; it evaluates to `void`, which we'd have to filter out 
◊(define target (current-poly-target 'atom))

◊foo{bar}


> '(root do-atom-foo "\n")


> Use (->output-path (select-from-metas 'here-path metas)).  The metas are not 
> available to pollen.rkt. It could not be, since metas come from the source 
> modules (for example, index.html.pm), but the source modules need the 
> definitions in pollen.rkt. It would be a circular dependency.


Ah, that is actually not true. The `doc` relies on "pollen.rkt", but the 
`metas` do not, because they live in an independent submodule. See [1]. This is 
deliberate, so you can fetch the metas quickly, without the overhead of running 
"pollen.rkt". The side effect is that there is no circular dependency.

But you still need to pass the metas to the `foo` function somehow. Of course, 
you can do this explicitly ...

◊foo2[metas]{bar}

... but it's sleeker to use a macro. Here's one way to do it:

;; pollen.rkt
#lang racket/base
(provide (all-defined-out))

(require (for-syntax racket/base) pollen/file sugar/file pollen/core)

;; if this macro doesn't make sense I will elaborate
(define-syntax (foo2 stx)
  (syntax-case stx ()
[(_ ARG ...)
 (with-syntax ([METAS (datum->syntax stx 'metas)])
   #'(do-foo2 (select-from-metas 'here-path METAS) ARG ...))]))

(define (do-foo2 here-path . xs)
  (define ext (string->symbol (get-ext (->output-path here-path
  (case ext
[(atom) 'do-atom-foo2]
[else 'do-html-foo2]))

;; index.atom.pm
#lang pollen

◊foo2{bar}


> '(root do-atom-foo2 "\n")



> Use different functions foo/html and foo/atom. This doesn’t work because some 
> of the function calls are implicit. For example, in my real code, I want this 
> level of control on root, which is a magical function called by Pollen on the 
> module level

You could make `root` into a macro, following the pattern shown above, and 
branch to `foo/html` and `foo/atom`.



[1] 
http://docs.racket-lang.org/pollen/pollen-command-syntax.html?q=metas#%28part._.Retrieving_metas%29

-- 
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] Splitting multiple-output tag functions with a Racket macro

2016-11-12 Thread Matthew Butterick

On Nov 11, 2016, at 11:48 AM, Joel Dueck  wrote:

> I created a macro to help myself out as I consider adding a third and fourth 
> output format to a Pollen project.
> 
> I wrote about it at my Pollen-as-blog project here: 
> https://thenotepad.org/posts/splitting-pollen-tags-with-racket-macros.html
> Comments/criticism welcome.


I like these ideas, and it suggests to me that Pollen could have some better 
tools built in for managing poly projects.

After trying it this macro, my one thought was that using the `poly-branch-tag` 
macro requires naming the underlying tag functions in a certain way, which is 
potentially fragile (and requires escalating housekeeping).

Here's an alternate — not necessarily better or preferable — approach where the 
macro takes as input the targets and the source files containing the tags:

https://gist.github.com/mbutterick/caf88360fc0090305937ca54539054bc

Invoked like so:

(define-poly-tag-from-file root
  [html "pollen-local/tags-html.rkt"]
  [pdf "pollen-local/tags-pdf.rkt"])

In this case, the tag functions are all defined using the same names. So the 
macro fetches the `root` function out of "pollen-local/tags-html.rkt" and uses 
it for the 'html branch of the poly tag; then fetches `root` out of 
"pollen-local/tags-html.rkt" and uses it for the 'pdf branch, etc.


We could imagine a second macro that stacks on top of this one to generate 
other poly tags en masse:

(define-syntax-rule (my-poly-tags ID ...)
  (begin
(define-poly-tag-from-file ID
  [html "pollen-local/tags-html.rkt"]
  [pdf "pollen-local/tags-pdf.rkt"]) ...))

(my-poly-tags p i emph b strong code)


For that matter we could also imagine a macro that generates the call to 
`define-poly-tag-from-file` using the list of current poly targets, and a 
certain naming convention for the source files.





-- 
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] Splitting multiple-output tag functions with a Racket macro

2016-11-15 Thread Matthew Butterick
PS Jens Axel recommended looking at Racket units. I know nothing about those. 
Jens Axel is usually right, however.

-- 
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] Splitting multiple-output tag functions with a Racket macro

2016-11-14 Thread Matthew Butterick

On Nov 14, 2016, at 10:40 AM, Joel Dueck  wrote:

> What if Pollen automatically branched to tag functions prefixed with pdf: 
> when current-poly-target is 'pdf ? That is, if 'pdf is the current target, 
> Pollen would check for pdf:strong and, if it didn't find one, default to 
> plain-ol strong

When you talk about functions transparently overriding other functions in some 
kind of inheritance hierarchy, are you talking about ... classes?

http://docs.racket-lang.org/guide/classes.html

-- 
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.


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.


Re: [pollen] Using highlight.js

2017-01-04 Thread Matthew Butterick
> 
> Now the problem. I transferred the python function into pollen.rkt like 
> follows:
> 
> (define (python . xs)
>   `(pre (code ((class ,(format "~a" "python"))) ,@xs)))
> 
> 
> Now the python code will not be highlighted.
> 
> What is my mistake? Thanks a lot.



Did you `(provide python)` from your "pollen.rkt"?

-- 
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] Getting unbound identifier back

2016-12-23 Thread Matthew Butterick
> This might be an unpopular opinion, but I am kinda annoyed at how Pollen let 
> unbound identifiers become tag while sometimes it is actually my mistake. 

I agree that the behavior can "make debugging difficult sometimes". [1] But 
having to define every tag in advance would be a massive, soul-killing project. 


> So, I tried to get the unbound id error back:

You can wrap any function name in `def/c` to get the original behavior of 
`#%top`.

#lang pollen

◊foo{hi} ; '(foo "hi")

◊(def/c foo){hi} ; unbound identifier error

 

https://docs.racket-lang.org/pollen/Top.html?q=%23%25top#%28form._%28%28lib._pollen%2Ftop..rkt%29._~23~25top%29%29
 


-- 
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] Comments to book drafts online

2017-03-15 Thread Matthew Butterick

> On Mar 15, 2017, at 2:54 PM, Paulo Matos  wrote:
> 
> Would you be able to share the code doing this so I don't need to reinvent 
> the wheel? 


If you want to see the JS, it's here, and it's garbage:

http://beautifulracket.com/functions.js 


There are a zillion ways to send form data to a server, most of which are 
better than this. So if you want to follow a model, you could do better ;)


-- 
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] Comments to book drafts online

2017-03-15 Thread Matthew Butterick

> On Mar 15, 2017, at 7:56 AM, 'Paulo Matos' via Pollen 

> Once I get my book chapter draft online, what's the best way to enable public 
> comments to paragraphs?
> 
> I am sure I have seen this before but maybe not integrated with Pollen.

I've been doing something like this on the preview pages at beautifulracket.com 
. But it's not a Pollen thing — it's just a boring 
web form that cooperates with a boring server script. Then I use boring JS to 
insert the form under the paragraph when someone clicks in the margin.

I do use Pollen to generate the paragraph-specific URLs, but that happens when 
the page is compiled, not as a browser scripe.


-- 
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] Composing select functions is awkward

2017-03-09 Thread Matthew Butterick

> On Mar 9, 2017, at 1:17 PM, Shrutarshi Basu  wrote:

> It would be great to have some functions that allow us to easily select 
> txexprs from within txexprs.


Have you investigated `findf-txexpr` and `findf*-txexpr` in the `txexpr` module?

-- 
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] pollen rock 0.4

2017-07-20 Thread Matthew Butterick
OK, I have it working now. Sorry, I don't know what the problem was before.

Very nice! 

I will try using it more, but two suggestions for now:

+ in Preview mode, include an option to stack the panes vertically rather than 
horizontally.

+ in Preview mode, keep the source panel synchronized with the preview panel 
(e.g., if you click on a link to another Pollen output file)



> On Jul 19, 2017, at 11:10 PM, Junsong Li <ljs.darkf...@gmail.com> wrote:
> 
> Thanks for letting me know Matthew. I've updated the README.
> 
> (I just realized the doc was really bad. I'll start to use scribble to 
> document the tool.)
> 
> Btw, pollen-rock is just like current built-in pollen server. You can see the 
> rendered page. You also have a list of files on index page. The improvement 
> is that you can open one pollen file in the editor by clicking file names.
> 
> So, for now you can't "launch" an editor, instead you can only edit an 
> existing file in the editor.
> 
> 
> On Wednesday, July 19, 2017 at 10:51:46 AM UTC-7, Matthew Butterick wrote:
> Thank you Junsong. I've installed this version of `pollen-rock` but I don't 
> understand how to launch the editor. Can you please describe this further? 
> 
> 
> > On Jul 18, 2017, at 10:32 PM, Junsong Li <ljs.da...@gmail.com 
> > > wrote: 
> > 
> > Hi list, 
> > 
> > I am glad to release pollen-rock 0.4. 
> > 
> > https://github.com/lijunsong/pollen-rock 
> > <https://github.com/lijunsong/pollen-rock> 
> > 
> > Aside from numerous bug fixes and codebase improvement, Pollen-rock 0.4 
> > adds two features to the editor 
> > 
> >  - Auto-complete tag names exported from pollen.rkt 
> >  - auto-indent and syntax highlight racket code in p/pm/pp files 
> > 
> 
> 
> -- 
> 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 
> <mailto:pollenpub+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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] Can we compile a battery-included library?

2017-04-26 Thread Matthew Butterick

> On Apr 25, 2017, at 9:17 PM, Junsong Li  wrote:
> 
> Oh I didn't realize the typography module. I'll check it out. Do you accept 
> pull request on that module? :D

Maybe. Accepting a pull request means that I have to maintain that code as if 
it were my own. So I think of PRs as most appropriate for bug fixes & 
improvements to existing code. Otherwise, new functionality should go in a new 
package.


-- 
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] RacketCon 2017 & quasi-PollenCon

2017-06-12 Thread Matthew Butterick
RacketCon is happening Oct 7-8 in Seattle, and tickets are available now:

http://con.racket-lang.org

This year, we'll be having our usual day of speakers (Sat) but also a day of 
free-form hacking (Sun). Although Sunday is not officially "PollenCon", I will 
be there the whole day to work on Pollen-related matters with whomever wants to 
join me. So if you're interested in lobbying for new features, or making some 
rapid progress on your project, bring it! I will help as many people as I can, 
for as long as I can. (In addition, there will be lots of the usual Racket 
engineers around who can also help.)

The rest of the conference will be great too, and Seattle in October is solid 
gold. 

-- 
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] Combining multiple input pages into single output.

2017-09-23 Thread Matthew Butterick

> On Sep 23, 2017, at 3:29 AM, Karim Chellaoui  wrote:
> 
> I'm new to Pollen, I read the tutorial but couldn't find the way to apply 
> this answer. I'm getting confused: how to effectively insert submodule 
> ch1-submod in the main file? I tried different functions but it seems that 
> I'm missing something.

Perhaps post an example of code that isn't working? That will make it easier to 
pinpoint the problem.

-- 
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] Is there a nice way to display a hash table in my document?

2017-09-17 Thread Matthew Butterick

> On Sep 17, 2017, at 10:02 AM, 飛羽如月  wrote:
> 
> Now I want to feed each element of this list into a tag function, basically 
> something like
> ◊(map p (hash-map references (lambda (x y) (string-append x ": " y
> if it actually works. How do I make this work?

Which part isn't working? Your code works for me. (Though if you're using 
Pollen markup, you'd need to put the result of the `map` operation inside some 
kind of container, so it qualifies as an X-expression)

-- 
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] Re: Dynamically generating a pollen book site for every user

2017-10-02 Thread Matthew Butterick
As they say here in Hollywood: you're nobody till somebody hates you.


> On Sep 30, 2017, at 2:35 PM, Joel Dueck  wrote:
> 
> Unrelated, but I wish I had learned of that HN thread when it was fresh. So 
> much misinformation. I would have had fun arguing^H^H supplying better 
> information

-- 
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: Seeking Advice re: Pollen

2017-10-05 Thread Matthew Butterick

> On Oct 5, 2017, at 9:55 AM, George Cox  wrote:
> 
> Hi, I've stumbled across your "book-is-the-program" software Pollen and feel 
> it is a solution to something I've wanted for years. One quick question on 
> practical implementation:  Do you 'write' inside DrRacket, use a text editor, 
> or something else? I'm just curious what you find best ... based on your 
> experience.


Pollen source files are plain text. So you can use whatever text editor suits 
you, or switch among them.

Typically I use DrRacket for .rkt source files so I can test them more easily, 
and Sublime Text for "content" files (.html.pm etc.) written in the Pollen 
language. Those can also be run in DrRacket. But generally I prefer to look at 
the full preview in the project server.

There's also a clever in-browser editor called `pollen-rock` that you can add 
on to your Pollen installation:

https://pkgs.racket-lang.org/package/pollen-rock 


(Confidential to Junsong Li: perhaps consider adding some Scribble 
documentation with screen shots, so people who don't use Pollen yet can see how 
cool `pollen-rock` is ;)

-- 
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] invitations for thoughts about the Pollen / LaTeX nexus

2017-10-05 Thread Matthew Butterick
I know that more than a few Pollen users (Pollenizers?) use it as a front end 
to LaTeX. 

I don't use LaTeX in any deep way so I've not really considered the 
Pollen–LaTeX interaction deeply. 

OTOH it seems like:

1) There is a small set of recurring problems that arise with LaTeX, that could 
maybe have common solutions.

2) if Pollen had better LaTeX support, I'm sure it would bring more mildly 
dissatisfied LaTeX users* across to Pollen 

[* in other words, all of them]


The question, which I can't really answer, is what form this should take. From 
my dumb-person's understanding of LaTeX it would probably mean a set of 
independent components:

+ a `pollen/latex` dialect that converts LaTeX into X-expressions?

+ a `pollen/template/latex` module that provides convenience functions for 
converting X-expressions to LaTeX?

+ Obviously, Pollen/Racket would automatically add a lot of programmability to 
LaTeX (no one seems to dispute that while LaTeX is programmable, it should 
never actually be programmed).

+ As I show in the fourth tutorial, it's already possible to use the project 
server to generate LaTeX PDF previews. [1]

+ Though I've been reluctant to put self-contained templates into Pollen, I 
also recognize that a huge number of LaTeX users just rely on those six default 
templates that it's had since 1979 or whatever. So it would make sense to make 
it easy to use those templates in Pollen (though maybe that's better put into a 
separate add-on library, so that my philosophical purity is preserved.**

[** No. The real reason I've avoided putting readymade templates in Pollen is 
because I don't want to attract people who really want a turnkey system like 
Squarespace or WordPress.]

+ What else? And is it worth doing?


[1] 
http://docs.racket-lang.org/pollen/fourth-tutorial.html#%28part._.Adding_support_for_.P.D.F_output%29
 


-- 
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] A "second-run" for a txexpr?

2017-09-05 Thread Matthew Butterick

> On Sep 5, 2017, at 4:26 PM, trent...@ifi.uio.no wrote:
> 
> Bullet-list is in my control, I was just using the example from the pollen 
> Typography for Lawyers for inspiration since it felt like writing tags for 
> every list felt too heavy, and I figured others had run into this issue 
> before. So, I can re-write it to call the correct functions.

Leandro's advice is sound — call more functions, don't reduce to X-expressions 
as quickly. 

It doesn't sound like you need `eval`. I'm not an enemy of `eval`, but like 
macros, there's often a simpler way to get the same result.

FWIW Pollen isn't different from Racket in that regard — Racket keeps 
evaluating expressions until it gets a value, and then stops.

The weakness of my `detect-list-items` example in the `pollen-tfl` project is 
that I only need to generate lists for HTML, so I'm reducing the result 
immediately to an X-expression (by applying `(default-tag-function 'li)`).

In your case, you'd want to take the `list-of-li-paragraphs` and pass it to 
another function, let's call it `make-li`, that has different behavior 
depending on whether you're targeting HTML, or LaTeX, etc.

-- 
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] Does pollen pre-processor support languages other than English?

2017-09-07 Thread Matthew Butterick

> On Sep 7, 2017, at 7:53 PM, Leandro Facchinetti  wrote:
> 
> the Pollen development server could send an ‘Content-Encoding’ HTTP header, 
> to avoid issues like the one jcheng8 reported. By default, it would send 
> ‘UTF-8’, but this choice could be parameterizable via the ‘pollen/setup’ 
> mechanism.
> 
> What do you think?

A good idea, but most people (including me) aren't deploying their Pollen sites 
using the Racket web server. 

Thus, I've traditionally been reluctant to introduce server-level magic because 
it's not automatically portable to other web servers. (And then we'd have the 
companion issue: "hey, why did this break when I published it?")

But if you've ever made an .html.pm file and rendered it with the fallback 
Pollen HTML template, you'll see it includes a  
declaration at the top, which AFAIK is the most portable way to enforce the 
encoding:

https://github.com/mbutterick/pollen/blob/master/pollen/private/server-extras/fallback.html
 



-- 
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] Does pollen pre-processor support languages other than English?

2017-09-07 Thread Matthew Butterick

> On Sep 6, 2017, at 7:55 PM, Leandro Facchinetti  wrote:
> 
> Pollen does not come with opinions regarding enconding, the author (you) has 
> to specify it.

PS

By default, all Racket strings are encoded as UTF-8. And thus, so are Pollen 
strings.

https://docs.racket-lang.org/reference/encodings.html 


A curious fact of the modern world: text files don't have a way of explicitly 
signaling their encoding. Most programs that display plain text (for instance, 
editors like Sublime Text) rely on guessing (which usually works well enough).

But sometimes it doesn't.

If you really, really want to work with an encoding other than UTF-8, you can 
change your Pollen templates to convert the encoding at output (see, e.g., 
`reencode-output-port`).

https://docs.racket-lang.org/reference/port-lib.html#%28def._%28%28lib._racket%2Fport..rkt%29._reencode-output-port%29%29
 



-- 
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] Does pollen pre-processor support languages other than English?

2017-09-06 Thread Matthew Butterick

> On Sep 6, 2017, at 6:34 PM, jche...@gmail.com wrote:
> 
> Hi, first time pollen user here. I am trying to write a book in Chinese. 
> Seems like Chinese could not be correctly parsed by pre-processor. Below is 
> an example. Is there a way to get it working?Thanks a lot.
> 
> vegetables.pp
> #lang pollen
> Vegetables
> Broccoli 西蓝花
> 
> output in browser:
> Vegetables
> Broccoli è¥¿è“ èŠ±

The output uses UTF-8 encoding. So you need to make sure your browser is also 
using UTF-8. What you are seeing is the correct output, but not displayed with 
UTF-8.

-- 
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] Combining multiple input pages into single output.

2017-09-24 Thread Matthew Butterick
If you use the submodule technique, you need to `provide` the identifiers from 
inside the submodule, then you also need to insert them in the body of the 
source file:

#lang pollen

◊(module art1-submod racket/base
   (require "article1.html.pm")
   (provide doc))
◊(require (prefix-in art1: 'art1-submod))

◊art1:doc

◊(module art2-submod racket/base
   (require "article2.html.pm")
   (provide doc))
◊(require (prefix-in art2: 'art2-submod))

◊art2:doc


Though looking at it now, I don't remember why I recommended submodules. You 
can just do this:

#lang pollen

◊(require (prefix-in art1: "article1.html.pm"))

◊art1:doc

◊(require (prefix-in art2: "article2.html.pm"))

◊art2:doc




> On Sep 24, 2017, at 10:32 AM, Karim Chellaoui <fogiaf...@gmail.com> wrote:
> 
> I have four files:
> - article1.html.pm <http://article1.html.pm/> and article2.html.pm 
> <http://article2.html.pm/> looking like this: 
> #lang pollen
> ◊(define article1 "Article 1")
> ◊h2{◊article1}
> - index.html.pm <http://index.html.pm/>
> #lang pollen
> ◊(module art1-submod racket/base (require "article1.html.pm 
> <http://article1.html.pm/>"))
> ◊(require (prefix-in art1: 'art1-submod))
> ◊(module art2-submod racket/base (require "article2.html.pm 
> <http://article2.html.pm/>"))
> ◊(require (prefix-in art2: 'art2-submod))
> - template.html
> 
> 
> 
> 
> ◊(->html ◊doc)
> 
> 
> With this configuration I end up with and empty page when rendering 
> index.html.pm <http://index.html.pm/> . I guess I need to call for the 
> art1-submod and art2-submod, I just don't know how to do it?




> On Sep 24, 2017, at 10:32 AM, Karim Chellaoui <fogiaf...@gmail.com> wrote:
> 
> I have four files:
> - article1.html.pm <http://article1.html.pm/> and article2.html.pm 
> <http://article2.html.pm/> looking like this: 
> #lang pollen
> ◊(define article1 "Article 1")
> ◊h2{◊article1}
> - index.html.pm <http://index.html.pm/>
> #lang pollen
> ◊(module art1-submod racket/base (require "article1.html.pm 
> <http://article1.html.pm/>"))
> ◊(require (prefix-in art1: 'art1-submod))
> ◊(module art2-submod racket/base (require "article2.html.pm 
> <http://article2.html.pm/>"))
> ◊(require (prefix-in art2: 'art2-submod))
> - template.html
> 
> 
> 
> 
> ◊(->html ◊doc)
> 
> 
> With this configuration I end up with and empty page when 
> renderingindex.html.pm <http://index.html.pm/> . I guess I need to call for 
> the art1-submod and art2-submod, I just don't know how to do it?
> 
> Le sam. 23 sept. 2017 à 16:33, Matthew Butterick <m...@mbtype.com 
> <mailto:m...@mbtype.com>> a écrit :
> 
>> On Sep 23, 2017, at 3:29 AM, Karim Chellaoui <fogiaf...@gmail.com 
>> <mailto:fogiaf...@gmail.com>> wrote:
>> 
>> I'm new to Pollen, I read the tutorial but couldn't find the way to apply 
>> this answer. I'm getting confused: how to effectively insert submodule 
>> ch1-submod in the main file? I tried different functions but it seems that 
>> I'm missing something.
> 
> Perhaps post an example of code that isn't working? That will make it easier 
> to pinpoint the problem.

-- 
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] `pollen/markup` now filters out void values

2017-11-26 Thread Matthew Butterick
I pushed an update yesterday that changes `pollen/markup` to ignore void 
values, the same way `pollen/pre` and `pollen/markdown` do.

So this file:

#lang pollen/markup
◊(cond)

Which used to parse this way:

'(root <#void>)

Will henceforth do this:

'(root)

I don't know why I had it the other way. Probably seemed like a good idea at 
the time. It wasn't.

Anyhow, I don't think I'll characterize this as a "backward incompatible" 
change because:

a) Void values were never valid in X-expressions, so the only sensible thing to 
do with them in `pollen/markup` was to filter them out.

b) If you have existing code that filters out void values, this change won't 
break that code.

c) If someone has code that affirmatively relies on detecting void values ... 
that just seems ludicrously unlikely, because the whole point of `void` is to 
disappear.

But I've been wrong before. So if you have a counterexample to (c), let me know 
and I will consider rolling back the change. Otherwise, we'll just consider it 
a long-term wart, overdue for removal.



-- 
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: Typesetting Racket code with Pollen

2017-12-15 Thread Matthew Butterick
Neither. The code is tagged with Pygments. The terms that end up in the `k` 
and `nb` classes are Racket identifiers. These are passed through a 
function that generates a link to the docs, derived from the `docs` 
function here. [1] Then a few housekeeping details to make everything look 
right.

[1] https://unitscale.com/mb/technique/pollen.rkt.html


On Friday, December 15, 2017 at 10:57:23 AM UTC-8, Alexis King wrote:
>
>
> I notice that in Beautiful Racket you have nicely typeset and 
> hyperlinked Racket code, a la Scribble. Did you write something to do 
> this automatically using for-label requires, like Scribble does, or did 
> you insert the links manually?

-- 
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] Citations

2017-12-19 Thread Matthew Butterick

> On Dec 19, 2017, at 4:22 AM, J Lorieau  wrote:
> 
> 1. I'd like to test out the functionality for bibtex citation rendering in 
> Scribble, but the API from Racket is somewhat opaque and difficult to 
> use--this is largely due to my inexperience with racket and lisps. I have yet 
> to use these functions to render a single citation from a bibtex file.

That might be a better question for the main Racket mailing list, because many 
of its members are publishing academic papers with Scribble, using its 
templates that target LaTeX:

https://docs.racket-lang.org/scribble/generic-prose.html?q=sigplan 
 




> 2. I believe an alternative would be to try to incorporate scribbler code 
> that renders into pollen tags. Would this approach be feasible?
> 
> https://docs.racket-lang.org/scriblib/autobib.html

Scribble is designed more as an end-to-end system. I've found it's hard to 
usefully extract parts of Scribble and use them elsewhere, because they assume 
cooperation the Scribble document model:

https://docs.racket-lang.org/scribble/core.html?q=prepart#%28part._parts%29 


No such model exists in Pollen (deliberately).

-- 
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] Citations

2017-12-19 Thread Matthew Butterick

> On Dec 19, 2017, at 8:13 AM, jakedrake.r...@gmail.com wrote:
> 
> AFAICT, the main advantage of Pollen over Scribble is that Pollen is more 
> extensible so that a user could customize the latex template and easily add 
> new tag functions. Is that indeed the case?

You can add tags to Scribble too. But with Scribble you're working through an 
intermediate abstraction (that is, the Scribble document model). With Pollen, 
you aren't. 

It's analogous to using a big JavaScipt app framework vs. vanilla JavaScript. 
With a framework, you get a lot of functionality for free. But you have to 
learn the framework. And accept its limitations. Without it, you have to handle 
more heavy lifting at the outset. But you get more control over the outcome.




> Faced with a new writing project, it would be useful to learn the advantages 
> of pollen vs scribble and other products. I believe you make the case, in 
> part, for something like pandoc vs pollen. As a suggestion, this might be a 
> useful item to add to the documentation

I agree. But I've never seriously used Pandoc or LaTeX, so I have no insights 
on how Pollen compares. (Though someone who does would be welcome to contribute 
a relevant section to the docs.)

-- 
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] pollen for slide-show presentations

2017-11-11 Thread Matthew Butterick

> On Nov 10, 2017, at 11:58 PM, Saša Janiška  wrote:
> 
> 
> What do you think whether Pollen is the right tool for the job?
> 
> Let me add that besides slide presentation, I'd like to have same source
> document to create handouts etc.


IIRC we had this discussion in Feb 2016:

https://groups.google.com/d/topic/pollenpub/E0Xn66e0tgQ/discussion 


As I said then, "I think you will be happier with Scribble." 

Though now, I think you will be happier with anything but Pollen.



 

-- 
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] pollen for slide-show presentations

2017-11-11 Thread Matthew Butterick

> On Nov 11, 2017, at 9:47 AM, Saša Janiška  wrote:
> 
>> Though now, I think you will be happier with anything but Pollen.
> 
> OK, thank you for clear input.


I should be a little clearer: it seems to me that a theme in your questions 
across the years has been "is Pollen a turnkey solution for X". My answer to 
this kind of question has always been (and will remain) no. Pollen is, at 
heart, a programming environment. The benefit is more control. The cost is more 
heavy lifting. This is not a bug. It is a feature. 

So to those looking for turnkey solutions, I will always suggest looking 
elsewhere, because that is the most honest and efficient answer.

-- 
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 insert CDATA?

2017-11-20 Thread Matthew Butterick

> On Nov 19, 2017, at 10:49 PM, a.bezle...@gmail.com wrote:
> 
> I need to export in "confluence storage format" - 
> https://confluence.atlassian.com/doc/confluence-storage-format-790796544.html#ConfluenceStorageFormat-Links
>  
> 
> 


I just pushed an update that will handle ""))

◊(->html
  ◊ac:link{
 ◊ri:attachment[#:ri:filename "atlassian_logo.gif"]{
  ◊ac:plain-text-link-body{◊as-cdata{Link to a Confluence Attachment)

;;;

Result:



* * *

Supernerds might point out that this fix is a bit of a cheat: The official 
grammar for X-expressions includes the `cdata` structure type. [1] But Pollen 
still does not support this `cdata` structure directly.

The problem is that the `cdata` is an outlier in the grammar: it's the only 
element that can't be serialized (meaning, written to a string in a way that 
allows it to be reconstituted later). Pollen relies heavily on disk caching. So 
the problem is that these `cdata` objects can't be cached to disk. CDATA 
strings, however, can be.

I'm not sure what the deeper fix would be — probably to update Racket's `xml` 
module so that its structures, including `cdata`, are serializable.


[1] 
https://docs.racket-lang.org/xml/index.html?q=xexpr%3F#%28def._%28%28lib._xml%2Fprivate%2Fxexpr-core..rkt%29._xexpr~3f%29%29
 


-- 
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 insert CDATA?

2017-11-20 Thread Matthew Butterick

> On Nov 20, 2017, at 12:39 PM, a.bezle...@gmail.com wrote:
> 
> Unfortunately in this case the result for
> 
> ◊(->html
>   ◊ac:link{
>  ◊ri:attachment[#:ri:filename "atlassian_logo.gif"]{
>   ◊ac:plain-text-link-body{◊as-cdata{Text with <> )
> 
> is
>  ri:filename="atlassian_logo.gif">![CDATA[Text 
> with  ]]

That's strange. Did you update your `pollen` like so?

raco pkg update --update-deps pollen

I get a different result:

; program
#lang pollen/pre
◊(require pollen/template/html)

◊(define (as-cdata string)
   (string-append ""))

◊(->html
  ◊ac:link{
 ◊ri:attachment[#:ri:filename "atlassian_logo.gif"]{
  ◊ac:plain-text-link-body{◊as-cdata{Text with <> )


 result






> but thanks for you example, looking at this, the following idea came me

Your code won't work on HTML blocks with more than one CDATA.

-- 
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 insert CDATA?

2017-11-19 Thread Matthew Butterick
Seems like it should work. Not sure why it isn't. I'll look into it.


> On Nov 19, 2017, at 1:10 PM, a.bezle...@gmail.com wrote:
> 
> 
> 
> My plan_b.html.pm
> 
> #lang pollen
> ◊as-cdata{567}
> 
> 
> My pollen.rkt
> 
> #lang racket/base
> (require pollen/tag)
> (require pollen/decode)
> (require txexpr)
> (require xml)
> (require racket/list)
> (provide (all-defined-out))
> 
> (define (as-cdata string)
>   (cdata #f #f string))
> 
> 
> My template.html
> 
> 
> ◊(->html ◊doc)
> 
> 

-- 
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 insert CDATA?

2017-11-19 Thread Matthew Butterick
BTW the `->html` function, consistent with the HTML spec, will automatically 
treat `script` and `style` blocks as CDATA, so if that's what you're aiming 
for, no special sorcery needed.


> On Nov 19, 2017, at 3:36 PM, Matthew Butterick <m...@mbtype.com> wrote:
> 
> Seems like it should work. Not sure why it isn't. I'll look into it.
> 
> 
>> On Nov 19, 2017, at 1:10 PM, a.bezle...@gmail.com 
>> <mailto:a.bezle...@gmail.com> wrote:
>> 
>> 
>> 
>> My plan_b.html.pm
>> 
>> #lang pollen
>> ◊as-cdata{567}
>> 
>> 
>> My pollen.rkt
>> 
>> #lang racket/base
>> (require pollen/tag)
>> (require pollen/decode)
>> (require txexpr)
>> (require xml)
>> (require racket/list)
>> (provide (all-defined-out))
>> 
>> (define (as-cdata string)
>>   (cdata #f #f string))
>> 
>> 
>> My template.html
>> 
>> 
>> ◊(->html ◊doc)
>> 
>> 
> 

-- 
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 print time/call for a racket function?

2017-11-21 Thread Matthew Butterick

> On Nov 21, 2017, at 1:23 PM, Karim Chellaoui  wrote:
> 
> I'm still new to Pollen so excuse me if I missed the information but I'm 
> getting quite lost in the documentation...
> My goal is to write a date as version number, for today I would like it to be 
> "20171121" for instance. How can I best achieve this?
> I see that there is a Time racket package 
> https://docs.racket-lang.org/reference/time.html 
>  but it's unclear to me how 
> I can call it.



The `gregor` library has the better time & date tools. Assuming you want the 
date stamp to be consistently eight digits, you could use `~t` with a CLDR 
pattern: [1]

(require gregor)
(~t (now) "MMdd")


The code below is maybe more obvious, but doesn't work, because one-digit days 
and months won't be padded to two digits:

(require racket/date)
(define d (current-date))
(format "~a~a~a" (date-year d) (date-month d) (date-day d))


[1] http://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table 


-- 
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] Pollen update: better caching / faster renders

2017-11-05 Thread Matthew Butterick
Pollen will now cache output files on disk, in addition to the `doc` and 
`metas` from each Pollen source. This means that during renders, Pollen can 
skip the step where it combines doc & metas with the template (which is 
expensive). 

The idea is that after the project has been rendered once, you can make a 
change to one source file, and the next `raco pollen render` will go much 
faster. So incremental updates are less tedious.

If this doesn't work as advertised, please let me know.


-- 
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] pollen for slide-show presentations

2017-11-09 Thread Matthew Butterick
> On Nov 9, 2017, at 6:43 AM, Gour  wrote:
> 
> Has anyone thought about using Pollen for creating slide-show
> presentation like Racket's slideshow presentations?
> 
> One concern, besides creating slide-show itself is how one could select which
> font(s) to use and/or being able to 'embed' presentation with desired fonts in
> order to make it portable - iow. creating on one OS and presenting on another
> one?
> 
> Btw, that's also the question for which I haven't got answer related to
> Racket's slideshow package...


IIRC you did get an answer:

https://groups.google.com/d/msg/racket-users/HKdGYNAVAJw/OfYIzG9LAQAJ

"One thing that's not portable is the fonts that you use. You will 
probably have to install the same fonts or ensure that you only 
use fonts that are available on both machines."

Or if portability is an indispensable requirement, you could make a set of 
linked HTML pages with slideshow styling. SMOP, etc.


-- 
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] Licensing for Pollen projects

2017-12-07 Thread Matthew Butterick

> On Dec 7, 2017, at 3:26 PM, Joel Dueck  wrote:
> 
> For any serious work, though, I am wondering how this approach would really 
> shake out. When “the book is a program”, is it ever a) useful or b) legally 
> meaningful to license the prose and the code separately when they are 
> interwoven and distributed together?


I can't give anyone legal advice. For myself it's a question of how can I make 
the material useful to its intended audience. Code becomes more valuable when 
it can be copied and futzed with in a compiler. Whereas ordinary prose can 
already be futzed with in the mind. So IMO a permissive license has less 
incremental benefit.

I did a similar split-license idea with the pollen-tfl sample project. Some is 
open source and some not. [1] Nothing bad has happened. I considered enforcing 
this more strictly by splitting the open-source material into a 
`pollen-tfl-lib` package that was held in a public repo, and then a separate 
private repo with the other stuff. But that seemed complicated. It's partly a 
Pollen recruiting tool. So it should be as easy & complete as possible. 

OTOH I haven't released the Pollen source code for Beautiful Racket. I don't 
think it has much explanatory value beyond the Pollen docs & pollen-tfl. Plus, 
there's always work to make source code clean enough to be worth sharing.

Earlier in my career I was surrounded by piracy-obsessed sasquatches. Later, by 
free-culture zealots. Ultimately I think both miss the point. The only way to 
completely protect work is to not release it. At which point the revenue 
potential is $0. OTOH if you make everything free, the potential also goes to 
$0. Therefore, somewhere in between is the optimal level of freedom (or piracy 
if you prefer).  


[1] https://github.com/mbutterick/pollen-tfl 


-- 
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] pollen for slide-show presentations

2017-12-06 Thread Matthew Butterick
BTW here's a web-based tool for making platform-independent presentations: 

https://revealjs.com/

Basically it's Markdown sources with some magic JS & CSS. So all of this 
could be wrapped in a Pollen layer.


On Sunday, November 12, 2017 at 1:30:12 AM UTC-8, Gour wrote:
>
> On Sat, 11 Nov 2017 10:45:51 -0800 
> Matthew Butterick <m...@mbtype.com > wrote: 
>
> > I should be a little clearer: it seems to me that a theme in your 
> > questions across the years has been "is Pollen a turnkey solution for 
> > X". My answer to this kind of question has always been (and will 
> > remain) no. Pollen is, at heart, a programming environment. The 
> > benefit is more control. The cost is more heavy lifting. This is not 
> > a bug. It is a feature. 
>
> You're right, although ConText works on top of LuaTeX and one can use 
> Lua which is full-fledged programming language, but to me the the main 
> thing is "Pollen is a publishing system that helps authors make 
> functional and beautiful digital books." iow. high-quality web books, 
> while "ConTeXt is software for typesetting high-quality documents." 
> where PDF is the objective. 
>
>

-- 
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] cached-doc questions

2017-12-03 Thread Matthew Butterick

> On Dec 2, 2017, at 10:39 PM, Joel Dueck  wrote:

> The get-* functions will accept a pagenode or a path/string, but the cached-* 
> functions will only accept a path/string
> The get-* functions take an argument pointing at the output filename (when 
> using a pagenode), but the cached-* functions expect their argument to point 
> at the source filename (like get-doc does when you pass it a path/string)

Right. `get-doc` and `get-metas` came first. I think of them as the preferred 
high-level interface. Basically they just wrap `cached-doc` and `cached-metas`, 
which are lower-level implementational functions.

> Would you consider a change (or a pull request) to allow the 
> cached-*functions to accept a pagenode, just like the get-* functions do?
> If not, would it be worth updating the docs for pollen/cache to make clear 
> that the cached-* functions expect their pathish argument to point at a 
> source file? The argument is of course named source-path, but that still 
> feels 
> It seems there is a function, cached-require, that is provided by 
> pollen/cache but not documented, could this be included in the docs? I’m 
> curious what one might use it for.
I see your point, though that would collapse the high/low difference between 
the two sets of functions. For instance, if there's more convenience 
housekeeping to be done in the future, I think that should go only in `get-doc` 
nad `get-metas` (esp since cache functions are designed to be fast, so one 
should avoid putting anything extraneous in them)

I'd agree however that the message in the docs that "you should always use 
cached-doc and cached-metas to get data from Pollen source files" is misleading 
and should be changed. What I meant is "if you were considering using a 
`require` form, don't". 

Though in general, `get-docs` and `get-metas` are the wiser choice.

PS `cached-require` ... I think my idea was to make it possible to send any 
value exported by a Pollen source file into the cache, i.e. things other than 
`doc` or `metas`, for those who want to get fancy. I stubbed it out but never 
finished it, so that's why it's not in the docs.

-- 
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] Rewriting URLs in Pollen server

2018-05-04 Thread Matthew Butterick
Perhaps, though a feature that claims to be "compatible" comes with a lot of 
housekeeping and maintenance. 

Why couldn't the URL rewriting happen in the tag function, rather than at the 
Pollen level? For instance, you would write

◊clean-apache-link["ooh/la/la.html"]{my link text}

And use an environment variable to toggle the behavior of the 
`clean-apache-link` function at build time.


> On May 4, 2018, at 9:28 AM, Joel Dueck  wrote:
> 
> Would it ever be feasible to add URL rewriting to Pollen's web server that is 
> similar to (or even at least partly compatible with) Apache's mod_rewrite?
> 
> This way you could use so-called "clean URLs" in your links, and follow them 
> in your local Pollen server just as you would on your live web server.

-- 
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] Using expressions to define metas

2017-12-30 Thread Matthew Butterick

> On Dec 30, 2017, at 1:23 PM, Joel Dueck  wrote:
> 
> I would have expected define-meta to take the result of the expression rather 
> than quoting it. Is there a way to define a meta in terms of an expression 
> result?
> 
> I don’t have a use for this right now, just curious.


No, `define-meta` can only take a literal value (not an evaluated expression) 
for three reasons:

1) For speed, `define-meta` plucks out all the values without evaluating 
anything.

2) Evaluating things on the right-hand side of `define-meta` would lead to 
sticky questions about what evaluation environment is should be used 
(`racket/base`? `pollen/pre`? Can you bring in more imports?)

3) Literal values can be cached to disk (for even more speed).


That said, you aren't limited to symbols, numbers, and strings — you can put 
anything on the right side of `define-meta` that Racket understands as a 
literal value:

◊(define-meta hash-val #hash((a . 1) (c . 3) (b . 2)))
◊(define-meta regex-val #px"^\\d+$")


Still, if you absolutely positively need to export an expression that's 
evaluated at runtime, you can always just use `define` rather than 
`define-meta`. In this case, `title` will be automatically exported as "Hello 
There":

#lang pollen

◊(define title (string-titlecase "hello there"))

-- 
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] Re: Pollen project server does not invalidate compile cache when files required by pollen.rkt change. Any lighter option than turning off the compile caches?

2018-01-20 Thread Matthew Butterick
I've been persuaded this is a good idea & therefore implemented it. You can 
now track extra dependencies with the new setup value 
`compile-cache-watchlist`.


On Friday, May 5, 2017 at 10:01:07 PM UTC-4, Matthew Butterick wrote:
>
> On May 5, 2017, at 6:48 PM, Shannon Severance <s...@s53.me > 
> wrote:
>
> Finally found the answer in the documentation, Pollen tracks what it 
> tracks and not any more, turning off the cache is the only sollution. 
> https://docs.racket-lang.org/pollen/Cache.html#%28part._.Scope_of_dependency_tracking%29
>  
> <https://docs.racket-lang.org/pollen/Cache.html#(part._.Scope_of_dependency_tracking)>
>
>
> Right. I once considered adding a project setup value that would let you 
> add other external "rkt" files to the list of files tracked by the cache. 
> But when any "rkt" file changes (like "pollen.rkt"), usually the whole 
> cache gets invalidated anyhow. Which is basically equivalent to turning it 
> off. So the extra housekeeping seemed pointless. Anyhow, I'm open to better 
> suggestions.
>

-- 
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] Pollen Footnotes

2018-01-24 Thread Matthew Butterick

> On Jan 24, 2018, at 8:30 PM, Matthew Butterick <m...@mbtype.com> wrote:
> 
> FWIW this is the same as `(length (member name fn-names))` if you avoid 
> putting duplicates in `fn-names` to begin with. `member` returns the tail of 
> the list beginning with the matching item. So in this case, you'd get a list 
> of the footnote refs from the target name to the beginning (because the list 
> is being accumulated in reverse)



PS That last sentence was poorly phrased.

So in this case, the tail would comprise a list of the footnote names from the 
target name to the first name collected (because the list is being accumulated 
in reverse). 

-- 
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] Yet another Pollen project: mbtype.com

2018-01-12 Thread Matthew Butterick
https://mbtype.com

Whereas Practical Typography and Beautiful Racket were almost entirely static 
web pages, this is the first project where I used Pollen with scripts running 
on a Racket web server (many good ideas came from Jesse Alama's book Server: 
Racket [1]) 

The pages aren't generated dynamically, but they have elements (e.g., 
translated text) that are updated on demand from the server.

It worked fine. It wasn't much different from an ordinary Pollen project. 

The biggest problem — which I never solved in a satisfying way — was how to 
make a single testing environment. With a static Pollen site, you can run the 
project server and that accurately simulates just about everything.

But in this case, the project server is limited, because it can't make requests 
to the live Racket web server (due to the restriction against "cross-origin 
resource sharing" [2] which is a browser security policy, and has nothing to do 
with Pollen). There are apparently ways to defeat CORS. They all made me dizzy. 
I just learned to live with it. (Open to better ideas.)

The experience did not persuade me that Pollen ought to have more of a 
server-side scripting component. As it stands, a Pollen front end can cooperate 
with any server back end. I don't see any special virtue in tying them 
together, like a matching washer and dryer. 

Moreover, a lot of the coordination in-browser happens via JavaScript, and 
there's no way to supplant JS. (Even though I'm a decades-long JavaScript hater 
[3], I have to concede that ES6 is actually not bad at all. Though largely 
because it's imported so many Rackety/Lispy features.)



[1] http://serverracket.com/ 

[2] https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS 


[3] https://youtu.be/20GGVNBykaw?t=130 

-- 
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] Printing hyperlinks as links in some output targets, as footnotes in others, and as endnotes/separate document in still others

2018-02-13 Thread Matthew Butterick
Pollen delegates the nitty-gritty of generating layout to other tools. So the 
workflow is 

1) find a tool that will make the layout you want 
2) write a program that commands the tool to make this layout 
3) generate this program with Pollen. 

Today — hopefully not forever — the best option for making programmatic print / 
PDF layouts is LaTeX.

(Of course, on the web the tool is the web browser, and the "program" is HTML.)




> On Feb 13, 2018, at 9:39 PM, Benjamin Melançon  wrote:
> 
> Output target #2 (a fancier book, a magazine-like layout) is where i'm 
> looking for examples or reassurance...   here there needs to be an awareness 
> in some function somewhere of how pagination plays out, which seems to me 
> devilishly difficult, as the output of a footnote can affect how much room 
> there is for text and therefore if the linked item to be footnoted appears on 
> that page or not.  So, i'm looking for how Pollen has handled output to 
> paginated media.
> 
> Bonus:  A similar situation, but probably requiring a different mechanism, is 
>  ◊aside[This would be the last time he saw his trusty narrator.]{Paul took 
> control of his life and began writing his own story.}  — where in a simple 
> layout, perhaps .mobi, the aside ("This would be the last...") is printed 
> immediately below its associated paragraph ("Paul took...") and in a more 
> complex layout, perhaps meant for print, it is in an space made by an offset 
> in the text to the left or right, or in the margin.

-- 
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] Why is render-from-source-or-output-path function quicker than get-source and then render?

2018-02-10 Thread Matthew Butterick

> On Feb 9, 2018, at 10:18 PM, Junsong Li  wrote:
> 
> I think I might have hit a bug in racket serve/servlet. The actual blocking 
> point is the pollen get-source. It runs only half way through for certain js 
> files (it detects markup, markdown, and are blocked before 
> null-source/scribble-source/...), and running get-source alone never had the 
> issue.

You may be right that there is some issue in serve/servlet. I've also 
occasionally had problems with CSS renders stalling out, especially ones that 
produce big files. I never came up with a consistent test case that produced an 
error, however, so I was never able to trace the source of the problem.

-- 
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] Error rendering value from cache

2018-02-15 Thread Matthew Butterick
Hard to say exactly without seeing the code. Judging from the error msg:

> output: don't know how to render value: '#hasheq((here-path . 
> "/Users/basus/src/basus/publications/index.html.pm ") 
> (title . "Publications"))

It looks like you're trying to drop the whole `metas` table into your template, 
rather than just the `title` field.




> On Feb 15, 2018, at 1:48 PM, Shrutarshi Basu  wrote:
> 
> I also have a title tag, so maybe that is what causing this issue? Clearing 
> out the cache seems to let things compile fine. Any help would be appreciated.

-- 
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] importing one Pollen source into another

2018-02-19 Thread Matthew Butterick
I pushed an update today that prevents importing one Pollen source into another 
without changing the name of the imported `doc` and `metas`. If this is 
bothersome please let me know whether I should reconsider (ideally with an 
example that shows a practical use)

This wasn't behavior that was guaranteed before. It just happened to work — 
e.g., you could import one Pollen source into another, and use its `doc` 
without anything bad happening.

But I also don't mind preventing it, because it seems mischievous and 
potentially confusing.

The update does not prevent importing other Pollen sources with `prefix-in` to 
distinguish each `doc` / `metas` pair, which was always the wiser policy 
anyhow. For instance:

;

#lang pollen
◊(require (prefix-in foo: "foo.html.pm")
  (prefix-in bar: "bar.html.pm"))

The doc of foo is ◊foo:doc

The metas of bar are ◊(format "~v" bar:metas)

;

-- 
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] Automatic non-breaking space inserter in Russian

2018-08-21 Thread Matthew Butterick

> On Aug 21, 2018, at 9:12 AM, Natanael de Kross  wrote:
> 
> I mean there is so much going on and I know so little. Last month it's like a 
> whole new world got opened to me. My to-learn list is huge enough already and 
> my head is going to explode. But I can't say that I don't enjoy the process. 
> Anyway, I'm resilient and optimistic. I will manage it.


> It turned out that HTDP is not about Racket, it's about designing programs in 
> general (which is also good for me) and it uses BSL instead of Racket. So in 
> addition to Racket I also need to learn Regular Expressions, HTML, CSS, JS 
> and web typography tricks, not to mention Pollen itself to be able to publish 
> a decent book. All in all I'm an utter noob to the field.


At least you're starting with strong motivation. ;)

The challenge then becomes maintaining the motivation during the periods where 
things are broken (as, inevitably, they will be). 

My free advice to anyone in your position would be to work "horizontally" by 
making an end-to-end prototype of the project (e.g., simple Pollen source files 
that produce simple HTML). Then, iteratively improve parts of it, moving from 
bigger issues to smaller details. 

This is in contrast to working "vertically" where one tries to complete one 
part at a time, in detail, before moving onto the next part. This tends to be 
harder, less rewarding, and takes more time (because it's easier to develop 
faulty intuitions about the project when you're not iterating on a working 
version of the system).


-- 
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] ‘raco pollen start’ and ‘raco pollen render --recursive’ inconsistent with respect to ‘current-project-root’

2018-03-07 Thread Matthew Butterick
OK, I just pushed an update with a `--subdir` switch that behaves this way.


> On Mar 7, 2018, at 3:32 AM, 'Leandro Facchinetti' via Pollen 
>  wrote:
> 
> Hi,
> 
> Consider the following Pollen project:
> 
>  ;; a.txt.pp
>  #lang pollen
>  ◊(current-project-root)
> 
>  ;; s/b.txt.pp
>  #lang pollen
>  ◊(current-project-root)
> 
> I wish the outputs of ‘current-project-root’ to be consistent, always 
> pointing to the project root where a ‘pollen.rkt’ might live. When I ‘raco 
> pollen start’, the development server exhibits that behavior: I visit both 
> ‘http:///a.txt’ and ‘http:///s/b.txt’ and see the same 
> output. But when I ‘raco pollen render --recursive’, the outputs disagree: 
> ‘s/b.txt’ includes the ‘s/’ directory.
> 

-- 
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] Templates interlinked within templates interlinked

2018-03-15 Thread Matthew Butterick

> On Mar 15, 2018, at 6:00 AM, Joel Dueck  wrote:
> 
> I was pretty happy to learn about the web-server/templates package, which 
> allows you to include the contents of a template file and have it dropped 
> into the lexical context of the calling site. I’ve often wanted something 
> like this so I could write only a single copy of things like headers and 
> footers, and partials for listing chapters/articles in different contexts, 
> etc.

Pollen templates can do all this too, for a not-very-surprising reason (keep 
reading) ...


> I started fiddling with it in a Pollen project and, come to realize it was 
> working even though I hadn’t `require`d or `provide`d any functions from 
> web-server/template. How is this possible, I think. Some digging revealed 
> that Pollen implements its own `include-template` function—and that it is 
> provided automatically for code inside a Pollen template.

The `include-template` in Pollen is the same one as in `web-server/templates` 
[1] But I copied its source and changed it so that it could return binary files 
(like PDFs), which the usual one cannot.


> have you thought about including it in the docs? It’s pretty useful, and the 
> docs could also help avoid confusion among those who already know about 
> web-server/template. The docs do mention that include-template is used behind 
> the scenes but not that it's also available in Pollen templates. With 
> appropriate warnings about XSS concerns.

I suppose I could. I've just never been clear what could be done with 
`include-template` directly that isn't already possible through existing Pollen 
functions. When you apply a template to a markup source during a render, you're 
already using `include-template`.

> might it also be worth providing or reimplementing web-server/template's `in` 
> function? [2] (maybe it already does so, I confess I haven’t checked yet) And 
> then, perhaps including it in the docs somewhere as well.
Same — I suppose I've always thought that because Pollen has a notion of 
X-expressions and tag functions, they subsume `in` (which, unlike 
`include-template`, does no heavy lifting anyhow)



[1] 
https://github.com/mbutterick/pollen/blob/master/pollen/private/include-template.rkt
 


-- 
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] ‘raco pollen start’ and ‘raco pollen render --recursive’ inconsistent with respect to ‘current-project-root’

2018-03-07 Thread Matthew Butterick
This sounds wrong. 

And yet: is it? 

`current-project-root` is documented as the "the directory where you launched 
raco pollen start". (I'm not saying that pedantically — I often read the Pollen 
docs to find out things I've forgotten ;) 

The idea of `raco pollen render --recursive` is that every directory is being 
treated as its own subproject. Same as if you had done `cd` into each directory 
and `raco pollen render` from there. Indeed, during a `raco pollen render` 
operation, there's no way to infer what the "real" home directory is. Except 
that Pollen will search upward, to the top of your filesystem if necessary, for 
a "pollen.rkt".

So I come around to thinking your solution — create your own value and export 
it — is the right one.

Or, you could create a pagetree in the home directory — maybe it 
programmatically picks up the pages in the subdirectories — and render that. 
Then you can avoid `raco pollen render --recursive`, and rather just `raco 
pollen render` from the base directory, and `current-project-root` will 
(should!) stay consistent.



> On Mar 7, 2018, at 3:32 AM, 'Leandro Facchinetti' via Pollen 
>  wrote:
> 
> Consider the following Pollen project:
> 
>  ;; a.txt.pp
>  #lang pollen
>  ◊(current-project-root)
> 
>  ;; s/b.txt.pp
>  #lang pollen
>  ◊(current-project-root)
> 
> I wish the outputs of ‘current-project-root’ to be consistent, always 
> pointing to the project root where a ‘pollen.rkt’ might live. When I ‘raco 
> pollen start’, the development server exhibits that behavior: I visit both 
> ‘http:///a.txt’ and ‘http:///s/b.txt’ and see the same 
> output. But when I ‘raco pollen render --recursive’, the outputs disagree: 
> ‘s/b.txt’ includes the ‘s/’ directory.
> 
> My current workaround is to use ‘define-runtime-path’ in ‘pollen.rkt’ and 
> forego ‘current-project-root’. Is there a better solution?

-- 
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] ‘raco pollen start’ and ‘raco pollen render --recursive’ inconsistent with respect to ‘current-project-root’

2018-03-07 Thread Matthew Butterick

> On Mar 7, 2018, at 8:01 AM, 'Leandro Facchinetti' via Pollen 
>  wrote:
> 
> I believe the directory containing ‘pollen.rkt’ is the “real home directory.” 
> Is this conception problematic?

Yes. Consider a project structured like this at the top level:

a.html.pm
pollen.rkt
sub/b.html.pm
sub/pollen.rkt
sub/sub2/c.html.pm

When rendering "c.html.pm", it will discover the "pollen.rkt" in the "sub" 
directory, but that's not the top directory. (Indeed, it would also be fair, 
though a little weird, to rely on a "pollen.rkt" entirely outside the project 
directory. The point being, one cannot infer anything from the location of the 
"pollen.rkt")



> If I don’t specify a pagetree, Pollen already generates a reasonable default 
> from listing the contents of the directory. How about introducing a way to 
> instruct Pollen to extend this default to include subdirectories as well?

Fair suggestion. I'll look into this.

-- 
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] ‘raco pollen publish’ shouldn’t publish templates

2018-03-02 Thread Matthew Butterick
I agree. But templates can have any name. ("template.html" is just the default 
convention.) So automatic filtering could be finicky.

I think the best policy is to use the `omitted-path?` setting in pollen/setup. 
I just failed to do so in this instance ;)


> On Mar 2, 2018, at 11:42 AM, 'Leandro Facchinetti' via Pollen 
>  wrote:
> 
> For example, https://typographyforlawyers.com/template.html 
> 
> 
> Do you agree?

-- 
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] What are the differences between Scribble and Pollen?

2018-03-02 Thread Matthew Butterick

> On Mar 2, 2018, at 7:03 AM, Joel McCracken  wrote:
> 
> But, I have been wondering, how do Pollen and Scribble differ? Its not clear 
> to me if I should actually start with Pollen, or evaluate both libraries.


It's a question of control & flexibility. 

Scribble is more opinionated than Pollen:

1) it has its own document model 

https://docs.racket-lang.org/scribble/core.html?q=scribble%20document%20model#%28part._parts%29
 


2) and its own rendering system

https://docs.racket-lang.org/scribble/renderer.html?q=scribble%20document%20model
 



If you like those opinions, use Scribble.


Personally, I found Scribble capable but stubborn. Thus Pollen, which is a 
hybrid of what I like about Scribble (the text-based syntax) and what I like 
about Racket (total control). 

-- 
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] Pygments doesn't work

2018-09-26 Thread Matthew Butterick

> On Sep 25, 2018, at 11:49 PM, Evžen Wybitul  wrote:
> 
> I followed the tutorial from the official Pollen docs 
>  and tried to make 
> Pygments work. I have installed Pygments with both pip and easy_install, and 
> have `pygmentize` available on PATH. My `.html.pm` file looks exactly like 
> the example from the linked tutorial; and yet, the code isn't getting parsed 
> and is only inserted in . Could somebody help me troubleshoot this?


When you run this:

#lang pollen/markup
◊(require pollen/unstable/pygments)
◊highlight['python]{42}

You should get this:

Using Pygments.
'(root
  (div
   ((class "highlight"))
   (table
((class "sourcetable"))
(tbody
 (tr
  (td ((class "linenos")) (div ((class "linenodiv")) (pre "1")))
  (td
   ((class "code"))
   (div ((class "source")) (pre (span ((class "mi")) "42") "\n"))
   "\n"
   "\n"))


Or, if you just get code wrapped in ` ···`, that's a sign that your 
`pygments` installation couldn't be found by `pollen/unstable/pygments`.

-- 
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] Source files in multiple directories and generating an index

2019-01-20 Thread Matthew Butterick

> On Jan 20, 2019, at 12:03 PM, Evžen Wybitul  wrote:
> 
> 1. I can't find out how to keep the "notes" from different subjects in 
> different folders. The problem is I'm unable to dynamically build the 
> "master-index" of such files. 

What have you tried that didn't work? It seems straightforward to put code 
inside "master-index.html.pm" that reads the contents of adjacent directories 
and makes links.



> 2. I'd like to have the output files in one folder, and not side by side with 
> the source files (solvable by `raco pollen publish`, but that's an extra 
> command I have to manually run).


Which, in turn, can be solved by putting your build commands into a makefile. 
This feature has been requested before. But it's a lot more annoying to 
implement than it seems. Once the two directories are separate, there's a whole 
new set of error conditions that can arise.


> Forgot this: I'd also like to use only one template and css file for all of 
> the files. 


If you put your template & css in the root directory of the project, the source 
files in the subdirectories should find it.

-- 
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] Source files in multiple directories and generating an index

2019-01-21 Thread Matthew Butterick


> On Jan 20, 2019, at 11:33 PM, Evžen Wybitul  wrote:
> 
> And it works, partially. However, when I call `(next here)` on order to do 
> page navigation, the value for file1 is `analysis/file2.html`, but I'd need 
> it to be only `file2.html`. Of course, I could just strip the `[...]/` part 
> programatically, but that feels really hack-ish. Especially if there's a 
> better way.

In essence, you are tracking absolute path names in the pagetree, but you want 
them to behave like relative path names. You can either 1) convert them to 
relative path names, or 2) use them as absolute URLs (that is, prefix them with 
"/") though that assumes you only need the links to work when served via HTTP.

-- 
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 make a tag do nothing for specific output formats

2018-12-08 Thread Matthew Butterick

> On Dec 8, 2018, at 5:15 AM, Fletcher Hardison  wrote:
> 
> I've been doing something like:
> 
> (define (my-tag . xs)
>(case (current-poly-target)
>[(ltx) do something] 
>[else xs]))
> 
> Is there a better way to pass elements through without doing anything to 
> them. I'm finding that my current method oftens wraps the xs in a list when 
> returned which then messes up further functions txexpr? contracts.


Wrap the elements in the splice tag @ and they will be merged with the 
surrounding X-expression:

(define (my-tag . xs)
   (case (current-poly-target)
   [(ltx) 'do-something] 
   [else `(@ ,@xs)]))

(In this case the first `@` represents the splice tag and the second `@` is the 
quasiquote unsplicing operator)

See also:
https://groups.google.com/d/msg/pollenpub/3zZ_dwMbqdI/fandociXAwAJ

-- 
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] local-require local files in a template

2018-12-19 Thread Matthew Butterick
The template is merely an accessory for a source file being rendered. 
Everything in the template (including relative path strings) will be evaluated 
as if it were in the source file already. AFAICT this is consistent with how we 
usually expect relative path strings to behave. You hint that you'd prefer 
"utils.rkt" to resolve as if it were an absolute path, but that seems more 
contrarian.

If you don't like putting things in pollen.rkt — you say "pollute" but that is 
its raison d'être — then you could also make a helper package that can be 
invoked as `(local-require sorawee/utils)`.




> On Dec 19, 2018, at 1:54 PM, sora...@cs.washington.edu wrote:
> 
> It doesn't seem to be possible to local-require local files in a template. 
> Consider:

> 
> The reason why I want to local-require local files is that there are a lot of 
> functions that are only specific to the template file. Putting those in 
> pollen.rkt would solve the problem, but it would pollute the environment 
> unnecessarily.

-- 
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] Moving to Pollen from WordPress

2019-03-23 Thread Matthew Butterick
1) Converting individual HTML pages is sometimes more straightforward than 
unraveling the mysteries of the XML export.

2) See the `pollen/unstable/convert` module for possibly useful helper 
functions.

https://docs.racket-lang.org/pollen/Convert.html?q=pollen%2Funstable%2Fconvert 




> On Mar 22, 2019, at 12:18 PM, Shrutarshi Basu  wrote:
> 
> I've been a light Pollen user for a few years, but I'm considering biting the 
> bullet and finally converting my WordPress blog to Pollen. My blog has over 
> 500 posts on it at this point, so I definitely want to do an automated 
> conversion, possibly with a longer manual editing/checking process over the 
> next few months. I'm wondering if anyone has converted a WordPress blog or 
> site to Pollen and has any pointers? I will probably do an export to XML and 
> then convert that. I'm also considering using a converter for another static 
> site engine to get things into a more manageable format before pollenizing.

-- 
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] getting the filename of current input source in pollen.rkt

2019-03-28 Thread Matthew Butterick

> On Mar 28, 2019, at 6:23 AM, Ifeoluwapo Eleyinafe  > wrote:

>  I think I can pull from metas using 'here-path but I don't know how to 
> access metas from pollen.rkt. I can do so from the template file but then I 
> won't be able to use the data in my tag definitions.

Import `pollen/core` and use `current-metas`:

https://docs.racket-lang.org/pollen/Core.html?q=current-metas#%28def._%28%28lib._pollen%2Fcore..rkt%29._current-metas%29%29
 


-- 
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] Enthusiastic thank you and beginner question about metas

2019-03-28 Thread Matthew Butterick


> On Mar 28, 2019, at 12:42 AM, Zach Mandeville  
> wrote:
> 
> And below this I wanted a function to turn ◊author into that details element 
> by referencing ◊author text against that 'scuttlebutts' meta...but, I can't  
> get it to work.  The closest I got is this:

FWIW though you call `scuttlebutts` a "meta", in terms of Pollen terminology, 
that's imprecise. "Metas" are key/value pairs stored by a Pollen source 
(usually with `define-meta`), and exported via the `metas` hash table. 

The `select-from-metas` function is just a disguised version of `hash-ref`. So 
it won't complain about your attempt to treat `scuttlebutts` as a source of 
quasi-metas, because it's also a hash.

-- 
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] Simple question about nested custom tags

2019-02-25 Thread Matthew Butterick

> On Feb 25, 2019, at 3:43 PM, Brendan Stromberger 
>  wrote:
> 
> I've got a simple Pollen question for anyone that is familiar.

> 
> ◊; digram-row would map to an , and digram-row-item to an ,

> 
> (define (digram . elements)
>   (case (current-poly-target)
>   [(txt) elements]
>   [else (txexpr 'span empty elements)]))
> 
> (define (digram-row . elements)
>   (case (current-poly-target)
> [(txt) elements]
> [else (txexpr 'ol empty elements)]))


> ◊; but I felt that this was coupling my representation of the digram row
> ◊; a little too closely to the HTML output. I am wondering if it might not
> ◊; be better to shoot for something like this:
> 
> ◊digram-row{
>   ◊digram{◊(lesser-yin)}
>   ◊digram{◊(greater-yin)}
>   ◊digram{◊(lesser-yin)}
>   ◊digram{◊(lesser-yin)}
> }
> 
> ◊; I would like digram-row to be able to look at its children and if it
> ◊; determines that one of its children is a digram, then wrap the digram
> ◊; in an  automatically. How do I do this?



The `digram` tags will be evaluated first, and the results become the input to 
`digram-row`. Therefore, to create the kind of cooperation you describe, you 
need to handle both ends:

+ The result of `digram` needs to preserve the information that `digram-row` 
will find useful. Right now it just renders to a vanilla `span`. For instance, 
you could add an attribute to the result like '(digram "true"). 

+ `digram-row` needs to operate on its `elements` conditionally based on this 
information. You can do this however you like, though the `decode` function in 
`pollen/decode` is designed to be helpful for this kind of processing. 

-- 
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] Library for rendering Pollen to JSON?

2019-02-27 Thread Matthew Butterick

> On Feb 26, 2019, at 6:53 AM, Brendan Stromberger 
>  wrote:
> 
> Has anyone written a library to generalize (at least to some extent) the 
> process of rendering a Pollen document to JSON?

When you say "Pollen document" I take it you mean an X-expression (because a 
rendered source file could just be stored as a string).

Here's a start for functions that could convert between X-expressions and JSON. 
One wrinkle is encoding tags in JSON. JSON doesn't have a symbol type distinct 
from a string, so in this case I've just stuffed the tag in a little hash table 
of its own.

This is not the only way to do it, of course. But JSON (like XML) is lightly 
disguised S-expressions (and all X-expressions are S-expressions) so it seems 
straightforward.


#lang racket
(require txexpr json)

(define (xexpr->json x)
  (jsexpr->string
   (let loop ([x x])
 (match x
   [(txexpr tag attrs elems) (list (hash tag "") (attrs->hash attrs) (map 
loop elems))]
   [other other]

(define (json->xexpr x)
  (let loop ([x (string->jsexpr x)])
(match x
  [(list (hash-table (jstag "")) jsattrs jselems) (list* jstag (hash->attrs 
jsattrs) (map loop jselems))]
  [other other])))

(define tx '(p ((foo "bar")) "hello" (em "world")))
tx
(xexpr->json tx)
(json->xexpr (xexpr->json tx))

-- 
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] Navigation issue with Pollen templates

2019-02-28 Thread Matthew Butterick

> On Feb 28, 2019, at 6:42 AM, Brendan Stromberger 
>  wrote:
> 
> I can't seem to get next/previous navigation working. When I use `◊(previous 
> here)` and `◊(next here)`
> for my nav links, they evaluate to blank strings. `◊|here|` correctly 
> evaluates (as far as I can tell) to the current doc path.

`here-path` is a source path, but `here` is an output path. So if you're going 
to rely on `here` as the input to navigation functions, the pagetree must also 
contain output filenames. 

(This point was a little ambiguous in the docs that introduce `here`, so I've 
pushed a clarification.)

In this case, your pagetree contains source names, so `here` (as an output 
name) is not found, and `(next here)` and `(previous here)` evaluate to #f, 
which are both rendered as empty strings.

That said, you can use source names in the pagetree. In a `poly` project that 
may be the better idea. But if so, you need to do a little more housekeeping in 
your template files:

1) Instead of `here`, you'd want to pass `(hash-ref metas 'here-path)` to your 
pagetree function.

2) The result will be a source path, so you'd want to use `->output-path` to 
convert it to a usable output navigation link.

Separately, if you're including subdirectories in your pagetree, you need to be 
mindful of absolute vs relative pathnames. For instance, if the browser is 
visiting "front/cover.html" and links to the relative URL 
"front/author_note.html", then it will try to go to 
"front/front/author_note.html" (which doesn't exist). The simple solution is to 
make all your pagetree paths start from the project root, and in the template, 
stick with absolute URLs (that is, always prefix links in URLs with "/"). 

-- 
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] Using generated pagetree as an index pagetree

2019-02-28 Thread Matthew Butterick

> On Feb 28, 2019, at 9:09 AM, Brendan Stromberger 
>  wrote:
> 
> Side question but related: is `doc` a magical export from ptree files? How do 
> I know what is being exported from any given Pollen file (*.ptree, *.p, *.pm)?


`doc` and `metas` are exported from every Pollen source file. (Meaning, a file 
that starts with `#lang pollen` or one of its dialects — not a *.p file, which 
is just a source-control convenience.) You can examine the values of these 
exports on the DrRacket REPL.

There isn't anything magical about the pagetree subsystem. It's just a way of 
streamlining the common housekeeping of a) maintaining a tree-shaped list of 
things and then b) querying into that list of things, while c) staying 
consistent with the authoring conventions of other Pollen files. You could do 
it your own way.

Likewise, zooming out further, there isn't anything magical about Pollen at 
large. It's just a convenient way of writing Racket programs that involve a lot 
of text.

-- 
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] dropping support for Rackets earlier than verison 6.3

2019-02-27 Thread Matthew Butterick
Short version: Pollen will soon be dropping support for Rackets earlier than 
6.3. If this is bothersome for some reason, now is the time to say so.

Long version:

To date, Pollen (and associated libraries, like `txexpr` and `sugar` and 
`hypheneate`) have supported Racket 6.0 or later. 

This week, the Racket team added https to the Racket package server. This means 
it's no longer accessible to Racket 6.0 and 6.1 (which don't support fetching 
of packages through https)

This also means, however, that the Travis CI builds for these versions won't 
work. Since that's how I confirm that Pollen works on earlier versions, it 
means I have to drop support for them in Pollen.

I don't have to drop support for 6.2 necessarily. But if I'm going to drop some 
versions, I'd prefer to drop that one too.

This means that in the coming weeks I will be introducing Pollen 2.0, which 
will require Racket 6.3 or above. The 2.0 designation is needed because this 
update is not backward compatible. It does not signal any deeper changes. It 
will however allow me to delete some cruft that was necessary to support the 
older versions.

-- 
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] Using generated pagetree as an index pagetree

2019-02-28 Thread Matthew Butterick
Sometimes there's a misapprehension among new users that Pollen represents a 
monolithic "take it or leave it" system. (Not a surprise, because many 
page-making systems are like that.) Pollen tries to make simple projects easy 
(by providing non-astonishing default behavior) while not inhibiting complex or 
ambitious projects (by being hackable & mixing smoothly with Racket at large). 

Of course, these projects require more heavy lifting from the author. My free 
advice to anyone in your position would be to work "horizontally" by making an 
end-to-end prototype of the project (e.g., simple Pollen source files that 
produce simple HTML). Then iteratively improve.

This is in contrast to working "vertically" where one tries to design the whole 
project from the top down, like a snake swallowing a goat. This tends to be 
harder, less rewarding, and takes more time (because it's easier to develop 
faulty intuitions when things are unfamiliar).


> On Feb 28, 2019, at 10:07 AM, Brendan Stromberger 
>  wrote:
> 
> Thanks Matthew. My apologies for using the "M" word – at this moment, a lot 
> about Racket *feels* magical simply because I don't understand it yet ;) 

-- 
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] Navigation issue with Pollen templates

2019-02-28 Thread Matthew Butterick

> On Feb 28, 2019, at 3:17 PM, Brendan Stromberger 
>  wrote:
> 
> In my template, I have `◊(define here (path->pagenode (->output-path 
> (hash-ref metas 'here-path`
> 
> This renders out to a pagenode that looks something like 
> "body/3_the_trigrams.html"
> 
> When I send this pagenode into `next` or `previous`, it returns nothing.

Probably you want to do something like this (pseudocodishly, I have not checked 
that this works):

;;;

(define here-path (hash-ref metas 'here-path))
;; `here-path` is an absolute path, so if your pagetree nodes are relative to 
project root,
;; you'll also want to make this one relative the same way.
(require racket/path) ; for `find-relative-path`. 
(define here-path-relative (find-relative-path here-path 
(current-project-root)))
;; every node in a pagetree is a symbol
(define here-path-pagenode (string->symbol (path->string here-path-relative)))
;; having made our special pagenode, now we can query the pagetree
(define next-path-pagenode (next here-path-pagenode)) 
;; then we convert the result back to an output path
(define next-url (->output-path (build-path (current-project-root) 
next-path-pagenode)))

;;;

BTW if the code above lives inside a template, use `local-require` rather than 
`require`. But I would put the code inside a function in "pollen.rkt". In that 
case you can pass `metas` as an argument, or use the `current-metas` parameter.

-- 
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] Navigation issue with Pollen templates

2019-02-28 Thread Matthew Butterick


> On Feb 28, 2019, at 4:28 PM, Matthew Butterick  wrote:
> 
> But I would put the code inside a function in "pollen.rkt". In that case you 
> can pass `metas` as an argument, or use the `current-metas` parameter.

(Of course in that case the `require` could go at the top of the file with the 
others. I'm just mixing it into this sample to show what it's being used for)

-- 
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] Navigation issue with Pollen templates

2019-03-01 Thread Matthew Butterick

> On Mar 1, 2019, at 11:08 AM, Brendan Stromberger 
>  wrote:
> 
> build-path: contract violation
>   expected: (or/c path-for-some-system? path-string? 'up 'same)
>   given: 'body/2_understanding_the_lines.poly.pm
>   argument position: 2nd
>   other arguments...:
>#
My error, the last line needs to look like this (converting the node, which is 
a symbol, to a string, which `build-path` will accept):

(define next-url (->output-path (build-path (current-project-root) 
(symbol->string next-path-pagenode


-- 
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] Highlight code blocks are indenting too much

2019-03-10 Thread Matthew Butterick
When I tried your example, I got the right result. But there is a known issue 
with the Scribble indenter (which Pollen uses) changing the indentation within 
curly braces, which it shouldn't. [1] 

Thus, your example persuades me that it's better policy for Pollen to leave 
whatever indenting is already in the source. So I've pushed a repair for that.

[1] https://github.com/racket/scribble/issues/58


> On Mar 10, 2019, at 8:32 AM, Evžen Wybitul  wrote:
> 
> Hey, I'm not sure this is a problem with Pollen, that's why I'm not opening 
> an issue straight away. I hope someone will be able to help me resolve this 
> problem.
> 
> The code blocks in `highlight` aren't indented as they should be.

-- 
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] Question about Pollen markup

2019-03-10 Thread Matthew Butterick
The curly-brace syntax is almost always preferable. Keep in mind that the 
linebreaks are separated into their own elements (For more on this behavior see 
[1].) So this markup:

◊ol{The remaining forty-nine stalks ◊(comment "" ",") two piles.
another item
another item
}

Produces this list of five (not three) elements:

'("The remaining forty-nine stalks "
 (comment "" ",")
 " two piles."
 "\n"
 "another item"
 "\n"
 "another item")

Probably what you want is to preprocess `elements` into bigger chunks 
representing list items before passing each to your 'li tag lambda. For 
instance this:

(require sugar/list)
(filter-split '("The remaining forty-nine stalks "
 (comment "" ",")
 " two piles."
 "\n"
 "another item"
 "\n"
 "another item")
   (λ (e) (equal? e "\n")))


Produces these sublists:

'(("The remaining forty-nine stalks " (comment "" ",") " two piles.")
  ("another item")
  ("another item"))

For a more elaborate example of list-item detection, see the 
`detect-list-items` function [2] in the pollen-tfl sample project.

[1] 
https://docs.racket-lang.org/pollen/pollen-command-syntax.html#%28part._the-text-body%29
 
[2] 
https://docs.racket-lang.org/pollen-tfl/_pollen_rkt_.html#%28def._%28%28lib._pollen-tfl%2Fpollen..rkt%29._detect-list-items%29%29

> On Mar 10, 2019, at 4:08 PM, Brendan Stromberger 
>  wrote:
> 
> Hey there, still plugging away on my book project. I have a function for an 
> ordered list:
> 
> (define (ol . elements)
>   (case (current-poly-target)
> [(txt) elements]
> [else (txexpr 'ol empty
>   (map (lambda (e) (txexpr 'li empty (list e))) elements))]))
> 
> And I am using it like so:
> 
> ◊ol[
>   "The remaining forty-nine stalks are laid down and, aiming at the 
> middle of the pile with the right thumb◊(comment "" ",") two piles are 
> separated."
>   "another item"
>   "another item"
> ]
> 
> I want to use it this way because if I use the ◊ol{} syntax, my ◊comment{} 
> tag in the first item gets treated as its own , and generally the 
> generated markup is a bit weird – at each newline, a blank  is generated:

-- 
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] Highlighted blocks of code in pre tags wrapped in by decode-paragraphs

2019-03-11 Thread Matthew Butterick



> On Mar 11, 2019, at 2:48 AM, Evžen Wybitul  wrote:
> 
> The `decode-pagaraphs` incorrectly wraps blocks of code in  tags into 
> paragraphs. I'm using pygments, so within the  the code is split into 
> various s, which I think is causing the problem. Simply seting  
> as block-tag didn't fix this. Is there any other way? Thanks.


Do you have a test case that demonstrates this bug? `decode-paragraphs` should 
leave `pre` tags alone, because they're already block-level elements, as shown 
in the example below.



#lang racket
(require pollen/decode rackunit)

(define tx
  '((span "a") "\n\n" (pre "b") "\n\n" (span "c"))) 

(check-equal?
 (decode-paragraphs tx)
 '((p (span "a")) (pre "b") (p (span "c"

-- 
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] Re: ◊(select …) function returns nothing, always.

2019-03-15 Thread Matthew Butterick
I recommend sorting this out in the REPL, and then moving back to the template.

For instance, it should be possible to preview the result like so (where `doc` 
is imported from "your-source.poly.pm"):

#lang racket
(require pollen/core "your-source.poly.pm")
(select 'line-image doc)


Though as to "line-image is a tag defined in my pollen.rkt file" — keep in mind 
that `select` works on the output, not the input. So if `line-image` doesn't 
actually create a `line-image` tag in the output, then `select` indeed will not 
work.




> On Mar 15, 2019, at 9:33 AM, Brendan Stromberger 
>  wrote:
> 
> Google Groups glitched out on me. To finish my post, is there a way to 
> ◊(select) entire txexpr's from a document that are defined in Pollen.rkt? The 
> only way I can seem to get a return value from ◊(select) is when the contents 
> of the tag are a simple string.
> 
> On Friday, March 15, 2019 at 11:31:51 AM UTC-5, Brendan Stromberger wrote:
> Hi there, I'm trying to use ◊select in my template, but no matter what I try 
> to select, it returns nothing when rendered.
> 
> Here are some facts:
> My template file is called hexagram-template.html.p
> My .pm files that use this template are in the same directory, with the 
> extension (unsure if this matters) *.poly.pm 
> I am certain that this template is being used by my .pm files.
> The tags that I am trying to select from my template are unnested (not sure 
> if that matters)
> I am trying to use select in the following manner from my template file: 
> ◊(select 'line-image doc)
> line-image is a tag defined in my pollen.rkt file and used in my .pm files. 
> It returns a txexpr. I want to use (select) to include this txexpr in my 
> template. I want to use select this way, because I have 64 individual pages 
> that all have the exact same structure, and I want to pare those pages down 
> to a bare minimum, and use my template to describe the layout entirely, so I 
> can easily shift the layout of elements around within each page all at once. 
> If I use ◊(->html doc) on its own, I lose a lot of that flexibility in this 
> particular case.
> I notice that if I have a tag in my document, for instance ◊hello{world}, and 
> then use ◊(select 'hello doc) from my template, "world" is rendered 
> correctly. Does select only handle cases where the tag returns a simple 
> string? Is there a way to  
> 
> 
> -- 
> 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 
> .

-- 
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] Question about Pollen markup

2019-03-13 Thread Matthew Butterick
Here's how I debug Pollen functions. I have the `debug` package installed, and 
then I change my #lang line to

#lang debug racket/base 

(or `#lang debug racket` etc)

And then when I put #R in front of any expression, it prints to the Pollen 
console when a page is rendered. 

In this case, you could use `#R elements` to see exactly what's getting passed 
to your function. Or you could use `#R e #R (equal? e "\n")` to print `e` and 
the result of the predicate.




> On Mar 13, 2019, at 1:33 PM, Brendan Stromberger 
>  wrote:
> 
> Huh, I don't understand at all why, but for some reason, the code I just 
> posted above is now working. Maybe I inadvertently fixed some issue in the 
> template?
> 
> *shrug*
> 
> Anyway, thanks for the help, I think I understand working with xexprs a 
> lile bit more now.
> 
> On Wednesday, March 13, 2019 at 3:18:03 PM UTC-5, Brendan Stromberger wrote:
> Is there a reason the curly-brace syntax is preferable? I've tried for the 
> past 2 hours but using filter-split on "\n" seems to have no effect on my 
> output. It seems more explicit to me to just use the ◊(ul[…]) form and not 
> have to do any mangling of xexprs. 
> 
> I think this is what you were suggesting?
> 
> (define (ul . elements)
>   (case (current-poly-target)
> [(txt) elements]
> [else (txexpr 'ul empty
>   (map (lambda (e) (txexpr 'li empty e)) (filter-split elements (λ (e) 
> (equal? e "\n")]))
> 
> On Sunday, March 10, 2019 at 8:22:40 PM UTC-5, Matthew Butterick wrote:
> The curly-brace syntax is almost always preferable. Keep in mind that the 
> linebreaks are separated into their own elements (For more on this behavior 
> see [1].) So this markup:
> 
> ◊ol{The remaining forty-nine stalks ◊(comment "" ",") two piles.
> another item
> another item
> }
> 
> Produces this list of five (not three) elements:
> 
> '("The remaining forty-nine stalks "
>  (comment "" ",")
>  " two piles."
>  "\n"
>  "another item"
>  "\n"
>  "another item")
> 
> Probably what you want is to preprocess `elements` into bigger chunks 
> representing list items before passing each to your 'li tag lambda. For 
> instance this:
> 
> (require sugar/list)
> (filter-split '("The remaining forty-nine stalks "
>  (comment "" ",")
>  " two piles."
>  "\n"
>  "another item"
>  "\n"
>  "another item")
>(λ (e) (equal? e "\n")))
> 
> 
> Produces these sublists:
> 
> '(("The remaining forty-nine stalks " (comment "" ",") " two piles.")
>   ("another item")
>   ("another item"))
> 
> For a more elaborate example of list-item detection, see the 
> `detect-list-items` function [2] in the pollen-tfl sample project.
> 
> [1] 
> https://docs.racket-lang.org/pollen/pollen-command-syntax.html#%28part._the-text-body%29
>  
> <https://docs.racket-lang.org/pollen/pollen-command-syntax.html#%28part._the-text-body%29>
>  
> [2] 
> https://docs.racket-lang.org/pollen-tfl/_pollen_rkt_.html#%28def._%28%28lib._pollen-tfl%2Fpollen..rkt%29._detect-list-items%29%29
>  
> <https://docs.racket-lang.org/pollen-tfl/_pollen_rkt_.html#%28def._%28%28lib._pollen-tfl%2Fpollen..rkt%29._detect-list-items%29%29>
>> On Mar 10, 2019, at 4:08 PM, Brendan Stromberger > 
>> wrote:
>> 
>> Hey there, still plugging away on my book project. I have a function for an 
>> ordered list:
>> 
>> (define (ol . elements)
>>   (case (current-poly-target)
>> [(txt) elements]
>> [else (txexpr 'ol empty
>>   (map (lambda (e) (txexpr 'li empty (list e))) elements))]))
>> 
>> And I am using it like so:
>> 
>> ◊ol[
>>   "The remaining forty-nine stalks are laid down and, aiming at the 
>> middle of the pile with the right thumb◊(comment "" ",") two piles are 
>> separated."
>>   "another item"
>>   "another item"
>> ]
>> 
>> I want to use it this way because if I use the ◊ol{} syntax, my ◊comment{} 
>> tag in the first item gets treated as its own , and generally the 
>> generated markup is a bit weird – at each newline, a blank  is generated:
> 
> 
> -- 
> 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 
> <mailto:pollenpub+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
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] Getting the first N words: speed comparison

2019-03-21 Thread Matthew Butterick
As a Racket rule of thumb, I find that most efforts toward "custom-built loops" 
end in defeat, because the Racket macro expander and JIT compiler are aware of 
better optimizations. If I were writing another book on Racket, it would be 
High-Performance Racket, which I know more about than I used to, but still not 
very much ;)


> On Mar 21, 2019, at 12:15 PM, Joel Dueck  wrote:
> 
> Yes, first-words-regex2 is pretty much identical in performance to my longer 
> regex-less version. Thanks for the pointer! I was not familiar with the use 
> of regexp-match functions on an input port. It’s a little wild to me how even 
> using a string port, a general-purpose pattern matching function can be just 
> about as fast as a custom-built loop that knows exactly what it wants. But 
> the regex library has probably been pretty well optimized by now.

-- 
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] Combining multiple input pages into single output.

2019-02-14 Thread Matthew Butterick
`require` is a compile-time command, but `for-each` doesn't happen until run 
time. So there is a timing mismatch.

I think you probably want `dynamic-require`, which lets you import identifiers 
at run time:

◊(map (λ (fileName) (dynamic-require fileName 'doc)) fileList)

As for generating a list of files, you can do that whatever way suits you — 
don't overlook the `pagetree->list` function.


> On Feb 14, 2019, at 8:11 AM, Ifeoluwapo Eleyinafe  
> wrote:
> 
> Or maybe just do this?
> 
> ◊(define fileList (file->list index.ptree)) ;Not sure how to get the exact 
> path here
> ◊(for-each (lambda (fileName) 
>  ◊(require (prefix-in nextChapter: fileName)) ;
>  ◊nextChapter:doc
> )
> fileList)
> 
> On Thursday, February 14, 2019 at 10:32:22 AM UTC-5, Ifeoluwapo Eleyinafe 
> wrote:
> I know this is an old post but I'm hoping anyone can help. I'm trying to see 
> is if this process can be automated for any files listed in the index.ptree. 
> I'm thinking the code should look something like this:
> 
> ◊(define fileList (file->list index.ptree)) ;Not sure how to get the exact 
> path here
> ◊(for-each (lambda (fileName) 
>  ;all files suffixed with poly.pm so remove them and then convert the 
> string to symbol
>  ◊(define nextChapter (string->symbol (string-replace fileName ".poly.pm 
> <http://poly.pm/>" ""))) 
>  ◊(require (prefix-in nextChapter: fileName)) ;
>  ◊nextChapter:doc
> )
> fileList)
> 
> 
> I know this is probably terrible cringeworthy code but I don't know racket so 
> well. Any help would be greatly appreciated. Thank you.
> 
> On Sunday, September 24, 2017 at 3:53:34 PM UTC-4, Matthew Butterick wrote:
> If you use the submodule technique, you need to `provide` the identifiers 
> from inside the submodule, then you also need to insert them in the body of 
> the source file:
> 
> #lang pollen
> 
> ◊(module art1-submod racket/base
>(require "article1.html.pm <http://article1.html.pm/>")
>(provide doc))
> ◊(require (prefix-in art1: 'art1-submod))
> 
> ◊art1:doc
> 
> ◊(module art2-submod racket/base
>(require "article2.html.pm <http://article2.html.pm/>")
>(provide doc))
> ◊(require (prefix-in art2: 'art2-submod))
> 
> ◊art2:doc
> 
> 
> Though looking at it now, I don't remember why I recommended submodules. You 
> can just do this:
> 
> #lang pollen
> 
> ◊(require (prefix-in art1: "article1.html.pm <http://article1.html.pm/>"))
> 
> ◊art1:doc
> 
> ◊(require (prefix-in art2: "article2.html.pm <http://article2.html.pm/>"))
> 
> ◊art2:doc
> 
> 
> 
> 
>> On Sep 24, 2017, at 10:32 AM, Karim Chellaoui > wrote:
>> 
>> I have four files:
>> - article1.html.pm <http://article1.html.pm/> and article2.html.pm 
>> <http://article2.html.pm/> looking like this: 
>> #lang pollen
>> ◊(define article1 "Article 1")
>> ◊h2{◊article1}
>> - index.html.pm <http://index.html.pm/>
>> #lang pollen
>> ◊(module art1-submod racket/base (require "article1.html.pm 
>> <http://article1.html.pm/>"))
>> ◊(require (prefix-in art1: 'art1-submod))
>> ◊(module art2-submod racket/base (require "article2.html.pm 
>> <http://article2.html.pm/>"))
>> ◊(require (prefix-in art2: 'art2-submod))
>> - template.html
>> 
>> 
>> 
>> 
>> ◊(->html ◊doc)
>> 
>> 
>> With this configuration I end up with and empty page when rendering 
>> index.html.pm <http://index.html.pm/> . I guess I need to call for the 
>> art1-submod and art2-submod, I just don't know how to do it?
> 
> 
> 
> 
>> On Sep 24, 2017, at 10:32 AM, Karim Chellaoui > wrote:
>> 
>> I have four files:
>> - article1.html.pm <http://article1.html.pm/> and article2.html.pm 
>> <http://article2.html.pm/> looking like this: 
>> #lang pollen
>> ◊(define article1 "Article 1")
>> ◊h2{◊article1}
>> - index.html.pm <http://index.html.pm/>
>> #lang pollen
>> ◊(module art1-submod racket/base (require "article1.html.pm 
>> <http://article1.html.pm/>"))
>> ◊(require (prefix-in art1: 'art1-submod))
>> ◊(module art2-submod racket/base (require "article2.html.pm 
>> <http://article2.html.pm/>"))
>> ◊(require (prefix-in art2: 'art2-submod))
>> - template.html
>> 
>> 
>> 
>> 
>> ◊(->html ◊doc)
>> 
>> 
>> With this configuration I end up with and empty page when rendering 
>> 

Re: [pollen] Re: Source files in multiple directories and generating an index

2019-02-19 Thread Matthew Butterick
What is your `raco pollen version`?


> On Feb 19, 2019, at 3:56 PM, Evžen Wybitul  wrote:
> 
> Even with the new fix the relative paths don't work. I'm getting the 
> following error:
> 
> find-relative-path: contract violation
>   expected: (and/c path-for-some-system? simple-form?)
>   given: 
> #
> 
> My file looks like this:
> 
> #lang pollen
> 
> ◊define-meta[template]{../../lecture-page-template.html}
> ◊define-meta[title]{Analýza II}
> 
> And is in doc/analyza/, while the template is located in the same directory 
> as doc.

-- 
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] Re: Source files in multiple directories and generating an index

2019-02-19 Thread Matthew Butterick
The revision with the bugfix is 1.5.2028.835.


> On Feb 19, 2019, at 4:01 PM, Evžen Wybitul  wrote:
> 
> It says 1.5.1987.839
> 
> Dne středa 20. února 2019 1:00:33 UTC+1 Matthew Butterick napsal(a):
> What is your `raco pollen version`?

-- 
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] Source files in multiple directories and generating an index

2019-02-19 Thread Matthew Butterick
(FWIW I cannot reproduce your bug with 1.5.2028.835)


> On Feb 19, 2019, at 4:02 PM, Matthew Butterick  wrote:
> 
> The revision with the bugfix is 1.5.2028.835.
> 
> 
>> On Feb 19, 2019, at 4:01 PM, Evžen Wybitul > <mailto:wybitul.ev...@gmail.com>> wrote:
>> 
>> It says 1.5.1987.839
>> 
>> Dne středa 20. února 2019 1:00:33 UTC+1 Matthew Butterick napsal(a):
>> What is your `raco pollen version`?
> 

-- 
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] Writing in raw X-expressions

2019-04-06 Thread Matthew Butterick

> On Apr 6, 2019, at 4:00 PM, Daniel Sockwell  wrote:
> 
> I have a quick question: is it possible to use Pollen to write x-expressions 
> directly? That is, can I directly write
> 
>'(root "I want to attend " (em "RacketCon " (strong "this") " year") ".")
> 
> instead of
> 
>#lang pollen
>I want to attend ◊em{RacketCon ◊strong{this} year}.


Yes, you can insert Racket-style expressions instead of Pollen-style 
expressions. [1]

The `root` wrapper is always added by Pollen, but you can use the splicing 
operator `@` to accomplish the same thing. Therefore this:

#lang pollen/markup
◊(@ "I want to attend " (em "RacketCon " (strong "this") " year") ".")

is the same as this:

#lang pollen/markup
I want to attend ◊em{RacketCon ◊strong{this} year}.

Or mix the styles:

#lang pollen/markup

◊(@ "I want to attend " (em "RacketCon " (strong "this") " year") ".")
I want to attend ◊em{RacketCon ◊strong{this} year}.


[1] 
https://docs.racket-lang.org/pollen/pollen-command-syntax.html#%28part._the-two-command-styles%29
 


-- 
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] Semantic markup in generated X-expression?

2019-04-12 Thread Matthew Butterick
OK, then suppose you store the attributes in the X-expressions for the purposes 
of your internal Pollen processing. You can always strip out those private 
attributes before the `doc` is injected into the HTML template. Does that work?

You're right that the X-expression closely models HTML output (which makes it a 
convenient choice for Pollen). But it's also a vanilla Racket list structure, 
so you can manipulate it with the usual list functions (with the `txexpr` 
module sugaring over some small annoyances)
 

> On Apr 12, 2019, at 9:02 AM, dsockw...@gmail.com wrote:
> 
> But note that that's not quite what I was asking about: that preserves the 
> semantic info all the way through to the generated HTML.  As you mentioned, 
> that could be good if I wanted to apply CSS based on the semantics.  But it 
> wouldn't do what I was asking about: keep the semantics in the X-expression 
> without keeping them in the HTML.
> 
> Based on your answer, I'm assuming that there isn't a simple way to do what I 
> was asking.  Based on that (and rereading some of the docs), I've concluded 
> that I was thinking of the generated X-expression all wrong.  I was thinking 
> of the X-expression as basically still a source file, albeit one that has 
> been processed.  But I it seems like it's very nearly an output file—it's 
> pseudo-HTML (or pseudo-text, or pseudo-LaTex, or whatever the final output 
> format is).  From that point of view, it makes perfect sense that it'd have a 
> structure that's limited to the semantics of HTML/text/LaTex.

-- 
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] Semantic markup in generated X-expression?

2019-04-12 Thread Matthew Butterick
You could preserve the semantic information inside a `class` attribute, or 
custom attribute. These would also be reachable through CSS selectors, if 
you're into that.

> On Apr 12, 2019, at 7:51 AM, Daniel Sockwell  wrote:
> 
> In general, my intuition is that the semantics should be preserved as long as 
> possible and only stripped out when taking the final step of transforming out 
> data to the output format (here, HTML).  But I'm not sure if that's 
> possible/worth the effort.
> 
> This leads me to the question I started with: is there a better approach that 
> would preserve the semantic meaning in our generated X-expression (while 
> still yielding valid HTML)?

-- 
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] Newbie Question about Rendering from Author Mode

2019-05-17 Thread Matthew Butterick
Looks like you put an incorrect "pp" extension on those source files. The first 
one needs to be named "downtown.html.pmd" and the other "uptown.html.pm".


> On May 17, 2019, at 10:52 AM, Eugene Wallingford  wrote:
> 
>  I am new to Pollen and just working through the Quick Tour.  Everything 
> works as
>  expected until I get to the sections on Markdown mode and Pollen mode.  
> When I
>  render downtown.html.pmd, whether at the command line or with the 
> server, I see
>  a line of partially-processed plaintext:
> 
> Pollen + Markdown —— + You wanted Plutonium — you got it. + search for 
> Plutonium 
> 
>  When I render uptown.html.pp, I see a line of Racket-y plaintext:
> 
> '(h2 "Pollen markup") '(ul (li (p "You " (strong "wanted") " it — you " (em 
> "got") " it.")) "\n" (li (p (a ((href "https://google.com/search?q=racket 
> ")) "search for Racket"
> 
>  So Pollen is doing some processing of my files, but it doesn't seem to be
>  taking the final step.  Can someone point out what I'm missing?  Thanks.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pollenpub/5D37674A-1F5D-4D41-AD88-17A37AF382CF%40mbtype.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Citation system update

2019-05-27 Thread Matthew Butterick
Looks cool! You should turn this into an installable Racket package with docs & 
tests, perhaps? I'm sure others would benefit from your suffering.

> On May 27, 2019, at 12:06 PM, sanc...@gmail.com wrote:
> 
> Joel and I each shared our approaches to footnotes a while back 
> (https://groups.google.com/d/msg/pollenpub/laWL4SWx0Zc/bNGZyKpABQAJ)
> 
> I now have a more complete citation system running in my Pollen setup:
> https://sanchom.github.io/automating-citations.html
> https://github.com/sanchom/sanchom.github.io/blob/master-source/pollen.rkt
> https://github.com/sanchom/sanchom.github.io/blob/master-source/citation-system.rkt

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pollenpub/028C4397-0211-436A-B1C3-FCC99D85517F%40mbtype.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] A few questions about pollen capabilities

2019-05-27 Thread Matthew Butterick



> On May 27, 2019, at 3:20 PM, Joel McCracken  wrote:
> 
>  I suppose I might be able to do that, but I don't think it will solve my 
> overall problem. `pollen.rkt` gets loaded/computed repeatedly, once per page, 
> so it would lose context between pages. I would then have to re-compute it, 
> and/or read/write it to disk, which is what I am doing right now, which I 
> would like to avoid if possible.

I'm still not clear why you need to introduce global state. Didn't you say the 
alias names are embedded in the source files as `meta` values? So why not just 
have "pollen.rkt" generate the alias table every time it runs? (You can read 
the `metas` of a Pollen source without rendering the file, or even the `doc`, 
for that matter.)


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pollenpub/57E3126B-962E-491C-ADE5-FDF95501EACA%40mbtype.com.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] A few questions about pollen capabilities

2019-05-27 Thread Matthew Butterick


> On May 27, 2019, at 5:24 PM, Joel McCracken  wrote:
> 
> The point is I was hoping to avoid having to rebuild the entire links table 
> every time I process another file.


Here's a perhaps simpler way to do it that you could customize further.

The Pollen sources define metas for each target that they want to host (you 
would sprinkle these through the file to taste).

In "pollen.rkt", `generate-link-dests!` makes a table associating paths and 
targets. `resolve-alias` calculates a URL using this table. If there are 
duplicate targets, or no targets, it throws an error.

If this approach is too slow, you could have `generate-link-dests!` write its 
table to a ".rktd" file (with `write-to-file`) and then `resolve-alias` could 
load it in with `file->value`. In your render script, you would trigger 
`generate-link-dests!` once before the render to freshen the index.

The trick here is that `metas` is made available directly from a Pollen source, 
but also through a submodule called `metas`. You can read the `metas` without 
triggering an evaluation of the rest of the file (which in turn would trigger 
"pollen.rkt", so you'd have a circularity problem).
 

;;; foo.html.pm
#lang pollen

◊(define-meta one #t)
◊(define-meta two #t)
◊(define-meta three #t)

◊link['four]{link to bar}


;;; bar.html.pm
#lang pollen

◊(define-meta three #t)
◊(define-meta four #t)
◊(define-meta five #t)

◊link['one]{link to foo}


;;; pollen.rkt

#lang racket
(require racket/path sugar/coerce pollen/core pollen/file)
(provide link)

(define (generate-link-dests!)
  (define link-table (make-hash))
  (for ([f (in-directory)]
#:when (path-has-extension? f #"pm")
[(k _) (in-hash (dynamic-require `(submod ,(path->string f) metas) 
'metas))]
#:unless (eq? k 'here-path))
(define key (->symbol (path-replace-extension (->output-path 
(find-relative-path (current-directory) f)) #"")))
(hash-update! link-table key (λ (val) (cons k val)) null))
  link-table)

(define (resolve-alias alias)
  (define link-table (generate-link-dests!))
  (match (for*/list ([k (in-hash-keys link-table)]
 [v (in-list (hash-ref link-table k))]
 #:when (eq? alias v))
   (cons k v))
[(list (cons k v)) (format "~a.html#~a" k v)]
[(list) (error 'alias-not-found)]
[_ (error 'alias-ambiguous)]))

(define (link name . xs)
  `(a ((href ,(resolve-alias name))) ,@xs))

(module+ test
  (require rackunit)
  (check-equal? (resolve-alias 'one) "foo.html#one")
  (check-equal? (resolve-alias 'five) "bar.html#five")
  (check-exn exn:fail? (λ () (resolve-alias 'three)))
  (check-exn exn:fail? (λ () (resolve-alias 'nowhere


-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pollenpub/5A3337F1-C98E-409F-AE55-C4CB1D9061B1%40mbtype.com.
For more options, visit https://groups.google.com/d/optout.


[pollen] better meta values?

2019-05-29 Thread Matthew Butterick
tl;dr

1) Would it be useful to allow meta values to be expressions, not merely datums?
2) Is anyone using identifiers or lists as meta values? Mostly my impression is 
that they're usually strings, numbers, or booleans (whose meaning wouldn't 
change with this upgrade).



I was thinking that it would be easy to make meta values expressions rather 
than datums, so that something like this:

◊(define-meta foo (* 6 7))

Means that the `foo` meta is 42. 

You could, in theory, run anything you wanted there:

◊(define meta bar (let () (local-require every/module) (do-a-zillion-things))

This isn't quite backward-compatible. Datums that are self-quoting, like 
strings, numbers, and booleans, are the same under either system.

But things that look like evaluatable expressions — especially naked 
identifiers and lists — would be different.

◊(define-meta id bar)

Today, this results in a meta value of `'bar`. But if meta values are treated 
as expressions, it would just be `bar`, and trigger an unbound-identifier error.

Or again consider:

◊(define-meta foo (* 6 7))

Today, this results in a value of `'(* 6 7)`, but it would not under the new 
system.

I can't really tell, however, whether the theoretical benefits outweigh the 
theoretical costs.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pollenpub/F1382F41-83DC-4864-8DEA-2D919DA7976F%40mbtype.com.
For more options, visit https://groups.google.com/d/optout.


[pollen] Re: parallel rendering fixes

2019-06-13 Thread Matthew Butterick
I'm afraid the parallel-processing problem is going to require more scrutiny 
about how it can be done safely. For the time being I've disabled parallel 
processing (you can still ask for `raco pollen render -p`, but it won't be 
parallel).


> On Jun 13, 2019, at 7:33 PM, Matthew Butterick  wrote:
> 
> Eh, don't bother. I just found another bug in it.
> 
>> On Jun 13, 2019, at 6:22 PM, Matthew Butterick  wrote:
>> 
>> I recommend that anyone who enjoys `raco pollen render -p` update to the 
>> newest Pollen. In the last week I've discovered (and hopefully corrected) a 
>> couple bugs that were causing it to silently ignore files during a parallel 
>> render.
>> 
>> 
> 

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pollenpub/2E3701BA-B6E8-4781-AD6C-5DDEC962D559%40mbtype.com.
For more options, visit https://groups.google.com/d/optout.


  1   2   >