Git Product home page Git Product logo

pollen-users's People

Contributors

mbutterick avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pollen-users's Issues

Newbie: `decode-paragraphs` breaks LaTeX paragraphs

Hi, everyone. This is my third day with Pollen. Perhaps I'm jumping the gun before learning to use Racket, but I fear hitting writer's block by the time I learn the language. I want to start using Pollen, though, and I fully intend to learn it.

Meanwhile, I want my book output in rudimentary HTML (for Kindle) plus LaTeX. I have created the LaTeX template, and Kindle is not sophisticated enough for layouts; a basic CSS would do (Amazon would rather I submit plain HTML).

Here is a sample of how I'm writing my poly.pm files:

#lang pollen

◊chapter{One}

"TOM!"

No answer.

"TOM!"

No answer.

Here is my pollen.rkt

#lang racket/base

(provide author title)
(define title "The Adventures of Tom Sawyer")
(define author "Mark Twain")

(require racket/date txexpr pollen/setup)
(provide (all-defined-out))

(module setup racket/base
  (define poly-targets '(html tex)))

(define (chapter . elements)
  (case (current-poly-target)
    [(tex) (apply string-append `("\\chapter{" ,@elements "}"))]
    [else (txexpr 'h1 empty elements)]))

(require pollen/decode txexpr)
(define (root . elements)
  (txexpr 'root empty (decode-elements elements
    #:txexpr-elements-proc decode-paragraphs
    #:string-proc (compose1 smart-quotes smart-dashes))))

This renders the HTML as (which is fantastic):

<html>
<head>
<meta charset="UTF-8">
<title>One | Adventures of Tom Sawyer by Mark Twain</title>
<link rel="stylesheet" type="text/css" media="all" href="/assets/css/main.css" />
</head>
<body>
<h1>The Edge</h1>
<p>“TOM!”</p>
<p>No answer.</p>
<p>“TOM!”</p>
<p>No answer.</p>
</body>
</html>

But renders my LaTeX as:

\chapter{One} “TOM!” No answer. “TOM!” No answer.

One way of handling this would be to use ◊p{"TOM!"}◊p{No answer.}, and omit decode-paragraphs, but that is going to make writing worse for me.

Is there a way I can conditionally use decode-paragraphs only for HTML output? I terribly messed up the syntax in my attempts. How do I write this condition? LaTeX handles --- and ..., but renders 'word' as ’word’; LaTeX uses `word' for quotes. It accepts ‘word’, though; doesn't interfere with smart-quotes.

The bigger goal is to know how to use Pollen to process basic HTML and basic LaTeX without having to resort to Markdown, but get all of the capabilities of Markdown (with a parser like Kramdown), ... to …; --- to —, 'word' to ‘word’, etc.

Pollen vs Org for notes, data, and publishing

TLDR: How well does Pollen handle use cases beyond just fancy typography? Am I better off doing everything in org mode that isn't a web page or book?

I've been using org mode for the last month or so for most of my note-taking and writing. It's nice for certain things and the tooling is better than I'd be able to put together myself in a short amount of time, but like other formats I've experimented with, I keep running into problems with the same few needs: flexibility/extensibility, legibility for humans, and legibility for computers.

For example, I want to create and publish a dictionary/glossary of in-group jargon for a couple communities I'm a part of. I want reading and writing to be easy, so relational databases, XML, SXML, HTML, and JSON files are out. For definitions and usage notes I'll need inline emphasis, links, and phonetic transcription at the very least, so using multi-line strings for longish text in TOML is out. I might want to mess around with corpus linguistics questions using that data, or at least be able to do simple things like checking for repeat entries, so it has to be easily legible to programs I write, which is a problem with anything that isn't an established format with libraries like XML or simple like S-expressions or similar.

Org mode can sorta do what I want. Those inline classes can be written with macros that create HTML tags. There's an Elisp API and Python libraries for reading org files and parsing the HTML tags. There's nesting, properties, tagging, and some other neat features. But all of this is awkward and hacky.

I'm hoping that Pollen will solve these problems, but I don't want to spend another month experimenting with a format I might end up dropping yet again without a sanity check first.

Everything I hear about Pollen focuses on typography, which is legitimately cool, but I'm wondering how well it can handle everything else. It would be nice to have a personal information management system that I can read, my programs can read, that has expressive text built-in, and that lets me just dump whatever parts of it I want onto a website with little hassle.

Will Pollen do it? Will Pollen do it if I write a reasonable amount of extra code to force it into shape? Is there some better format for my use case? Or should I just build my own format from scratch?

Tips to write lists

I know the traditional Pollen way of writing lists would be someting like this

◊ul{
◊i{first item}
◊i{second,
    multiline
    item
    ◊ul{
        ◊i{first item}
        ◊i{second,
            multiline
            item}}} 
}

But that is rather hard to read, I think. I managed to get something like this working

◊ul{
- first item
- second,
    multiline
    item
        - first item
        - second,
            multiline
            item
}

But now the code is hard to extend (i.e. by adding a new kind of bullet, or adding ordered sections). I’m wondering if any of you have already met the same problem and how did you slove it. It could be a concrete piece of code, or even some best-practices regarding these “semi-markdown tags” that you learned the hard way.

new feature: `dry-run` switch

In raco pollen setup and raco pollen render you can now supply a --dry-run or -d switch to see which files will be affected without actually performing the operation.

Reuse namespace

I did an experiment by modifying Pollen to use the same namespace instead of creating a new one for every file. For pollen-tfl with one thread, the rendering time after raco pollen reset reduces from 332s to 121s.

Of course, the behavior would be different. In particular, if files like pollen.rkt have a side-effect (say, mutate a global variable), then the side-effect would persist across rendering multiple files. However, for projects that don't have side-effects (which are probably the majority?), I think this is a performance boost for free?

Perhaps there should be an option to allow using the same namespace?

backlinks?

Hello all,

I am trying to figure out how, if possible, to create backlinks in Pollen.

If page A links to page B, then a 'back link' would be a link which goes from page B back to page A.

Several wiki engines support this feature and I would be very interested to know if anyone has implemented such a system for references, etc. I'm trying to avoid being sucked in by Roam Research. Any thoughts or ideas appreciated.

RFC breaking change: removal of certain `setup` options

I’d like to get rid of these user-configurable setup values, because I don’t believe they’re widely used (if at all), and Pollen accesses them frequently, which means a performance cost for no benefit.

The result of removing these is that the default value (shown on the right) would become the permanent, immutable value. Projects that have not overridden these values would work exactly the same way.

(define-settable preproc-source-ext 'pp)
(define-settable markup-source-ext 'pm)
(define-settable markdown-source-ext 'pmd)
(define-settable null-source-ext 'p)
(define-settable pagetree-source-ext 'ptree)
(define-settable template-source-ext 'pt)
(define-settable scribble-source-ext 'scrbl)
(define-settable poly-source-ext 'poly)
(define-settable cache-dir-name "compiled")
(define-settable cache-subdir-name "pollen")
(define-settable template-prefix "template")
(define-settable fallback-template-prefix "fallback")
(define-settable template-meta-key "template")
(define-settable main-export 'doc)
(define-settable meta-export 'metas)
(define-settable meta-tag-name 'meta)
(define-settable define-meta-name 'define-meta)

pollen start gives error if there are other directories

Hi,

I want to have some javascript and css static files in my pollen content directory so that the web pages render correctly. These are from Zurb Foundation Sites. When pollen tries to compile the project, I get an error, see below.

My directory layout is like this:

content/
  index.html.pm
  pollen.rkt
  template.html.p
  css/
    app.css
  js/
    app.js

How can I use the pollen webserver and also have static css and js at the same paths that they would be when published...?

I created a small publish script that does pollen render to an output directory, and then copies in the css and js static files which I can serve using npm. This works, but it requires the additional manual step to run the publish script.

Here's the error:

Servlet (@ /index.html) exception:
select: contract violation
  expected: existing Pollen source, or name of its output path
  given: #<path:/Users/adam/personal/proj/hcpr/hcpr/content/js1>

  context...:
   get-metas
   /Users/adam/Library/Racket/7.6/pkgs/pollen/pollen/core.rkt:28:25: select*
   select
   /Applications/racket/collects/racket/contract/private/arrow-val-first.rkt:486:18
   'g354: [running body]
   temp35_0
   for-loop
   run-module-instance!
   perform-require!
   for-loop
   top-level: [running body]
   eval-one-top
   begin-loop
   /Users/adam/Library/Racket/7.6/pkgs/pollen/pollen/render.rkt:343:0: render-markup-or-markdown-source
   /Users/adam/Library/Racket/7.6/pkgs/pollen/pollen/render.rkt:269:25: render
   /Users/adam/Library/Racket/7.6/pkgs/pollen/pollen/private/cache-utils.rkt:110:2: generate-dest-file
   ...```

compiling .pm file for sending to webserver without creating a file

Good afternoon. Just wondering if anyone else has tackled a similar problem. I'm trying to publish directly to a website using the website's api. I can connect successfully, get a response with authentication.

However, the data I've been sending is just junk data. What I'm trying to do now is raco pollen render without actually creating a file. I would like to output to a string which I can then send to the webserver for publishing or storage in sql or whatever. Does anyone have any ideas about how to output from a pollen markup file to a string?

I am thinking I should create a template.api file and do the work within the template file. Then create a poly-target called api. My only? problem, since ignorance is bliss, is I don't know how to stop the generation of a file.

Thanks much.

Debugging performance

At some point in one of my projects in the past month or so, the total time to build the site increased by about 30 seconds. Specifically, when doing a parallel render (and this is after preheating the cache) the first batch of pages render in ≈3sec each, and the rest render in ≈1.5–3 sec each. I can’t be sure if it was a change in my code, or the new Racket version, or (less likely) a change in Pollen. I upgraded to Racket 7.6 but have stuck with the non-CS variant.

This has brought me back to the question: what is a good way to investigate performance in a Pollen project? I am trying to learn how to use DrRacket’s profiling tools, but not getting very far; there isn’t much documentation about them, and the most “interesting” functions listed in the profiler are designated << unknown >>. I’ve so far tried using the profiler on a .poly.pm source file, and on a separate .rkt that calls render-to-file on that source file.

Additionally, it would be nice to see messages when there is a caching miss, so I can rule that out. Maybe another command line switch?

better handling of environment variables?

I’m working on a project where I’d like to use mutiple environment variables (not just POLLEN). You don’t need Pollen’s permission to do this, but ordinarily the cache only tracks the value of the POLLEN variable itself, so if you use others, the cache will not be invalidated correctly (assuming that the other environment variables affect the output).

I’m thinking of adding pollen/setup value — let’s call it envvar-watchlist — that would allow a project to specify the environment variables that matter. (Simply looking at all the environment variables is not a good policy.)

Thoughts? Objections? Improvements?

How to use Pagetree Navigation with Subdirectories

A project I'm working on would be much more manageable if I could use subdirectories with the pagetree. When I started to implement this, the navigation I expect with (next here), for example, stopped working. It just returned a blank string.

I read from this thread that I will need to do something like this in my pollen.rkt file:

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

with the proviso that if this code lives inside pollen.rkt,:

you can pass metas as an argument, or use the current-metas parameter.

Could someone help me with how to do that? At the moment I get unbound identifier in metas inside DrRacket.

suggestions for Pollen GUI app?

As a way of learning a little about Racket’s GUI library, I’m working on a small app for handling certain Pollen operations without the command line (for instance, running the project server).

This isn’t going to become the primary interface to Pollen. But it might be useful to people who don’t spend a lot of time on the command line.

Suggestions welcome for functionality that would be useful.

beginner questions

(1) It looks as if document structure and design is pretty much a do-it-yourself thing with pollen. But I suspect there are a number of pre-built lozenge commands that are available, whether as part of the pollen distribution or some kind of community folklore. Is there a list of these?

(2) One feature I need is file inclusion. Ideally something like ◊include["filename"] to include another file as if its contents were present in the place of the lozenge command. I've tinkered with scribble and not succeeded. In particular I've been unable to get all its at-commands (succh as @(require ...) working reliably from included text. More seems to be involved there than merely calling elem to to necessary conversions after the at-reader has done its work.
I hope it's simpler in pollen.

(I would not mind a restriction that the syntax be properly nested. I have no need to match an open bracket in one file with a close bracket in another, and would appreciate an error message if I seem to be trying that!)

(3) Not as essential, but would be nice: using the markdown parser on part of a document. Something like:
ordinary pollen stuff
◊markdown{ a page or two of markdown-style bullet-point notation }
more ordinary pollen stuff.

(4) Is there a way to indicate that the output file should be somewhere other than in its default location; e.g., in another directory?
-- hendrik

pollen performance and folders

Coming from little experience with web dev, pollen is great!
I have a few questions:
1: What is causing pollen take some time to generate pages since js based tools do it instantaneously?
2: I'd like to separate my pages into folders but I'm not sure how to write a directory down in the .ptree which is located at the root. Does every folder need it's own .ptree file?

Stacking or nesting templates

I'm wondering if there's some way to stack or nest templates? For example, I want a toplevel template.html.p that defines the general look and feel of my site, but then I want blog/template.html.p to define the look of blog posts. But the blog post template will share the <head> and navigation elements with the top-level templates, so it would be nice to have those in the toplevel, and just define an included smaller part in the blog template.

From my reading of the Pollen documentation on templates, it seems like there's only one template associated with a source file, and there isn't a way to nest them the way I'd like. Is there some way to do this?

Made with Pollen, Show and Tell: A command line zine

Hello!

I wanted to share a zine I made with pollen, that would not have been possible without all the incredible tips shared here in pollen-users. If this is too off-topic for this list I can remove it, but if not , here you go! https://solarpunk.cool/zines/map-is-the-territory

The source code for the zine can be found here: https://gitlab.com/cool-zines/the-map-is-the-territory/-/tree/master

I am v. grateful for the language and this community. Pollen is incredibly cool.

(Also: if there's any glaring improvements you can see in my pollen.rkt, I'm keen to know them!)

Structuring Pollen libraries

As I've been using Pollen to build my website, I've been gradually building up a small library tag functions. They're mostly for the standard HTML5 tags, but also for the Bootstrap framework. I was wondering if there's a good way to structure these so that I can (1) re-use them across projects and maybe (2) release them to other Pollen users who might find them helpful. Currently they are a couple of submodules in my top-level pollen.rkt file.

Graphviz diagrams inline with Pollen

One thing that I've wanted out of Markdown for a really long time is the ability to draw graphviz diagrams inline with my Markdown code. Now, this isn't going to happen with Markdown, so I just draw my diagrams in graphviz and include the images normally, but this becomes a huge pain when I'm answering answering assignment questions and naming my files something like q5-c.dot and trying to keep track of over a dozen of them. But Racket has a Graphviz library, so I was thinking if it might be possible to achieve this with Pollen.

What I want to be able to do something like:

#lang pollen
◊(require graphviz)

this is some text 

; Or something like this I guess
◊(include-graph (make-diagraph `(some code for the graphviz library)))

some more text after a picture of my FSM

I was wondering if this would work by first getting graphviz to generate the image and dump into into a temp file in a bin directory or something, then link to the image with an img tag or with whatever rendering strategy it's trying to use.

Is this something that Pollen can already do? I didn't read anything about it in the tutorials. If not, is it something you'd consider including?

Interactive books with Pollen?

Hello, I just read through the Pollen information and I am wondering if Pollen is capable of creating interactive electronic books. I do understand (of course) that the underlying Racket system can do anything. However, I am wondering whether Pollen supports interactive books (i.e., books that allow readers to enter data that will then be processed by some Racket function and result in an update of the displayed page content.)

question for those who like `poly` files

I’m thinking more about where Quad fits into the Pollen toolchain. For instance, so far I’ve thought about Quad mostly as a way of rendering PDF, including from Pollen sources. Which it can do today, in a simplified way.

But as I experiment with making poly files — admittedly, something I haven’t done much of in the past — I’m wondering if Quad wants to slot in higher. What I notice is that most of the tag functions for a poly file have to branch based on (current-poly-target). Which is fine, as far as it goes, and provides fine control for each output target, for those who want that.

But most of the formatting chores that occupy human consciousness are more vanilla — e.g., “center this text", "make this bold", etc. So I’m wondering if it would make more sense to move Quad up in the hierarchy. For instance, make each tag function in a poly file emit consistent Quad markup (regardless of the output format), and then let Quad figure out the rendering based on the output format.

I suppose this is similar to what Racket’s Scribble system already does, in terms of having multiple renderers (Markdown, HTML, LaTeX) that can generate output from a single Scribble file. Those renderers are notoriously difficult to customize, however, and indeed that’s part of the reason I made Pollen in the first place — to have very precise control of output, without having to contend with Scribble’s opinions. By that view, maybe making Quad more opinionated would send Pollen in a direction nobody wants.

[quad] word segmentation and zero-width space

TLDR: is there zero-width space in quad?

In some non-English languages such as Thai, there are no word boundaries. Particularly, whitespace is not a word boundary, but it is a sentence separator. This causes quad to enter a new line only at a new sentence, which is not optimal. The problem is described with more technical details here.

There are existing tools that help with this problem, notably Swath. So my current solution is to traverse the document tree and replace each string with outputs from Swath. However, I need zero-width space to glue these segmented words together. Is there a way to input it?

More generally, I want to ask if this is a good approach. I understand that quad is meant to be low-level, so the word segmentation problem might not be suitable to resolve at this level. Yet IMO, it also doesn't make sense to leave the problem, which is quite low-level, to users.

Adding tags in the sense of categories?

One common use that I couldn’t find easily described in the tutorials is
creating tags for content such as are present in e.g. WordPress. (Meaning, not
XML tags or tag functions, but tags like metadata applying to multiple items in a
hierarchy).

E.g., you might tag a document “legal”, “update”, “technology”, etc.

I realize this is probably very basic Racket that I’m misunderstanding.

The best way I could guess to do this would be to add ◊(define-meta) at the
top of a document and give it a list.

◊(define-meta my-tags '("legal" "update" "technology"))

Then in a template.html.pm, use something like

<ul>
  ◊(map ◊li{◊select*['my-tags metas]})
</ul>

This doesn’t work because something about the syntax is incorrect, but is it on
the right track?

[quad] positioning a block a text

Let me use this space for asking a quad question again.

I wonder how I can typeset a letter like this. Specifically, the letter heading has multiple lines. These lines all start at the same position (about 60% of the page width). How could I do that in quad? If this were LaTeX, I would use minipage or parbox, which would be equivalent to the quad structure in quad (as you mentioned at mbutterick/quad#57 (comment)). But as I understand, a quad cannot be directly manipulated (like changing its position) in quadwriter, correct?

[quad] dynamically query for a character width

For non-monospace font, each character could have different width. For instance . would be much less narrow than m. Is there a way to query for how wide each character is in quad?

Here's a use case. I am creating a form. In the unfilled state, the document could look like this:

Name: ................................
Age: .................................

In the filled state, it would look like this:

Name: ...Jane Doe.....................
Age: ...100...........................

The challenge is, how do I make sure that the length of the first line will be the same as the length of the second line? Particularly, it looks like I need a way to compute how wide the label in each line is, how wide the filled text in each line is, and subtract that from the desired length to determine how many dots I should put in.

Another solution would be something like \dotfill in LaTeX which automatically fills the rest of the line with dots. I then can use left-inset and right-inset to limit how much it can fill.

(http://joshua.smcvt.edu/latex2e/_005chrulefill-_0026-_005cdotfill.html documents \dotfill and how to use it to create a form like this).

stumped by this bytecode-caching problem

If Pollen generates bytecode for #lang pollen files, builds are about 20% faster. But there is a bytecode-caching bug I can’t figure out, illustrated by the sample code below.

This sample simulates a render of a Pollen source "doc.rkt" that relies on "pollen.rkt". After "pollen.rkt" is changed and the bytecode regenerated for both files, only "pollen.rkt" can be re-evaluated correctly. When "doc.rkt" is re-evaluated, it shows the older value.

Why is this so?

At first, I thought the dependency manager was failing to notice that "doc.rkt" relies on "pollen.rkt" (and thus should be recompiled when "pollen.rkt" changes). But the tests using module-recorded-dependencies seem to disprove this theory.

Then I thought that the bytecode for "doc.rkt" wasn’t being refreshed on the second call to managed-compile-zo. But even if I erase the first set of bytecode files, the problem persists.

My only remaining theory is that managed-compile-zo has some deeper cache mechanism that needs to be overcome, but if so how?

#lang at-exp debug racket
(require compiler/cm compiler/depend rackunit)

(display-to-file @string-append{
 #lang racket/base
 (provide id)
 (define id "first")} "pollen.rkt" #:exists 'replace)

(display-to-file @string-append{#lang pollen
 ◊id doc} "doc.rkt" #:exists 'replace)

(managed-compile-zo "pollen.rkt")
(managed-compile-zo "doc.rkt")

;; proves that dependency manager notices that "doc.rkt" relies on "pollen.rkt"
(check-true (and (member (path->complete-path (string->path "pollen.rkt")) (module-recorded-dependencies "doc.rkt")) #true))

(parameterize ([current-namespace (make-base-namespace)])
  (check-equal? (dynamic-require "pollen.rkt" 'id) "first"))

(parameterize ([current-namespace (make-base-namespace)])
  (check-equal? (dynamic-require "doc.rkt" 'doc) "first doc"))

(display-to-file @string-append{
 #lang racket/base
 (provide id)
 (define id "second")} "pollen.rkt" #:exists 'replace)

;; we erase the bytecode!
;; we erase the bytecode!
(for ([bc '("compiled/pollen_rkt.zo" "compiled/doc_rkt.zo")])
     (when (file-exists? bc)
       (delete-file bc)))

(managed-compile-zo "pollen.rkt")
(managed-compile-zo "doc.rkt")

(check-true (and (member (path->complete-path (string->path "pollen.rkt")) (module-recorded-dependencies "doc.rkt")) #true))

(parameterize ([current-namespace (make-base-namespace)])
  (check-equal? (dynamic-require "pollen.rkt" 'id) "second"))

(parameterize ([current-namespace (make-base-namespace)])
  (check-equal? (dynamic-require "doc.rkt" 'doc) "second doc")) ; huh?!?!

Auto-generate all files when using project server?

Running the pollen dev server doesn’t seem to actually generate any files
until you click on them through the menu. I would expect that this would
generate all files just as raco pollen publish does. It would make sense to
generate all of the files so that they can all be worked on iteratively (e.g.,
if pollen is just one step in a larger publishing pipeline) but
maybe there are performance reasons not to do this?

For reference, I’m using:

raco pollen reset && raco pollen start

not insert <br> for single linebreak

Hi,

Is there a way to get pollen to not insert <br> tags for single linebreaks? That way I can write text with linebreaks in my editor, but use CSS to flow text when it gets rendered to html.

Right now if I enter this:

◊p{First sentence.
Second sentence.
Third sentence.}

I get this output:

<p>First sentence<br>
Second sentence.<br>
Third sentence.</p>

But I want this:

<p>First sentence Second sentence. Third sentence.</p>

Running pollen on macOS Catalina

Hi, I'm unable to run a pollen server on macOS Catalina:

/Applications/Racket\ v7.4/bin/raco pollen start

works ok, but if I visit http://localhost:8080 I get the error that the project root was not found (it's definitely there). Presumably this is to do with the new permissions on Catalina. I've tried giving raco and racket full disk access but this did not solve the issues.

Any ideas?

Pollen/Racket “Office hours”

A couple of weeks ago I was invited by some “indie web” enthusiasts to give a tour of a personal project of mine that makes heavy use of Pollen. You can watch that tour on YouTube — it is quite long, but you can skip to the 58:00 mark to get to the Pollen stuff. Some of the attendees were very interested in Pollen and Racket, and I convinced them to dig into the tutorials themselves.

That event was encouraging enough that I’m experimenting with “Pollen/Racket office hours”. Maybe a “user group” would be a better term. Tomorrow (Friday April 10) I have the afternoon off work, so at ≈ 3pm CDT (4pm EDT/1pm PDT) I will be hosting a videoconference where I’ll be sharing my screen, and nerding out about Pollen and web publishing with anyone who cares to join. You could ask questions about Pollen, compare notes, or even share your own Pollen project.

Here’s the event page: https://www.mixily.com/event/5518667978796314220 …if you RSVP it will help me plan a bit, but it’s not necessary.

This is the first one of these I’ve ever done, and it’s short notice, so it might only be a couple of people. Optimistically 5–7? But it’s a subject I enjoy, I don’t get to discuss it with people very often, and it was really fun to do so at the first event I mentioned above. So if you like Pollen (or are wrestling with it) and you have some time, please stop by, it will be fun.

How should I make a pagetree with poly sources?

Do pagetrees only work with one output source?

Let's say I'm using poly sources (1.poly.pm and 2.poly.pm) to generate both html and txt output. If my pagetree contains:

  • 1.html
  • 2.html

then Pollen functions which rely on the pagetree (for example, previous here) work only when generating html output. The txt output seems to be unaware that there is any pagetree. So previous, next, parent and children links don't produce anything.

I tried making a pagetree with:

  • 1.poly
  • 2.poly

But that didn't fix it. None of the pagetree-depenent functions worked for either html or for txt.

Source location info in tag functions

In #27 @odanoburu asked about tag functions having info about where they are located in the Pollen source doc:

I wonder if it's possible to include the location of the error in the source file (i.e., the location of the tag in the source file, not of the location of the tag function in pollen.rkt). is this location information available to the tag function? if not, can it be made available?

This info is available at compile time, so if you write your tag function as a macro you absolutely can get to it. I recently cooked up a proof of concept:

#lang racket/base ; ~~~ pollen.rkt ~~~

(require pollen/tag)
(require (for-syntax racket/base syntax/parse))

(provide root note)

(define (root . elems)
  `(body ,@elems))

(define-syntax (note stx)
  (syntax-parse stx
    [(_ args ...)
     (with-syntax ([srcdoc (format "~a" (syntax-source stx))]
                   [srcline (number->string (syntax-line stx))])
      
       #'(note-tag #:src srcdoc #:line srcline args ...))]))

(define note-tag (default-tag-function 'div))

Paste this into example.html.pm and save it into the same folder:

#lang pollen

◊note[#:date "2019"]{This is going to be cool.}

“Running” it in DrRacket produces:

'(body
  (div
   ((date "2019")
    (line "3")
    (src
     "/Users/joel/Documents/code/sandbox/srcloc/example.html.pm"))
   "This is going to be cool."))

So you see that the output div contains the file and line number where ◊note occurs in the Pollen source. In order to make full use of this code you really need to delve into how macros and syntax objects work. I found it kind of brain-melting at first (still do, a bit). But it’s another example of Racket’s power, and it’s really cool that this is available to us in Pollen.

I haven’t used this for error reporting (I do as little error reporting in Pollen as possible since I’m the only user of my tag functions and can spot any issues pretty quickly). But I wanted to make it possible to have output that could link back to its source file and location.

Newbie: Defining classes

The solution is likely very obvious, but I've been stuck on this for days.

A couple of pages in my web-based book project need a different layout than the majority of the pages in the book. The solution I've been trying to hash out is wrapping the content on those specific html.pm files with a div assigned a specific class, but I'm not seeing the result. Note the background-color attribute for the #wide class is just for testing purposes.

credits.html.pm

#lang pollen
◊wide{
◊h2{Credits}
◊h3{Works}
The original Surplus Portfolio prints were made by Derek Sullivan at Open Studio, Toronto in 2012. Ink on Kozuke paper.
... }

styles.css.pp

body {
background: ◊|white|;
font-family: 'Karla', sans-serif;
font-size: ◊|multiplier|em;
line-height: ◊|multiplier|;
margin-bottom: ◊|edge|em;
margin-left: auto;
margin-right: auto;
}

#wide {
background: ◊|red|;
}

And then this is in the pollen.rkt file:

(define (wide . content)
`(div ((class "wide")) ,@content))

I must be missing something in the requisite parts, and haven't had any success trying out other solutions in the other Pollen examples I've seen so far. Any help is appreciated.

PDF accessibility

Because there's no quad-users, I decide to post this here, but feel free to move it wherever you think appropriate.

Last week, my friend spent an entire day trying to fix accessibility issues in her PDF files generated from LaTeX. By that, I mean making sure that screen reader will say the right thing. The issue is really frustrating because LaTeX source files have all information that is needed to make PDF accessible, but the final output is not accessible at all.

Can quad generate accessible PDF files? And if not, can I propose to add this to the feature request list?

pollen-users is fine for Quad questions

For the time being, everyone who is interested in Quad is also interested in Pollen, and Quad exists mostly to serve Pollen, so as moderator I officially deem it OK to post Quad-related questions here. It is, to my mind, all part of one unified struggle for better publishing tools.

If there comes a time when the Quad community has interests that diverge from that of the highbrow Pollen lifestyle, I will consider spawning a new gated community.

How does Pollen relate to Scribble?

The documentation says that:

Pollen is a publishing system built on top of Scribble and Racket.

I'm a bit unclear on what this means. Does it mean Pollen is built on top of Scribble the language (i.e the syntax), but not Scribble the library (with all the tag definitions and output formats)? I prefer the syntax and flexibility of Pollen, but I would still like to be able to use the features of the Scribble library. Is it possible to use Pollen syntax for writing Scribble documents to re-use these features? What are the limitations of Scribble that motivated the development of Pollen as a separate library instead of just being an alternative syntax for writing Scribble documents?

questions on MathJax

Hi, I'm a new pollen & racket users. I am experimenting with the source code for "Typography for Laywers" and trying to add LaTex equations into it on my computer.

Here is what I added into my html.pp file

◊(define ($ . xs) (mathjax ,(apply string-append ("$" ,@xs "$")))) ◊(define ($$ . xs) (mathjax ,(apply string-append `("$$" ,@xs "$$"))))

◊(define-meta title "where do the rules come from?")
◊hanging-topic[(topic-from-metas metas)]{Professional typography}

Example 1: ◊h1{◊${\mathcal{O} = 2_{\alpha+1}}}
Example 2: ◊${|\psi\rangle = \sum_nc_n|n\rangle}
`

However, the latex code only appears correctly in Example 1 where '◊h1' is used but this creates a bigger font than what I need. How can I make the latex code works without '◊h1'?

Another question is how do I move the following lines to pollen.rkt file? This is not obvious to me in the tutorial.

◊(define ($ . xs) (mathjax ,(apply string-append ("$" ,@xs "$")))) ◊(define ($$ . xs) (mathjax ,(apply string-append `("$$" ,@xs "$$"))))

Thanks!

plans for latex like replacement

Hi, back in RacketCon 2014 you seemed keen on expanding pollen to a complete replacement of latex for authoring documents, but pollen still seems to rely heavily on latex to get to pdf. Did you encounter a show stopper in the plan, or was it just change of time/interest?

It's a neat idea, and I'm looking at pollen as a potential killer language in which to typeset lecture notes, with web and pdf as the main target outputs. At the moment though it seems like you would be fighting latex since it's designed to control the whole document production process.

Representing hyperlinks in Pollen

I was wondering how people represent hyperlinks in Pollen. Currently I have the following tag functions for general links, and internal (same site) links:

(define (link url . text)
  `(a ((href ,url)) ,@text))

(define (internal url . text)
  (let ([url (string-append "/" url)])
    `(a ((href ,url)) ,@text)))

So I can write links as ◊link["https://link.url"]{Link Text}. It's a little suboptimal since I have to wrap the URL in quotes. I also don't handle alt text or such. Any other ideas for how to represent links?

Handling of tag functions within Pollen Markdown/Authoring mode

The "issue" or concern is how default tag function behavior is/is not handled in markdown authoring mode, and it's implications for using pollen.

When in markdown mode (*.poly.pmd),

◊(sidebar "hi!")

renders to:

(p rsquo "(sidebar " ldquo "hi!" rdquo ")")

In pollen markup mode, (*.poly.pm),

◊(sidebar "hi!")

renders to :

(sidebar "hi!")

I can imagine that this is related to the rule that tag functions in markdown authoring mode must render to markdown, however I am curious why the default tag function behavior does not apply. (or what the loss would be in changing it to apply)

In terms of the output X-expressions, if the default tag function behavior applied, then tag functions could be used to make a user extensible version of markdown. (which then using other parts of pollen could be used to have a relatively more readable source render to X-expression then convert to HTML+CSS and LaTeX)

To further the above example, consider the following .pm:

#lang pollen

◊(h1 "Barticle Title")
◊(p "The wonderful "◊(em "second") " part of the article.")
◊(sidebar "hi!")

which renders to:

(root
  (h1 "Barticle Title")
  (p "The wonderful " (em "second") " part of the article.")
  (sidebar "hi!"))

compared to the following markdown:

#lang pollen

Barticle Title
==============
 
The wonderful _second_ part of the article.

◊(sidebar "hi!")

which renders to:

(root
  (h1 ((id "barticle-title")) "Barticle Title")
  (p "The wonderful " (em "second") " part of the article.")
  (p rsquo "(sidebar " ldquo "hi!" rdquo ")"))

however, if the default tag function were obeyed even in markdown mode, it might be:

(root
  (h1 ((id "barticle-title")) "Barticle Title")
  (p "The wonderful " (em "second") " part of the article.")
  (sidebar "hi!"))

which, at least given my neophyte understanding of X-expressions, would be easier to work with. It would also seem to fulfill the goal of markdown authoring mode, which I presume to be to serve as a gateway drug to fuller use of pollen markup and semantic tags.

As possibly relevant context, I have approval from my supervisor to write a project in "70% markdown with some customization to allow for website and PDF to both look great", but not to use a new markup language. So I would happily ditch markdown entirely, however the difference in readability for everyone else in my (modestly tech savvy government) office threatens to rule out pollen before I get much further.

faster renders (I think)

I’ve been burned before by overconfidence (see: parallel processing). But today I had (what I hope will turn out to be) a genuinely good idea: to create a fast path for raco pollen setup and raco pollen render that skips certain expensive luxuries that one really needs only during interactive development sessions with the project server (which will be as sluggish as always). For instance, rebuilding Beautiful Racket is now 3x faster. Try it and let me know if it improves your life (or the opposite).

Pollen report: two websites, one source

I recently did something with Pollen I hadn’t tried before: collapsing my websites Practical Typography and Typography for Lawyers into one set of source files.

I use the environment variable pub=tfl or pub=bpt to determine which target to use in a writing or rendering session. Then I have tag functions called tfl and bpt that are shown in one publication and not the other, so I write branching sentences like

This is commonly used by ◊tfl{lawyers}◊bpt{writers}.

I also use the pub environment variable in the setup submodule to set a different default pagetree and publishing directory. Aside from a few other minor housekeeping details, that’s about it.

The only shortcoming I’ve found is that having two projects “duplexed” in this way defeats the page-rendering cache (that is, when you switch from one publication to another, you have to reset all the rendered HTML files). However, the compile caches work correctly, since Pollen keeps separate caches for each value of pub (once I added pub to the envvar-watchlist)

Ignoring certain elements in decode-paragraphs

Hello!

I am making a pollen site that includes a form, which is organized into a series of fieldsets.

I would like to write the form like so:

 ◊fieldset[]{
 ◊legend{About You}
 ◊text-input[#:for "Name"]{}
 ◊text-input[#:for "Email"]{}
 ◊text-input[#:for "Emergency Contact"]{Who should we call (name and number)? }}

(the text input will make a label and input based on #:for, with any text in the curly braces added as helper text)

The issue I'm having is that, when this renders, everything inside of fieldset gets wrapped in a <p> tag, and so the legend is not added correctly and it loses semantic clarity. I can remove the linebreaks in my page and solve the issue, but then the pollen file is hard to read.

I have decode-paragraphs added in the style given in the pollen tutorial, and love it for the other pages in this site:

 (define (root . elements)
-     (txexpr 'root empty (decode-elements elements
                                           #:txexpr-elements-proc decode-paragraphs
                                           #:string-proc (compose1 smart-quotes smart-dashes))))

I think it is causing the <p> tag wrapping on the form, though.

Is it possible to have it pass over elements like fieldset, so I can get both the pollen file and html output I want?

Thank you!

Racket CS performance

Racket CS is the new version of Racket built atop Chez Scheme. For now it’s available as a separate installer. But before too long, it will become the default version of Racket. (Today’s Racket will become known as “Racket BC”)

Today, Racket CS performance is pretty close to parity with Racket BC (though it is continuing to be improved). One area that is notably different, however, is parallel processing.

In my quick tests on Pollen projects, I’ve found that Racket CS performance is optimal at 4 cores (and actually goes slower at 8 cores and 12 cores). Whereas Racket BC always goes faster with more cores.

You can control the number of cores in a parallel job by using the -j X switch (where X is the number of parallel jobs) rather than the -p switch (which is like -j C where C is the total number of cores on your machine).

If you switch to Racket CS early, you may want to experiment with the -j count to find the optimum level.

Conversely, if you’re acclimated to burning hot 40-core Pollen parallel builds, you probably want to stick with Racket BC for a while to come. I expect the parallel performance of Racket CS to improve.

Supernerds who build from source can install both Racket BC and Racket CS (they can peacefully coexist) and compare timings.

“Pollen Time” streaming event: May 7, 2020

I’m planning to have the next “Pollen office hours” type event on May 7.

Read the email newsletter for details. Here are the highlights:

  • The streaming event will be on Thursday, May 7, at 7pm CDT.
  • The event will be live-streamed on YouTube: Here is a link for that stream. There is no need to RSVP! Just show up. You won’t be using your webcam or calling in to anything, but there will be live chat.
  • What will happen: I/we will be writing a “Pollen Cookbook” live, in Pollen, to demonstrate various commonly-requested techniques.
  • However, note: I am not an experienced streamer. So I am planning a preliminary “mic check” streaming session on Sunday May 3, at 1:30pm CDT (YouTube link), in which I will be doing nothing but testing my setup, drinking coffee, and taking early feedback and suggestions.

Implementing targets as separate components

I'm learning Pollen to ditch Hugo and every static site generator that frustrates me. I am somewhat familiar with Scheme, but a newcomer to Racket, especially the module system.

I've done the fourth tutorial, on multiple output targets. I understand that pollen.rkt defines a module that resolves Pollen tags. The tutorial uses branching expressions within tag functions to implement different targets.

I want to make the implementation choice at the module level rather than in the tag functions. In other words: separate targets into different components. I think of a Pollen document as requiring an interface, with the current poly target controlling which implementation is used. However, I'm not skilled enough in Racket to do this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.