Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Render formatted Scripture to screen using Pk renderer #11

Open
mvahowe opened this issue Dec 8, 2021 · 1 comment
Open

Render formatted Scripture to screen using Pk renderer #11

mvahowe opened this issue Dec 8, 2021 · 1 comment
Assignees

Comments

@mvahowe
Copy link
Collaborator

mvahowe commented Dec 8, 2021

The current PoC, in Diegesis, can be seen at https://github.com/Proskomma/diegesis/blob/ad625bce427af3886eb9817c61bb69334449fa65/src/pages/Browse/TextBookContent.js#L38

The main steps are

  • Run a 'kitchen sink' query to get a description of the whole document (L43)
  • Build a config object to pass data into the renderer (L45). Note that this object is also used to store and return state (so it should probably have a different name).
  • Instantiate the renderer (L57).
  • Give that renderer at least one docSet handler (L58, L60).
  • Give that docSet handler at least one document handler (L59). Multiple handlers are useful if, eg, frontmatter is to be processed differently to canonical text.
  • Render (L61)
  • Do something with the generated state in the config object (L62)

At present it does not handle some USFM features such as character styles, but this could be done, as demonstrated for HTML generation with https://github.com/Proskomma/proskomma-render-pdf

One gotcha is that JSX cannot be generated one tag at a time, instead, some type of stack is required to collect enclosed content and then wrap it with matching tags. (The Diegesis PoC does this. The PDF generator does it in most places but is simply building strings.)

Also note that, in this case, the rendering model is setting the cv reference that is used to scroll to the selected verse.

We discussed making the renderer markup agnostic, ie allowing different containers etc to be specified. This would be cool, but it might be easier to get a hardwired model working with the hook first.

@mvahowe
Copy link
Collaborator Author

mvahowe commented Dec 8, 2021

Also, while the initial query could probably be handled by another, existing hook, we might want to wrap the entire process, since behaviour of the model when fed the results of a different query is undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants