Add support for passing an extra env dictionary to the MarkdownSerializer #98

Closed
opened 2023-05-16 14:28:40 +02:00 by segevfiner · 5 comments
segevfiner commented 2023-05-16 14:28:40 +02:00 (Migrated from github.com)

This is useful for serialization rules that need additional data or configuration that isn't part of the document.

This is useful for serialization rules that need additional data or configuration that isn't part of the document.
marijnh commented 2023-05-17 09:58:27 +02:00 (Migrated from github.com)

Why not just have your serializer functions close over the data they need?

Why not just have your serializer functions close over the data they need?
segevfiner commented 2023-05-17 11:33:44 +02:00 (Migrated from github.com)

I don't want to create a new instance of MarkdownSerializer for each parse
cycle.

בתאריך יום ד׳, 17 במאי 2023, 10:58, מאת Marijn Haverbeke ‏<
@.***>:

Why not just have your serializer functions close over the data they need?


Reply to this email directly, view it on GitHub
https://github.com/ProseMirror/prosemirror-markdown/issues/98#issuecomment-1550933213,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AF4WB76FE32XU3UQK6NCI7TXGSAK3ANCNFSM6AAAAAAYDSL3IE
.
You are receiving this because you authored the thread.Message ID:
@.***>

I don't want to create a new instance of MarkdownSerializer for each parse cycle. בתאריך יום ד׳, 17 במאי 2023, 10:58, מאת Marijn Haverbeke ‏< ***@***.***>: > Why not just have your serializer functions close over the data they need? > > — > Reply to this email directly, view it on GitHub > <https://github.com/ProseMirror/prosemirror-markdown/issues/98#issuecomment-1550933213>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AF4WB76FE32XU3UQK6NCI7TXGSAK3ANCNFSM6AAAAAAYDSL3IE> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
marijnh commented 2023-05-17 13:38:24 +02:00 (Migrated from github.com)

Wouldn't you have to do the same if you pass in the env as an object?

Wouldn't you have to do the same if you pass in the env as an object?
segevfiner commented 2023-05-17 13:39:59 +02:00 (Migrated from github.com)

I only need to create the env object and pass it to serialize, reusing the same global MarkdownSerializer.

I only need to create the env object and pass it to `serialize`, reusing the same global `MarkdownSerializer`.
marijnh commented 2023-05-17 15:12:31 +02:00 (Migrated from github.com)

Ah, I see, it's an argument to serialize. Still, this seems to address a highly specific use case that's easily enough worked around by putting the values you need to access in some shared variable, so I don't think this needs to be in the library.

Ah, I see, it's an argument to `serialize`. Still, this seems to address a highly specific use case that's easily enough worked around by putting the values you need to access in some shared variable, so I don't think this needs to be in the library.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
prosemirror/prosemirror-markdown#98
No description provided.