mbutterick / pollen-users

please use https://forums.matthewbutterick.com/c/typesetting/ instead
https://forums.matthewbutterick.com/c/typesetting/
53 stars 0 forks source link

serialising txexprs? #117

Closed aalexei closed 2 years ago

aalexei commented 2 years ago

Hi, I'm trying to create pages that contain a list of other pages. Like a subject outline and description followed by a list of pages containing material.

In my html template I save metadata to an sqlite database, and in the subject outline I can pick up that data for every page. The problem is that some of the data I want to store, like the title and abstract, can contain arbitrarily nested txexprs. Two possible approaches I've tried but not managed to get working are

For the first, I just get the html tags in the text as strings not as html code, which I guess makes sense. The second approach seems more general but I don't know how to serialize some nested txexprs to a string that sqlite accepts. Anyone have some pointers I could try?

otherjoel commented 2 years ago

If you write the txexpr to a string, you will be able to read it back in again!

Read those docs carefully and experiment a bit in a REPL. They operate on ports, not strings, so you will need to convert your strings to ports with, e.g., open-input-string and open-output-string.

aalexei commented 2 years ago

Ahh, thank you for that! Got it working nicely. My bouncing around the docs and experimenting in a REPL just wasn't finding how to connect strings and ports together.