unified-doc

Overview

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!

Simple filename operations

With the returned file data, you can easily work with the filename and extension to rename files.

Live Code Editor
Preview
Old filename: doc.md
New filename: doc.new-extension

Create a file

You can easily create JS files with the file data returned by doc.file().

Live Code Editor
Preview
Check console for logged file

Export as original/source

Returns the document as-is.

Live Code Editor
Preview
{
  "content": "> **some** markdown content",
  "extension": ".md",
  "name": "doc.md",
  "stem": "doc",
  "type": "text/markdown"
}

Export as .html

Returns the document as a valid '.html' file.

Live Code Editor
Preview
{
  "content": "<blockquote>\n<p><strong>some</strong> markdown content</p>\n</blockquote>",
  "extension": ".html",
  "name": "doc.html",
  "stem": "doc",
  "type": "text/html"
}

Export as .txt

Returns the textContent of a document.

Live Code Editor
Preview
{
  "content": "\nsome markdown content\n",
  "extension": ".txt",
  "name": "doc.txt",
  "stem": "doc",
  "type": "text/plain"
}

Export as .md

Returns the document as a valid '.md' file.

Live Code Editor
Preview
{
  "content": "> **some** HTML content",
  "extension": ".md",
  "name": "doc.md",
  "stem": "doc",
  "type": "text/markdown"
}

Export as .xml

Returns the document as a html-compatible '.xml' file.

Live Code Editor
Preview
{
  "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"
}
© 2020 unified-doc