You might want to try this pollen.rkt

#lang racket

(provide (all-defined-out))

(define scuttlebutts
  (hash
   "Gillis" "@a;lksjd2j3j1k2j.sha256f"
   "Brenda" "@s8/sj31l13j2k32.sha256"))

(define (author name)
  `(details (summary ,name) (p ,(hash-ref scuttlebutts name))))

And here’s the output:

'(root
  (title "A Cool Essay")
  "\n"
  (details (summary "Brenda") (p "@s8/sj31l13j2k32.sha256"))
  "\n"
  "\n"
  "this is the essay and all the paragraphs and all that....")

Notice the following changes:

   1. I convert keys of scuttlebutts to strings so that I do not need to
   convert name in the author function to symbol.
   2. Since name will always be one string in your use case, you don’t need
   to use the rest argument.
   3. You want to compute (hash-ref scuttlebutts name), so it’s needed to
   be unquoted with ,.

To perfectly get the output that you indicate above, you also need to
define the root function that decodes paragraphs. You also need to define
the title function which creates the h1 tag.

On Thu, Mar 28, 2019 at 12:42 AM Zach Mandeville <[email protected]>
wrote:

> Hello!
>
> Thank you v. much for dreaming up and creating pollen (and thanks to all
> y'all making cool things with it!).  I discovered it through an article
> about medium, from practical typography, that was shared with me.  Pollen
> represents exactly what I want for a web publishing tool.  Especially the
> notion of creating your own tags, that can then be rendered however you'd
> like in html (or other forms).  That's philosophically just so good to me!
>
> The dilemma I have now, though, is that I started to write in pollen
> first, defining tags as I went along, and then found out I didn't quite get
> how to turn them into the html elements I want.  Worse, I enjoy writing in
> the pollen style so much  that I can't go back.  So I have an html.pm
> that I can't quite figure out how to turn into the .html i'm envisioning,
> and hoping someone here might be able to help?
>
> What I'd like is to have a list of essays by different authors, and each
> author has an id attached to them (it's authors from Scuttlebutt
> <https://scuttlebutt.nz>, and so each person has a public key ID
> associated with them).  the ID is long and strange, and so I don't wanna
> have to enter it each time.
>
> So for an essay, I'd have:
>
> ◊title{A Cool Essay}
> ◊author{Brenda}
>
>
> this is the essay and all the paragraphs and all that....
>
> And I'd want this html:
>
> <h1>A Cool Essay</h1>
> <details>
>   <summary>Brenda</summary>
>   <p>@s8/sj31l13j2k32.sha256</p>
> </details>
> <p>this is the essay and all the paragraphs and all that....</p>
>
> In my pollen.rkt I created a meta hash that had each author's name and
> their ID:
>
> (define scuttlebutts
>   (hash
>    'Gillis "@a;lksjd2j3j1k2j.sha256f"
>    'Brenda "@s8/sj31l13j2k32.sha256"))
>
> And below this I wanted a function to turn ◊author into that details
> element by referencing ◊author text against that 'scuttlebutts' meta...but,
> I can't  get it to work.  The closest I got is this:
>
> (define (author . elements)
>   `(details (summary ,@elements)(p `(select-from-metas elements
> scuttlebutts))))
>
>
> Essentially, I can't figure out how to have the value of the for the p
> x-expression to be the result of the select-from-metas expression.  I know
> it's likely something to do with quoting or some such, but I don't have
> enough racket knowledge (yet) to quite make sense of it.
>
> So my question is: what would be the best way to accomplish this?  Is
> there a correction to my function I'm missing, or would y'all recommend
> going about this in a wholly different way?
>
> Thank you!  And thank you again for this wonderfully strange language!
>
>
>
>
> --
> 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.
>

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