[rich-text-plain-text-renderer] Allow custom render nodes to be provided like Rich Text Html Renderer
Feature Request: Allow custom render nodes to be provided like Rich Text Html Renderer. Use the same syntax as the RichTextHtmlRenderer does.
By allowing custom render nodes to be passed, users can handle things like embedded entries (see #161) as well as allowing for custom output for items such as links where both the text and uri would likely be desired.
An example:
A link could look something like this:
const customTextRenderNode = {
renderNode: {
[INLINES.HYPERLINK]: (node, next) => `${next(node.content)}: ${node.data.uri}\n`,
},
};
And be called like this:
const renderedText = documentToPlainTextString(richTextDocument, null, customTextRenderNode);
Hey @localpcguy , that sounds like a good idea. Is that something you are willing to submit a PR for?
Sure, I can take a stab at it
Have not had time to work on this yet. I'm still interested in doing it, but also don't want to prevent someone else from jumping on it if they want to or need it.
Taking a stab with a simple implementation using the following logic:
- adding
optionsas a third optional parameter, much likedocumentToHtmlString - checking to see if the desired
renderNodeis available and if so, using it from within the check to see if we are a block or inline object
I say simple because I do not see a need to define defaults for all renderers since this is ultimately rendering text.