Thanks Matthew and Joel, 
* yes, I took the brackets literally - oops
* I know I could just skip the date thing, but where's the teaching moment 
in that ....

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


On Thursday, March 23, 2017 at 3:25:23 AM UTC+1, Joel Dueck wrote:
>
> Matthew’s answer is great. I would just add that the main reason I made us 
> of dates in the metas was that I planned to have an RSS feed for chapters, 
> and things syndicated in a feed need to have a date stamp. But the feed is 
> also coded so as to omit anything that doesn’t have a 'doc-publish-date 
> in the metas.
>
> So if you won’t be publishing an RSS feed, and if your book doesn’t 
> particularly need dates on each chapter, you could just remove any 
> reference to the date in the templates.
>
> On Wednesday, March 22, 2017 at 12:20:29 AM UTC-5, Paul Atlan wrote:
>>
>> I'm slowly winding my way up the learning curve by adapting Joel Dueck's 
>> work to a personal web-book I want to write. 
>> I've hit a snag due to my limited understanding of racket, probably. 
>>
>>
>> The template.pdf.p files contains the following line to generate a nicely 
>> formatted LaTex date:
>> \date{◊(pubdate->english (hash-ref metas 'doc-publish-date))}
>>
>> *metas *is generated from meta values in the source files, with one of 
>> the keys being "doc-publish-date".
>>
>> *pubdate->English * is a helper function to format everything nicely. 
>>
>> This works perfectly if I don't forget the "doc-publish-date" key in the 
>> source files. If I do (or don't want to set it), the *hash-ref* fails 
>> and stops the rendering process. 
>>
>> The *hash-ref* documentation (hash-ref 
>> <http://docs.racket-lang.org/reference/hashtables.html?q=hash-ref%20#%28def._%28%28quote._~23~25kernel%29._hash-ref%29%29>)
>>  mentions 
>> that one can write: 
>>      
>> hash-ref hash key [failure-result]
>>
>> were *failure-result* is either a procedure or is a value and gets 
>> returned instead of the missing key-value. 
>>
>> I've been trying to use this in order to fail gracefully when 
>> *doc-publish-date 
>> *is missing:
>> * either by returnnig a blank value (so the LaTex output will be " 
>> \date() " 
>> * or, even better, by skipping the whole \date function if the *hash-ref* 
>> function fails.  
>>
>> 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. 
>>
>> Any pointers would be greatly appreciated!
>>
>> P. 
>>
>>
>>  
>>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to