The doc.file() method provides simple ways to return file data based on the specifie file extension (if supported). This is the unified-doc's way of performing file conversions!
With the returned file data, you can easily work with the filename and extension to rename files.
doc.mddoc.new-extensionYou can easily create JS files with the file data returned by doc.file().
Returns the document as-is.
{
"content": "> **some** markdown content",
"extension": ".md",
"name": "doc.md",
"stem": "doc",
"type": "text/markdown"
}.htmlReturns the document as a valid '.html' file.
{
"content": "<blockquote>\n<p><strong>some</strong> markdown content</p>\n</blockquote>",
"extension": ".html",
"name": "doc.html",
"stem": "doc",
"type": "text/html"
}.txtReturns the textContent of a document.
{
"content": "\nsome markdown content\n",
"extension": ".txt",
"name": "doc.txt",
"stem": "doc",
"type": "text/plain"
}.mdReturns the document as a valid '.md' file.
{
"content": "> **some** HTML content",
"extension": ".md",
"name": "doc.md",
"stem": "doc",
"type": "text/markdown"
}.xmlReturns the document as a html-compatible '.xml' file.
{
"content": "<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body><blockquote><strong>some</strong> HTML content</blockquote></body></html>",
"extension": ".xml",
"name": "doc.xml",
"stem": "doc",
"type": "application/xml"
}