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.md
doc.new-extension
You 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" }
.html
Returns 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" }
.txt
Returns the textContent
of a document.
{ "content": "\nsome markdown content\n", "extension": ".txt", "name": "doc.txt", "stem": "doc", "type": "text/plain" }
.md
Returns the document as a valid '.md' file.
{ "content": "> **some** HTML content", "extension": ".md", "name": "doc.md", "stem": "doc", "type": "text/markdown" }
.xml
Returns 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" }