The .nano format is compact storage of HTML and XML in YAML or JSON.
0BSD License
English | Franais | Espaol | Portugus | Italiano | Nederlands | Deutsch | etina | | | | Polski |
nano-format
HTML/XML Nano, YAML JSON .
.
HTML XML.
YAML (JSON).
, , .
npm yarn:
npm install nano-format
yarn add nano-format
nano2html()
Nano HTML:
const { nano2html } = require('nano-format');
const nano = {
p: {
$class: 'text',
content: ' .'
}
};
const html = nano2html(nano);
console.log(html);
// <p class="text"> .</p>
( content
):
const { nano2html } = require('nano-format');
const nano = {
$class: 'text',
p: ' .'
};
const html = nano2html(nano);
console.log(html);
// <p class="text"> .</p>
html2nano()
HTML- Nano:
const { html2nano } = require('nano-format');
const html = `<p class="text"> .</p>`;
const nano = html2nano(html);
console.log(nano);
/*
{
p: {
$class: 'text',
content: ' .'
}
}
*/
nano-format
setSelfClosedTags()
, setDefaultAttributes()
, setTags()
:
const { setSelfClosedTags, setDefaultAttributes, setTags } = require('nano-format');
//
setDefaultAttributes({ 'customComment': '$ref' });
setTags([
{ child: 'div', tags: ['section', 'article'] },
]);
setSelfClosedTags(['customComment']);
// customComment setTags addTags { child: '', tags: ['customComment'] }
`resetAll()`:
const { resetAll } = require('nano-format');
resetAll();
nano2html(content, nextTag = null)
Nano HTML.
:
content
(any): Nano .nextTag
(string|null): , (').html2nano(html)
HTML- Nano.
:
html
(string): HTML- .setSelfClosedTags(tags = null)
.
:
tags
(string[] | null): null .setDefaultAttributes(attrs = null, value = undefined)
.
:
attrs
(DefaultTagsAttributes | null): null .value
(string | undefined): (').resetAll()
.
:
ISC.