I am building a use case in Workshop, where the user is working with an agent to generate a report.
The agent is outputting this report in Markdown, making it easier to read and allowing the user to view citations.
Outputting this text to Notepad results in the pure markdown being shown, which doesn’t look great.
As these reports do not follow a specific pattern, the generator widgets are not very useful.
Is there a native way to make this output look good, by tapping into Notepad’s formatting?
My alternative is to finish this “last mile” of the task outside of Foundry, which would be a lot of work for a simple task like this, or create objects that are then parsed into the template, which is also a very roundabout way of solving this.
You can convert Markdown to rich text in Notepad by using a function in a Notepad template:
- Add a Functions on Objects widget to your Notepad template and configure it with a string template input.
- In the widget configuration, set the function result as “Markdown”. This will interpret the output of the function as markdown and convert it to rich text in Notepad.
- If you don’t need to perform any additional processing on the markdown string that you provide as a template input, the function itself can be a simple string identity function.
When generating a Notepad from the template, you can then provide the markdown string as input and the formatted text will be included in the generated document.
Note that some markdown syntax, such as nesting a numbered list inside a bulleted list, is not supported in Notepad. While the conversion is not guaranteed to be 1:1, most of the CommonMark spec should be supported.
thanks @gblake, should’ve mentioned I already tried this and ran into issues with the inconsistencies you mention.
Is there another way to programatically build this? By hitting the notepad API (https://foundryurl.com//notepad/api/notepad/notepadRid) I can see the elements of how the document is constructed.
Are there any API endpoints I can use to do this? Not worried if these are subject to change.
Notepad’s JSON document schema is not part of its supported public API and is subject to change without notice, so programmatically constructing documents from the raw JSON representation isn’t supported.
Could you share more about the issues you ran into with the markdown function approach? Was there formatting or types of elements that weren’t converting properly?