Skip to content
This repository has been archived by the owner on Sep 17, 2022. It is now read-only.

serialising txexprs? #117

Closed
aalexei opened this issue Sep 29, 2021 · 2 comments
Closed

serialising txexprs? #117

aalexei opened this issue Sep 29, 2021 · 2 comments

Comments

@aalexei
Copy link

aalexei commented Sep 29, 2021

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

  • convert the fields to html in the template with ->html and store that. Then I include those strings in the outline page.
  • serialize the txexprs and store, then deserialize them and insert into the page tags to be interpreted in the usual way.

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

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
Copy link
Author

aalexei commented Sep 30, 2021

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.

@aalexei aalexei closed this as completed Sep 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants