Re: [pollen] Markup/Tags in Metas

2016-06-28 Thread Matthew Butterick

On Jun 27, 2016, at 10:19 PM, Chris Forster  wrote:

> Is it possible to include Pollen markup in the metas metadata hash?
>  
> Am I missing something? Is it possible to use markup/function in metas? Is 
> there a different approach to metadata I should be exploring?

Yes (although I agree the error message could be more helpful). A meta value 
can be any single X-expression. The problem with

Conclusion to ◊em{Studies in the History of the Renaissance}

Is that it's a sequence of two X-expressions: the string "Conclusion to" 
followed by the sub-expression '(em "Studies in the History of the 
Renaissance").

The solution is to wrap it all in a single tag so it becomes one X-expression. 
You can create a new tag, or just use the splice tag, for instance:


#lang pollen/markup
◊(define-meta title ◊@{Conclusion to ◊em{Studies in the History of the 
Renaissance}})

Now you have ◊(select-from-metas 'title metas)


Result:

'(root "Now you have " "Conclusion to " (em "Studies in the History of the 
Renaissance") "\n")

-- 
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-19 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 v6.4/collects/file/cache.rkt:63:2: fetch-and-conti

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 20, 2016, at 8:37 AM, Joel Dueck  wrote:
> 
> This is a big help for my understanding of macros, thanks. I felt that eval 
> was a bit of a hack, but I had not understood that with-syntax could use 
> `...` to produce repeating patterns that aren't tied to the syntax pattern 
> passed in by `syntax-parse`. I guess I might have been able to infer this 
> from Hendershott's explanation that `with-syntax` can be considered as simply 
> a rearranged `syntax-case`.

`syntax-case`, `with-syntax`, and `syntax-parse` all rely on syntax patterns 
[1] to destructure syntax objects (though `syntax-parse` supports some extra 
options that the others do not [2]).

You can think of syntax patterns as a mini-language for parsing syntax, similar 
to how regular expressions are a mini-language for parsing strings. And, like 
regexps, you often have more than one option for how you break down a syntax 
object.

In the case of a list-shaped syntax object like `(foo bar baz)` you can:

+ match the whole thing with a single-term pattern like `THE-WHOLE-LIST` 
+ match each element with a list pattern like `(FIRST-ELEMENT SECOND-ELEMENT 
THIRD-ELEMENT)`
+ match each element with an ellipsis pattern like `(LIST-ELEMENT ...)` or 
`(FIRST-ELEMENT LIST-ELEMENT ...)`
+ match the head and tail of the list with a dot pattern like `(FIRST-ELEMENT . 
OTHER-ELEMENTS)`

Getting the hang of the ellipsis is the most important skill, I think, because 
it's a very clever operator that lets you write tight syntax templates.

[1] http://docs.racket-lang.org/reference/stx-patterns.html?q=syntax%20pattern
[2] http://docs.racket-lang.org/syntax/stxparse-patterns.html?q=syntax%20pattern



> I'm still curious as to why one can't `eval` a symbol matching the name of a 
> function in a Pollen file though, even when that function is defined in the 
> same file. I will probably never absolutely need to use it that way, but it 
> runs counter to my understanding of Pollen files as full-fledged Racket 
> programs

When you use `eval` in a program (as opposed to in the REPL, which allows more 
casual `eval`ing), you have to specify a namespace for resolving identifiers. 
That's why this code will fail with a "bold: unbound identifier" error:

#lang racket
(require rackunit)
(define (bold . xs) "this is bold")
(check-equal? ((eval 'bold) "hi") "this is bold")

If you just want to use the surrounding namespace, you can use a namespace 
anchor to capture the namespace and pass it to `eval`. That's why this code 
works:

#lang racket
(require rackunit)
(define (bold . xs) "this is bold")
(define-namespace-anchor nsa)
(check-equal? ((eval 'bold (namespace-anchor->namespace nsa)) "hi") "this is 
bold")


Though in general, when you find yourself using `eval` it's a sign that you're 
taking an unnecessary detour.

-- 
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] Emacs pollen-mode company backend available

2016-07-20 Thread Matthew Butterick
Thanks! I still don't use Emacs, but I appreciate your work on this ;)


On Jul 19, 2016, at 9:32 PM, Li Junsong  wrote:

> Hello,
> 
> Emacs pollen-mode supports company-mode now. You'll get tag function 
> completion in your pollen file. See https://github.com/lijunsong/pollen-mode
> 
> 
> 
> 
> I'll have a few bug fixes before making this pollen-mode into the package 
> repository. Any comments and suggestions (and bug reports!) are very welcome!

-- 
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] Nesting within txexpr

2016-08-01 Thread Matthew Butterick

On Aug 1, 2016, at 10:57 AM, Chris Forster  wrote:
> I have written the following Pollen code to create such links:
> 
> (txexpr 'a `((href ,(string-append "#fn" (number->string footnote-number
>  `(sup ,(number->string footnote-number)))
> 
> 
> Everything is correct here except the sup produces not , but ⊃.
> 


The third argument to the `txexpr` function is a list of txexpr elements, which 
are attached as the tail of the txexpr. The problem here is that your third 
argument:

> `(sup ,(number->string footnote-number))

Produces

'(sup 42)

Which the `txexpr` function understands to be a list of two txexpr elements (= 
a symbol followed by a number). But you want it to behave as a single txexpr. 
So you need to wrap it in another list like so:

#lang racket
(require txexpr)
(define footnote-number 42)
(txexpr 'a `((href ,(string-append "#fn" (number->string footnote-number
 (list `(sup ,(number->string footnote-number


If you find this annoying to keep track of, you can just make the txexpr as one 
quasiquoted expression:

#lang racket
(require txexpr)
(define footnote-number 42)
`(a ((href ,(string-append "#fn" (number->string footnote-number (sup 
,(number->string footnote-number)))


FWIW this ambiguity is unavoidable — I touch on it in the docs for `decode` [1].

That said, I don't think it would hurt to add a `txexpr*` function that allows 
you to avoid the list-wrapping fandango (similar to how `list*` behaves 
compared to `list`)


[1] 
http://docs.racket-lang.org/pollen/Decode.html#%28def._%28%28lib._pollen%2Fdecode..rkt%29._decode%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] Nesting within txexpr

2016-08-01 Thread Matthew Butterick
On Aug 1, 2016, at 12:43 PM, Chris Forster  wrote:
> 
> (txexpr 'div '((id "top")) '("Hello" (p "World"))) 
> 
> I'm not sure I understand why the nested paragraph wouldn't also be a 
> txexper--would there ever be a situation where the following would make sense?
> 
> (txexpr 'div '((id "top")) '("Hello" (txexpr 'p empty "World")))
> 

True, the second expression will test as a `txexpr?`, but notice that it's not 
giving the result you expect:

'(div ((id "top")) "Hello" (txexpr 'p empty "World")) ; wrong!

Because '("Hello" (txexpr 'p empty "World")) is prefixed with a quote, 
everything inside gets quoted, including the `txexpr`. Instead, you could do 
this:

(txexpr 'div '((id "top")) `("Hello" ,(txexpr 'p empty '("World"

Now, this expression will have the same result as:

(txexpr 'div '((id "top")) '("Hello" (p "World"))) 


> 
> Likewise, if I follow, does that mean that there is no situation where a 
> txexper can't be replaced by a quasiquoted expression?

Right. A txexpr is just a Racket list, with some special conditions about what 
values can appear where. In general, you can use any of Racket's list-making / 
list-breaking functions to make a txexpr. Quasiquoting is just a way of making 
a list. The advantage of the `txexpr` function itself is that it will check 
your arguments to make sure they will result in a valid txexpr. Sometimes 
that's helpful. Sometimes not.

In the `pollen-tfl` docs I show some examples of how different Racket functions 
can make valid txexprs:

http://docs.racket-lang.org/pollen-tfl/_pollen_rkt_.html#%28part._.Making_tagged_.X-expressions__txexprs_%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] Output into Subdirectories based on Format

2016-08-08 Thread Matthew Butterick
On Aug 8, 2016, at 8:40 AM, Chris Forster  wrote:

> Is it (easily) feasible to put all files from a particular output target in a 
> subdirectory of the project root? This would clean up the project root, but 
> also help for some other purposes; for instance, I'm trying to use Pollen to 
> create partial LaTeX files, stow them in a subdirectory, and then recombine 
> them on demand (for, essentially, customized anthologies). It would be nice 
> to put all my latex partials in a single subdirectory so that other code 
> could reach in their and compile them (based on user selection, say, from the 
> web).
> 
> I could accomplish this manually (I think), by doing raco pollen publish; 
> then, in the published directory making a bunch of subdirectories and moving 
> by file extension; but is there a way to do within Pollen?  




In general, it's not that I'm numb to the (occasional) pleas for better 
file-management options. I have two reservations. 

First, I haven't personally come across a need for it. So I would rather 
someone describe in detail how this new part of the system ought to work, 
rather than guessing (probably incorrectly). (Thank you for doing so here: I 
can visualize what you're trying to do & why)

Second, anything that touches the file system is inherently more complicated. I 
don't want Pollen to duplicate (probably incorrectly) that which other tools do 
well. 

For instance, `raco pollen publish` makes sense as a Pollen operation because 
it requires rules about what is & isn't a publishable file in the Pollen 
universe. Whereas just copying / moving files into different directories ... 
seems like a job better suited to `make` or a shell script? (That is a 
non-rhetorical question. I don't know if that would suit your needs.)

PS Of course, you could accomplish your goal "by hand" in the sense that you 
could have Pollen source files in your subdirectory that generate the LaTeX 
partials, but all they do is reach up into the parent directory to `require` 
their `doc` and `metas` from the right ".poly" 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] Markup/Tags in Metas

2016-08-08 Thread Matthew Butterick

On Aug 8, 2016, at 1:58 PM, Chris Forster  wrote:

> You may note that in both these cases, I've removed the splice (@); that's 
> because when I include it, we have this situation.


I believe I suggested the `◊(define-meta title ◊@{Markup in ◊em{MetaData}})` 
idea to you. But I see that it doesn't quite work. The splice mark should never 
show up. I consider this wrong:

> 
> <@>Markup in MetaData
> @Markup in emMetaData

So I'll look into that.


In the meantime, your (perhaps accidental) discovery of `◊(define-meta title 
◊{Markup in ◊em{MetaData}})` looks like the better idea anyhow, at least for 
metas. When you use `◊{ ... }` without a function name, then it just produces a 
list.

To convert that list to vanilla text that LaTeX can use, you can try something 
like:

◊(local-require racket/string racket/list)
◊(apply string-append (filter string? (flatten (hash-ref metas 'title))

This will take the X-expression-ish list inside `(hash-ref metas 'title)`, 
flatten it (thereby losing all the internal nesting, take out everything but 
the strings, and then push them together. (Depending on what's in that meta 
field, more elaborate filtering might be required, but that's the general idea.)

-- 
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] Markup/Tags in Metas

2016-08-09 Thread Matthew Butterick
On Aug 8, 2016, at 3:35 PM, Matthew Butterick  wrote:

> The splice mark should never show up. I consider this wrong:
> 
>> 
>> <@>Markup in MetaData

> So I'll look into that.


I have now looked into that.

I adjusted the `->html` function so that it will handle splice tags correctly.

So if your source file says this:

> #lang pollen/markup
> ◊(define-meta title ◊@{Markup in ◊em{MetaData}})


And your template says this:

> ◊(->html (hash-ref metas 'title))



The splicing should now work correctly.


This is an edge-case problem. It only seems to surface when you store a splice 
tag in a meta, and then pull it out within a template, because doing that 
circumvents the usual processing of splice tags that happens when a Pollen 
source file runs. 

Anyhow, try out the patch and see if it helps.

-- 
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 is Sun Sept 18 in St Louis

2016-08-09 Thread Matthew Butterick
You are invited: http://con.racket-lang.org 

Once again, I am a sponsor of RacketCon and its web-designer-in-chief.

Additionally, I will be talking about the "Beautiful Racket" book project.


-- 
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 here-path to Produce an Output Filename

2016-08-15 Thread Matthew Butterick

On Aug 15, 2016, at 4:22 PM, Chris Forster  wrote:

> here-path seems to be a string (rather than a path object), hence the 
> string->path call. It seems as though last isn't evaluating... and so 
> string->path is getting the whole list... but why?


You're right about the problem. `last` is in `racket/list`, which is not part 
of the default Pollen imports, which are derived from `#lang racket/base` 
(which has fewer default imports than `#lang racket`). It should suffice to add 
`racket/list` somewhere in your `local-require`:

◊(local-require racket/file racket/system racket/string racket/list)

BTW because Pollen treats any unbound identifier as a tag, this is an 
unavoidable yet also annoying error. You can override this behavior for any 
identifier by wrapping it with `def/c`, which will force it to behave as a 
bound identifier (or throw an error).


-- 
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] Implementing unordered lists in plaintext output

2016-08-16 Thread Matthew Butterick
1. You might want to see if the `pollen-count` package suits your needs: 
https://github.com/malcolmstill/pollen-count

2. 
>>  After some playing around, it seems that when list items are processed 
>> (when the li function is called), the code for the ordered list in the case 
>> statement isn't getting run; in li  list-type still has its initial value.

Right -- because your code depends on the `ol` function running before the `li` 
functions inside. But that's not how the page is actually evaluated, so you're 
not getting the right result. Tag functions (and other ordinary functions) are 
evaluated from the bottom up. (IIRC this is, indeed, the opposite of XSLT, 
which goes from the top down.)


3. The easiest option is probably just shifting the list-item processing into 
the `ol` function itself. This is usually what I do (there's a sample in the 
`pollen-tfl` code, showing how the surrounding list tag decodes the items 
inside). Once you have the list items gathered into a (Racket) list, you can 
loop through them (either using `set!` to keep a counter, or `in-indexed` is 
also good for this), for instance:

#lang racket/base
(define list-items '("foo" "bar" "baz"))
`(ol ,@(for/list ([(item idx) (in-indexed list-items)])
 `(li ,(format "~a." (add1 idx)) ,item)))

> '(ol (li "1." "foo") (li "2." "bar") (li "3." "baz"))



-- 
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] Implementing unordered lists in plaintext output

2016-08-16 Thread Matthew Butterick

On Aug 16, 2016, at 11:00 PM, Matthew Butterick  wrote:

> there's a sample in the `pollen-tfl` code, showing how the surrounding list 
> tag decodes the items inside


Meant to include a link:

http://docs.racket-lang.org/pollen-tfl/_pollen_rkt_.html#%28def._%28%28lib._pollen-tfl%2Fpollen..rkt%29._detect-list-items%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] Implementing unordered lists in plaintext output

2016-08-17 Thread Matthew Butterick
On Aug 17, 2016, at 1:25 PM, Chris Forster  wrote:
> I see your point Junsong; this is just a list (it's a LIST! for heaven's 
> sake) and so can be handled like a list (i.e. without any global variable to 
> track mutation). In part I led astray I think by modeling my solution to this 
> problem on how I've handled footnotes in plaintext (i.e. put in a numbered 
> footnote marker, and collect note text in a global list, that can be appended 
> to the end of the document);

True, mutation of state variables is not a core Racket / functional-programming 
idiom. But if you were to look through the Racket source code you'd find plenty 
of instances where `set!` is used in this way. So if it's the best tool for the 
job, use it. 

In practice, there are a lot of Racket functions that approximate the benefits 
of mutation without the drawbacks, for instance:

+ for/fold
+ parameters
+ generators

These often end up being simpler to think about than the `set!` approach.


> footnotes, unless I'm still misunderstanding something, are most easily 
> handled through mutation--because, unlike items in a list, they have no 
> single container (i.e. they could occur anywhere in a document). I think 
> that's right... (the irony of being confused by how to handle lists in a LISP 
> is not lost on me.)

If you're talking about continuously numbered footnotes, that's right -- the 
challenge is that the context for numbering is the whole project, whereas 
Pollen source files are ordinarily rendered one by one. 

(This is a limitation of Pollen's non-monolithic approach to structuring a 
project. To be fair, sequential footnote numbering is a relic of the 
letterpress age and makes no sense in the digital age, though academics seem in 
no hurry to let it go ;)

Putting a footnote counter in "pollen.rkt" won't actually work, because that 
file gets run separately every time a source file is rendered, so it won't 
"remember" the footnote count between renders.

The Rackety way to do this is to define a parameter, which is essentially a 
well-behaved global variable. What you do is:

1) Set up a new source file with the parameter.

2) `require` this file into your "pollen.rkt". The parameter is a function, and 
you retrieve its current value by invoking it as a function, or set its value 
by passing it an argument.

3) Then set up a render script that uses `parameterize` to set the initial 
value of the parameter, and preserves the state of the value between each page.


Here's a short example showing how multiple submodules can share state through 
a parameter. It works the same way if you turn the submodules into independent 
source files.



#lang racket/base

(module params racket/base
  (provide (all-defined-out)) 
  (define footnote-number (make-parameter "this value is overridden")))

(module pollen-rkt racket/base
  (require (submod ".." params))
  (provide (all-defined-out)) 
  (define (do-note which)
(displayln (format "~a has note ~a" which (footnote-number)))
(footnote-number (add1 (footnote-number)

(module foo racket/base
  (require (submod ".." params) (submod ".." pollen-rkt))
  (provide (all-defined-out))
  (define (do-foo-notes)
(do-note 'foo)
(do-note 'foo)
(do-note 'foo)))

(module bar racket/base
  (require (submod ".." params) (submod ".." pollen-rkt))
  (provide (all-defined-out))
  (define (do-bar-notes)
(do-note 'bar)
(do-note 'bar)))

(module zam racket/base
  (require (submod ".." params) (submod ".." pollen-rkt))
  (provide (all-defined-out))
  (define (do-zam-notes)
(do-note 'zam)
(do-note 'zam)
(do-note 'zam)
(do-note 'zam)
(do-note 'zam)))

(module main racket/base
  (require (submod ".." params) (submod ".." foo)
   (submod ".." bar) (submod ".." zam))
  (parameterize ([footnote-number 1])
(do-foo-notes)
(do-bar-notes)
(do-zam-notes)))


-- 
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] 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] Deploying pollen server live

2016-08-19 Thread Matthew Butterick

On Aug 19, 2016, at 12:35 PM, Ifeoluwapo Eleyinafe  wrote:

> Hey.  Thanks so much.  I was looking into trying to use Racket as the 
> webserver and pollen as the preprocessor but this will not work as I am not 
> yet smart enough.  But pollen to php, html, css and on and on incorporates 
> nicely with my current CMS.  Thanks much for all your work on this awesome 
> program.

FWIW, I've never used the Racket web server on any live deployments of Pollen 
projects. I just use the basic Apache server that my web-hosting service 
(Dreamhost) offers. 

But what you're proposing — using Pollen to automate the files that are fed to 
your CMS — will also work.

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


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

2016-10-20 Thread Matthew Butterick

On Oct 20, 2016, at 11:50 AM, lfacc...@jhu.edu wrote:

> The existence of a current-output-type function, available to pollen.rkt. It 
> would return the same things that current-poly-target returns, but would 
> always be in correspondence with the output type in question, regardless of 
> the source file being (for example) .html.pm or .poly.pm.
> When using a source file with an extension other than .poly.pm, the 
> current-poly-target parameter is set to the default, which isn’t very 
> helpful. So, in that case, current-poly-target could change to do what I 
> described in the point above. Granted, current-poly-target is not as aptly 
> named to that purpose as current-output-type, but it might fit better with 
> the existing system and documentation.

`current-poly-target` is meant to fill in a detail that cannot be inferred from 
the source file name. 

How is your proposed `current-output-type` parameter different from an 
expression like this? (in pseudocode):

(if source-file-has-poly-ext
   (current-poly-target)
   (get-source-file-ext))


> The existence of a metas variable, available to pollen.rkt. With it, I could 
> create current-output-type, as you showed in your answer.


I don't see how this would be better than just passing `metas` to functions in 
"pollen.rkt" when needed. In general, I'm wary of adding magic communication to 
the supported interface when standard Racket idiom will suffice. (Though I 
would not talk anyone out of structuring a project that way.)

The advantage of a macro in a case like this is that it's a little bit hacky, 
but the hackiness is contained. 



-- 
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] Collecting a wish list for a pollen editor

2016-10-20 Thread Matthew Butterick
Interesting. How would you implement these? As extensions to DrRacket?


On Oct 20, 2016, at 9:44 AM, Li Junsong  wrote:
> 
> I am collecting a wish list for a pollen editor.
> 
> I always wish my editor could tell me whether a tag is defined and exported. 
> The only way to know this now seems to look at the generated HTML tags.
> 
> A real-time preview could be useful too.
> 
> It would be useful to know which tag is from which configuration racket file, 
> especially when I have multiple directories defining their own configurations.
> 
> Any other ideas? 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.
For more options, visit https://groups.google.com/d/optout.


Re: [pollen] Splitting multiple-output tag functions with a Racket macro

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

Nice work Joel. Thanks for sharing 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] 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-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] Splitting multiple-output tag functions with a Racket macro

2016-11-14 Thread Matthew Butterick

On Nov 14, 2016, at 1:49 PM, Joel Dueck  wrote:
> 
> 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
> 
> I'm familiar with inheritance and overloading from OOP days, but didn't have 
> anything like that in mind!
> 
> Assuming you weren't joking, I think I'd say yes to "functions transparently 
> overriding other functions" but strike out "in some kind of inheritance 
> hierarchy". I haven't dug into Pollen's internals so I wouldn't presume to 
> know the best route to take, though.

Not joking, but also not claiming to have a full-fledged idea ;) Personally, I 
avoid classes because I find them exhausting. But maybe they would be a helpful 
way of getting the "fallback" behavior you describe.

FWIW when I was putting in the poly functionality some months ago, I thought a 
lot about how to organize the different sets of functions (because I figured 
that would be the most annoying part). 

For instance, I considered putting the per-target tag functions into 
specially-named submodules, like the `setup` submodule, or separate files. 

In the end, I went with the `current-poly-target` parameter because it felt 
like it made the fewest demands on the organization of a project. If you want 
all the poly functions for a certain tag to be in one function, you can do 
that. If you want them in submodules, or separate files, you can do that 
instead (and bring them back together with a macro). This way, everyone's "lazy 
subconscious assumptions" can be accommodated.

-- 
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
On Nov 14, 2016, at 5:30 PM, Matthew Butterick  wrote:

> Not joking, but also not claiming to have a full-fledged idea ;) 

Here's a rudimentary version of moving tag functions into classes:

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

In this example, all the tag functions would become class methods. The `tags%` 
class would define the default versions. The `pdf-tags%` and `text-tags%` 
inherit from this class, so they get all the default tag functions, but can 
define overrides as well.

The `current-tag-object` parameter would switch which class is being used, 
somehow tied to `current-poly-target`, I'm glossing over some details ...

Then the actual tag functions in "pollen.rkt" would merely be stubs that 
dispatch into the `current-tag-object`.

But I believe this produces the behavior you describe: selective override of 
certain tag functions, otherwise resorting to defaults.


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


[pollen] Relocating / renaming the "pollen-cache" directory

2016-11-21 Thread Matthew Butterick
Rather than maintaining a separate directory, Pollen will now put Pollen's 
cached files inside a "pollen" subdirectory of the "compiled" directory. Racket 
already uses this directory to store source caches, and it seems simpler to 
combine everything.

The benefit is that if you use source control, you only have to .gitignore the 
"compiled" subdirectories. 

I mention it so that no one is alarmed when "pollen-cache" directories are no 
longer sprouting everywhere. Other than the location, the actual caching is 
happening the same way as usual.

-- 
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] update: new `-l` or `--launch` flag for `raco pollen start`

2016-11-22 Thread Matthew Butterick
This flag will launch the project dashboard in your default web browser right 
after the server starts.

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

2016-12-24 Thread Matthew Butterick
> Right. That's why I have the exception to allow unbound id that starts with 
> "/" to become a tag (after stripping "/" out, of course) like what Pollen 
> would normally do.

At one point I considered having a magic character that would denote tags, 
somewhat like you suggest. But:

1) It breaks one of the golden rules of Pollen (= that every tag corresponds to 
a function with the same name)

2) Questionable ergonomics: when you want to change `/foo` to a defined 
function, are you supposed to search-and-replace all `/foo` with `foo`? That's 
a drag.

3) Identifier-sniffing schemes like this tend to have unintended problems (for 
instance, what happens to `/` the division function)



> But again, I'm not arguing that what I did is better. I just want to know if 
> there is any way to accomplish this without touching top.rkt

Why not make a new `#lang pollen/def` dialect that takes everything from `#lang 
pollen` except for `#%top`? 

-- 
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] Parsing Markdown in Pollen Markup

2017-01-07 Thread Matthew Butterick

> On Jan 7, 2017, at 1:39 PM, Oliver Taylor  wrote:
> 
> It doesn’t seem that Pollen parses Pollen markup when in markdown-authoring 
> mode. The following does’t work

Right. Pollen has two mutually exclusive authoring modes: Markdown, or Pollen 
markup.

http://docs.racket-lang.org/pollen/second-tutorial.html#%28part._.Authoring_mode%29
 




> 
> TEST.html.pmd
> 
> #lang pollen
> ◊(define (sc . words) `(span [[class "small-caps"]] ,@words))
> 
> ## Welcome to ◊sc{CIA}
> 
> - Introduction to ◊sc{CIA}
> - ◊sc{CIA} History


When you invoke Markdown authoring mode, Pollen expects Markdown as input, and 
compiles this to an X-expression. The problem here is that you're trying to 
embed X-expressions in Markdown first. This won't work. 

But you can use tag functions that emit Markdown:

#lang pollen
◊(require racket/string)
◊(define (sc . words) (string-append "**" (string-join words "") "**"))

## Welcome to ◊sc{CIA}

- Introduction to ◊sc{CIA}
- ◊sc{CIA} History


You might object: "But ** doesn't mean small caps in Markdown." True, but there 
are no small caps in Markdown. This is one of the reasons I dislike Markdown: 
it's not author-extensible.

http://docs.racket-lang.org/pollen/second-tutorial.html#%28part._the-case-against-markdown%29
 

 



> It occurs to me that I might be able to to create a ◊markdown tag to parse 
> markdown within or attach markdown decoding to Pollen’s root tag. 

You can use the `parse-markdown` function from the `markdown` package (included 
with Pollen) to decode Markdown from within a tag function:

#lang pollen
◊(require racket/string (only-in markdown parse-markdown) txexpr)
◊(define (markdown . words)
   (txexpr '@ null (parse-markdown (string-join words

◊markdown{## Welcome to CIA

 - Introduction to CIA
 - CIA History}




> Or maybe what I need is a way to tweak how decode-paragraphs works, and how 
> to easily generate lists in Pollen without typing all this out:
> 
> ◊ul{
> ◊li{Item One}
> ◊li{Item Two}
> ◊li{Item Three}
> }

Here's an example of a tag function that detects list items:

http://docs.racket-lang.org/pollen-tfl/_pollen_rkt_.html#%28def._%28%28lib._pollen-tfl%2Fpollen..rkt%29._detect-list-items%29%29
 



Here's another:

#lang pollen
◊(require pollen/decode txexpr)
◊(define (my-list . items)
   `(ul ,@(map (λ(item) `(li ,item))
   (filter (λ(x) (not (equal? "\n" x))) items

◊my-list{
 Item one
 Item two
 Item three
}



> 
> The reason I don’t like the decode-paragraphs implementation is that I write 
> using “Semantic Linefeeds”. Where newlines are ignored within paragraphs 
> (like Markdown, HTML, reStructuredText, etc.). Like this:
> 
>> Four score and seven years ago
>> our fathers brought forth on this continent,
>> a new nation, conceived in Liberty,
>> and dedicated to the proposition that
>> all men are created equal.
> 
> 


This is getting into somewhat fancier sauce, but you can use the 
#:linebreak-proc argument in `detect-paragraphs` to change how newlines are 
handled:


#lang pollen/markup
◊(require pollen/decode racket/string)

◊(define (replace-newlines-with-spaces xs)
   (list (string-join (filter (λ(x) (not (equal? "\n" x))) xs) " ")))

◊(define (root . xs)
   `(root
 ,@(decode-paragraphs xs #:linebreak-proc replace-newlines-with-spaces)))

Four score and seven years ago
our fathers brought forth on this continent,
a new nation, conceived in Liberty,
and dedicated to the proposition that
all men are created equal.


> Sadly, I have no idea how to do this. I’m not much of a programmer.

Study the `pollen-tfl` sample project:

http://docs.racket-lang.org/pollen-tfl/ 


For language concepts, read through some of the "explainers" on Beautiful 
Racket:

http://beautifulracket.com/#explainers 


-- 
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] Defined element incorrect behaviour

2017-02-05 Thread Matthew Butterick

> On Feb 5, 2017, at 11:05 AM, Greg Trzeciak  > wrote:
> 
> Am I missing something simple? Can you replicate it on your machines?

Yes, you're missing a binding for `empty?`, which is part of `#lang racket` but 
not `#lang pollen`. If you import `racket/list` (or use `null?` instead of 
`empty?`) then the function will work.

You're not seeing an error because Pollen handles undefined identifiers by 
making them into tag functions. Hence `(empty? tx-elements)` becomes '(empty? 
tx-elements) and always evaluates to true.

-- 
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: a server and an in-browser editor for Pollen

2017-03-02 Thread Matthew Butterick
This is fantastic. Thank you Junsong for figuring this out. I tried an earlier 
version but I look forward to trying the newest version.


> On Mar 2, 2017, at 1:17 AM, Junsong Li  wrote:
> 
> Hello list,
> 
> I am happy to announce the first release of pollen-rock, an in-browser editor 
> for Pollen.
> 
>  https://github.com/lijunsong/pollen-rock

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

2017-03-10 Thread Matthew Butterick
Joel's idea of using a "master file" to combine the chapter source files is 
good. 

Joel is using `dynamic-require`. Another mechanism would be making a submodule 
for each chapter with `module`:

(module ch1-submod racket/base
  (require "ch1.html.pm")
  (provide doc metas))
(require (prefix-in ch1: 'ch1-submod))

By using `prefix-in` you can keep all the `doc` and `meta` values separate.

I would avoid combining source files with `cat`, as it dissolves the idea of 
self-contained source files. 


> On Mar 10, 2017, at 9:11 AM, Joel Dueck  wrote:
> 
> In my try-pollen repo, I have this exact use case. The approach I took was to 
> use a .pp file [1] to gather multiple .poly.pm files into a single .ltx 
> output file.
> 
> [1]: 
> https://github.com/otherjoel/try-pollen/blob/master/flatland/flatland-book.ltx.pp
> 
> On Friday, March 10, 2017 at 5:02:54 AM UTC-6, osub...@gmail.com wrote:
> Hello, everyone.
> 
> If there are way to combine multiple source pages to generate single output.
> 
> Say, we have chapter1.poly.pm , chapter2.poly.pm 
> 
> 
> The use case - HTML output (chapter1.html. chapter2.html) vs PDF output 
> (single output).
> 
> The simple solution that comes to mind - just combine the chapter source 
> files into single "book" file (with 'cat' ) 
> and use it as a source for PDF.  Technically, also will allow generation of 
> the single-HTML output from the "book".
> 
> -Oleg Subbotin.
> 
> 
> 
> -- 
> 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] 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] 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-16 Thread Matthew Butterick

> On Mar 16, 2017, at 3:05 AM, Paulo Matos  wrote:
> 
> Thanks, given my JS-fu being weak I might be better off starting with
> what you provide. :)


One Google search on the topic would yield a hundred more qualified teachers, 
including people who actually like JS, which I do not ;)


> Now, I wonder if using whalesong something like this could be integrated
> with pure-racket code. Have you ever thought about something along these
> lines?

I have not used Whalesong [1] (Racket-to-JS compiler) nor Urlang [2] (JS with 
more Racket-like syntax, IIUC). You could use them with Pollen, I suppose, just 
like you can use any other kind of JS with Pollen. But they do different 
things, and would not join together Voltron-style.


[1] https://github.com/soegaard/whalesong 

[2] https://github.com/soegaard/urlang 

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

2017-03-17 Thread Matthew Butterick

> Great job with Beautiful Racket 1.0, makes the top in hacker news. For
> those of us who like to hold a beautiful book, what would be the best
> way to go from Beautiful Racket as you created to Beautiful Racket in
> dead tree form and still preserve it's beautiful-ness?
> 
> I am unsure if the sources are available but in any case I assume you
> could, possibly, provide a PDF from which a hardbook could be printed?



Though I love printed books, and buy many, I have no plans to make BR into a 
printed book. And definitely not a PDF or ebook. [1]

If you're asking more broadly about how to go from Pollen to print, Joel Dueck 
is the expert on this. [2]

If the web is ever going to be taken seriously as a book-publishing platform, 
then there's no shortcut other than using it to publish books (and refusing 
these inferior alternatives). [3]

That's not just a political posture. Even more so than with Practical 
Typography, I really enjoyed the reading experience I could create on the web 
that just wouldn't be possible with print / PDF / ebook. Especially because 
Racket has such extensive online documentation — readers can detour into that, 
then return to BR and continue. This is the best representation of the idea.

Moreover, the point of the book is to spread the word about Racket. Right now, 
people on six continents are making their first Racket languages. I couldn't 
get that reach with a printed book.




[1] http://beautifulracket.com/why-you-should-pay.html 


[2] https://thelocalyarn.com/excursus/secretary/ 


[3] http://practicaltypography.com/why-theres-no-e-book-or-pdf.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] A mysterious issue…

2017-03-20 Thread Matthew Butterick
> On Mar 20, 2017, at 7:01 PM, Jon Sterling  wrote:

> ◊(define (infer concl . premises)
>   (string-append "\\frac{" (apply string-append (add-between premises
>   "\\quad ")) "}{" concl "}"))
> 
> Now, what I would expect is for ◊(infer "a" "b" "c") to reduce to
> "\frac{b\qquad c}{a}" or something like that. Instead, I get the
> following error:

> Somehow something is not being evaluated! How is that possible?
> 
> The really strange thing is that if I run this code in the Racket repl,
> it exhibits the correct behavior. Only within Pollen does it seem to do
> this mysterious thing. Any ideas?


`add-between` is part of the `racket/list` library, which is not in the base 
`#lang pollen` environment. So when you compile your Pollen source, 
`add-between` is undefined, and gets converted to a symbol rather than invoking 
the function you expect. [1]

To make your function work, you can import `racket/list` (which contains 
`add-between`):

◊(require racket/list)

Or you can move `infer` to an external "pollen.rkt" file. This is a wise 
practice partially because then you would've caught this error at compile time 
(and inevitable, since assumedly you're going to want to use `infer` elsewhere)


[1] This is a feature not a bug: http://docs.racket-lang.org/pollen/Top.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] Writing a book - Pollen and/or Ormode's Babel

2017-03-20 Thread Matthew Butterick

> On Mar 20, 2017, at 5:48 PM, Steve Graham  
> wrote:
> 
> I have started to write a book on programming using various languages to 
> illustrate different concepts.  My plan has been to use orgmode's babel to 
> produce the book because it enables you to actually execute code within a 
> document and see the output -- either in the document or in a file -- and to 
> publish the document.
> 
> I've also been reading about Pollen and have seen some videos of Matthew 
> discussing Racket and Pollen and Beautiful Racket.  Other than that I don't 
> know anything about Pollen.
> 
> Finally I would like to publish it in 3 formats:  Paperback, pdf and Kindle.
> 
> What are your thoughts about using orgmode versus Pollen for this project?


I've never used orgmode, so no comparative opinion there.

A Kindle is a fancy set of HTML pages, so that seems doable.

PDF is a precursor to paperback, so assuming you're satisfied with LaTeX 
output, that seems doable (again, I yield to Joel Dueck on these matters, who 
is on the cutting edge)

The evaluation part ... hmm. With Beautiful Racket I used pygments for all the 
syntax highlighting, which pipes code to a python process and gets a result. 
Similarly, you could make Pollen functions that send their input to an external 
process and then pop in the result. Don't know if the speed would be 
acceptable, but you could cache the results of these eval blocks, SMOP, etc.

Probably the best way to compare them is to put together a short sample and see 
which you prefer.

-- 
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] Setting "hash-ref" failure result; Error handling conditionals?

2017-03-22 Thread Matthew Butterick
Are you taking the square brackets in `[failure-result]` too literally? ;) They 
simply denote an optional argument. Racket reads `[]` as `()` which it 
interprets as an incomplete function expression.

The fallback value can be passed directly:

(hash-ref metas 'doc-publish-date "")
(hash-ref metas 'doc-publish-date #f)

Or wrapped in a lambda (if it's something costly that you'd prefer to defer 
until needed:

(hash-ref metas 'doc-publish-date (λ () (calculate-value)))

So this would work:

\date{◊(pubdate->english (hash-ref metas 'doc-publish-date ""))}

If you want the date to be suppressed unless it exists, you can do test that 
the key exists with `hash-has-key?`

But more compact to do this:

◊(define maybe-date (hash-ref metas 'doc-publish-date #f))

◊when/splice[maybe-date]{
 \date{◊(pubdate->english maybe-date)}}


> On Mar 21, 2017, at 10:20 PM, Paul Atlan  wrote:
> 
> Unfortunately all my efforts to set the failure-result have failed. I've 
> tried e.g. 
> \date{◊(pubdate->english (hash-ref metas 'doc-publish-date [] ))}
> in order to return an empty string, but racket chokes by telling me [] is not 
> a procedure.
> 
> And I can't find reference to something resembling if-error in the racket 
> documentation. 

-- 
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] Setting "hash-ref" failure result; Error handling conditionals?

2017-03-23 Thread Matthew Butterick
I'm afraid it's difficult to offer more precise advice without seeing more of 
the code that's causing trouble.


> On Mar 23, 2017, at 4:29 PM, Paul Atlan  wrote:
> 
> ... as shown by the fact that I'm still struggling: 
> * I've defined the "maybe-date" outside of the ◊(define latex-source 
> ◊string-append{} loop. So that works. 
> * however, 
> ◊when/splice[maybe-date]{
>  \date{◊(pubdate->english maybe-date)}}
> gives me:
> string-append: contract violation
>   expected: string?
>   given: '(@ "\\date{" "Saturday, February 20th, 2016" "}")
>   argument position: 74th
>   other arguments...:... [165 total] ...
> 
> I guess instead of a string I'm outputting "something" (a quote?) that's a 
> concatenation o strings ...
> I thought I could convert this into a simple string by using symbol->string 
> but no joy. 
> I'm pretty sure I'm missing something obvious about lists and strings here, 
> but I can't figure out what ...

-- 
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 source for TFL PDF samples

2017-04-20 Thread Matthew Butterick
Actually no, those PDFs were made with InDesign. (They existed before Pollen 
did.)


> On Apr 20, 2017, at 12:13 AM, roberto.me...@gmail.com wrote:
> 
> A question for Matthew:
> 
> I imagine the sample PDFs for TFL were themselves written in Pollen. If so, 
> is the Pollen source available anywhere? In particular, I would be interested 
> in the table-after 
> 
>  one.
> 
> Thank you for this beautiful piece of software.

-- 
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-23 Thread Matthew Butterick
I encourage you to post a new package and invite pull requests.

IMO little utility functions like these can be difficult to turn into 
worthwhile library functions, because they tend to be connected to particulars 
of the author's project design.

This is why, for instance, `pollen/unstable/typography` exists — those 
functions were good enough for me in my projects. But if they were going to be 
official library functions, they'd have to handle edge & corner cases better 
than they do. 

But, I make them available because for some people they may suffice, and others 
might use them to make better functions.

So, even if consensus doesn't necessarily emerge, I think it's useful to have 
more sample code available for inspection.


> On Apr 23, 2017, at 10:11 AM, Junsong Li  wrote:
> 
> I am wondering can we build a collection of functions for common use? 
> 
> I am sure we all want something similar when processing document, like 
> generating URL, checking broken URL, extract headlines (sections),  generates 
> notes on margins, etc. And I sometimes (or in most cases) just want to reuse 
> implementation from others instead of writing my own, especially in the 
> middle of writing :(
> 

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


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?

2017-05-05 Thread Matthew Butterick
> On May 5, 2017, at 6:48 PM, Shannon Severance  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
>  
> 
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] Restrictions on using a pagetree in pollen.rkt?

2017-05-12 Thread Matthew Butterick

> On May 12, 2017, at 11:07 AM, vincent...@gmail.com wrote:
> 
> That allows me to load index.html, but it contains parenlog/introduction.html 
> as well as parenlog/predicates_variables_and_unification.html. I'd prefer to 
> use siblings instead of next* and remove index.html, but for some reason 
> index.html isn't served when I do that. I don't get an error message - the 
> page just hangs in my browser. Are there special restrictions on what you can 
> do with a pagetree in pollen.rkt?

`siblings` returns a list that includes the current pagenode. So if ◊(toc) 
appears in "index.html.pm", then it tries to `select` from a list of pagenodes 
that includes "index.html.pm", which in turn tries to load "index.html.pm", 
which in turn calles ◊(toc), and lo, you have created an infinite loop.

You can either:

1) Remove "index.html" from the list of pagenodes returned by `siblings`.

2) Use `other-siblings`, which I just pushed.




-- 
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] Scribble-style codeblocks

2017-05-21 Thread Matthew Butterick

> On May 21, 2017, at 10:11 AM, Vincent Nys  wrote:
> 
> I'd like to display some Racket code in a Pollen book. In Beautiful Racket, 
> it looks like Racket code is produced by the Scribble HTML renderer, because 
> it links to the Racket docs all over the place.

No, I don't use the Scribble HTML renderer for anything. I use Pygments to 
apply the syntax coloring. (One advantage is that Pygments can color most 
languages; Scribble can only color Racket). Then with `decode`, I find the 
defined terms in each code block (using the tags Pygments leaves behind) and 
wrap each one in a link into the Scribble docs. This last step relies on some 
not-well-documented functions, but here's an example of how it all works (links 
to the source at the bottom): 

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.


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

2017-07-19 Thread Matthew Butterick
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  wrote:
> 
> Hi list,
> 
> I am glad to release pollen-rock 0.4.
> 
> 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.
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  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  > > 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] Books with code including curly braces

2017-07-28 Thread Matthew Butterick

> On Jul 28, 2017, at 12:38 PM, 'Leandro Facchinetti' via Pollen 
>  wrote:
> 
> 2. If they are not balanced, use ◊___|{}| instead of ◊___{}:


You can even keep going and insert other characters [1] between the bars and 
curly braces, e.g. —

#lang pollen

◊bars|{ {{ }|
◊barbangs|!{ {{ }!|
◊barbanghashpercents|!#%{ {{ }%#!|
◊barparens|({ {{ })|
◊barbangparens|!({ {{ })!|


[1] 
https://docs.racket-lang.org/scribble/reader.html#%28part._alt-body-syntax%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-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] 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-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] 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] 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] 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  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 
> 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  <mailto:m...@mbtype.com>> a écrit :
> 
>> On Sep 23, 2017, at 3:29 AM, Karim Chellaoui > <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.


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

2017-10-05 Thread Matthew Butterick
True, though I see it as possibly analogous to Pollen's relationship to HTML — 
when you're working with boilerplate structures (e.g.,  and ) you can 
let Pollen take care of them. 

But when you want to insert literal chunks of markup because of their 
specialness or complexity, you can do that too.

OTOH, you're right that finding a productive level of abstraction to aim for in 
the software is an open question (and one I don't feel qualified to answer).


> On Oct 5, 2017, at 12:48 PM, Shrutarshi Basu  wrote:
> 
> As a meta-point though, In my personal experience, X-as-a-LaTeX-front-end 
> breaks down really easily when trying to do something non-trivial.


> On Oct 5, 2017, at 1:10 PM, Leandro Facchinetti  wrote:
> 
> I suppose that, at best, Pollen could be a leaky abstraction—one would still 
> need to understand TeX and 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.


[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] 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-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  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 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"> 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 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/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.


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


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


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

2018-01-13 Thread Matthew Butterick

> On Jan 13, 2018, at 6:16 AM, Joel McCracken  wrote:
> 
> Nice! I was planning on doing something similar for my own blog/personal 
> site. Is the source available anywhere so I can examine some of your 
> techniques? I do not see it on you github. 


Because I had no idea what I was doing, the server-side code is pretty sloppy. 
So I'm not in a rush to post it. At least until it reflects better on Racket ;) 
If you want to know how certain things work I can describe the approach.




> Barring that, I would imagine having pollen be usable as a "library"/plugin 
> application for the racket web server would be another way to go. This would 
> be akin to the notions that I know Django and Rails both have (or had in the 
> past, I have stopped paying attention to each community).


Perhaps. My impression — dim, as I also steer clear of the web-dev world, lest 
my face melt off — was that server-side page generation had fallen out of vogue 
in favor of async HTTP requests. 

-- 
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 > 
> 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] 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
Correction: name of the setup value will be `cache-watchlist`, not 
`compile-cache-watchlist`

On Saturday, January 20, 2018 at 5:57:20 PM UTC-5, Matthew Butterick wrote:
>
> 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  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 22, 2018, at 4:38 PM, Joel Dueck  wrote:
> 
> We’re getting heavy snow all day today here in Minneapolis, so I took the day 
> off. I spent some of the down time writing up my approach for implementing 
> footnotes in an upcoming project: 
> https://thenotepad.org/posts/pollen-footnotes-approach.html

Thanks a lot for this Joel. I was drawn to your comment in the article:

"The output for footnotes (given my requirements) can’t very well be handled 
within individual tag functions; it demands a top-down approach."

I was curious why this was necessarily so. I tried refactoring your footnote 
mechanism into tag functions. (I left out the MD5 fingerprinting and the 
blank-footnote requirement.) Result below. It seems to work with your samples. 
Where does this approach break down?


;

#lang racket/base
(provide (all-defined-out))

(define (fn-id x) (string-append x "_fn"))
(define (fnref-id x) (string-append x "_fnref"))

(define fn-names null)
(define (fn name-in)
  (define name (format "~a" name-in))
  (set! fn-names (if (member name fn-names) fn-names (cons name fn-names)))
  `(sup (a ((href ,(string-append "#" (fnref-id name)))
(id ,(fn-id name)))
   ,(format "(~a)" (length fn-names)

(define fndefs (make-hash))
(define (fndef name . xs) (hash-set! fndefs (format "~a" name) xs))

(define (footnote-block)
  (define note-items
(for/list ([fn-name (in-list (reverse fn-names))])
  `(li ((id ,(fnref-id fn-name)))
   ,@(append
  (hash-ref fndefs fn-name)
  (list `(a ((href ,(string-append "#" (fn-id fn-name 
"↩"))
  `(section ((class "footnotes")) (ol ,@note-items)))

(define (root . elements)
  `(root ,@elements ,(footnote-block)))






-- 
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
Correction: `(length fn-names)` should be `(length (member name fn-names))` to 
handle the possibility of multiple references to the same footnote.

;;

#lang racket/base
(require racket/list)
(provide (all-defined-out))

(define (fn-id x) (string-append x "_fn"))
(define (fnref-id x) (string-append x "_fnref"))

(define fn-names null)
(define (fn name-in)
  (define name (format "~a" name-in))
  (set! fn-names (if (member name fn-names) fn-names (cons name fn-names)))
  `(sup (a ((href ,(string-append "#" (fnref-id name)))
(id ,(fn-id name)))
   ,(format "(~a)" (length (member name fn-names))

(define fndefs (make-hash))
(define (fndef name . xs) (hash-set! fndefs (format "~a" name) xs))

(define (footnote-block)
  (define note-items
(for/list ([fn-name (in-list (reverse fn-names))])
  `(li ((id ,(fnref-id fn-name)))
   ,@(append
  (hash-ref fndefs fn-name)
  (list `(a ((href ,(string-append "#" (fn-id fn-name 
"↩"))
  `(section ((class "footnotes")) (ol ,@note-items)))

(define (root . elements)
  `(root ,@elements ,(footnote-block)))


-- 
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 7:38 PM, Joel Dueck  wrote:
> 
> I found that, conveniently, the #:txexpr-proc will match the ◊fn tags in the 
> same order a left-to-right reader would encounter them in the text, 
> regardless of nesting. If I had given it more thought, I might have figured 
> out that Pollen does the same with the entire doc.

Right. Racket guarantees left-to-right evaluation (though I can't find the docs 
link for this right now). As you say, the way to think about it is to imagine 
how it looks as an X-expression, and the evaluation will go in the same order 
(pre-order depth-first traversal, I believe is the fancy term)


> (+ 1 (index-of (remove-duplicates (reverse fn-names)) name))

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)


I apologize if I exploded part of your blog post. Occasional unfortunate side 
effect of being a curious character. May we be united in the quest for 
knowledge ;)

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


Re: [pollen] Why is render-from-source-or-output-path function quicker than get-source and then render?

2018-02-09 Thread Matthew Butterick
> On Feb 9, 2018, at 10:55 AM, Junsong Li  wrote:
> I noticed pollen server is using a function called 
> render-from-source-or-output-path , which is defined here 
> https://github.com/mbutterick/pollen/blob/5f338b5ecf9bbca7d7a44ca0e721b22a6cf8210a/pollen/render.rkt#L71
> 
> And once I switch to this function, pollen-rock dashboard can load normally. 
> This function also loops over all source file types.
> 
> Has anyone noticed the performance difference of that two functions before?


`render-from-source-or-output-path` is just a wrapper function around 
`render-to-file-if-needed`, so I'm skeptical that performance is at issue. 

As its name implies, `render-from-source-or-output-path` is more lenient with 
input: it can take either a source or output path as its starting input (if it 
gets an output path, it derives the source path name). 

Whereas `render-to-file-if-needed` can only take a source path. 

So my theory is that you're passing arguments (output paths, I would suppose) 
that `render-from-source-or-output-path` can handle, but 
`render-to-file-if-needed` cannot (though I'm surprised that there are not 
explicit errors popping up.)

I assume I needed this housekeeping for the project server and it seemed too 
idiosyncratic for the public interface, but perhaps it's suitable for 
pollen-rock (because it is also a 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] 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] 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.


  1   2   3   >