nano-format

The .nano format is compact storage of HTML and XML in YAML or JSON.

0BSD License

Downloads
585
Stars
0
Committers
1

English | Franais | Espaol | Portugus | Italiano | Nederlands | Deutsch | etina | | | | Polski |

.nano - HTML XML YAML JSON.

nano-format HTML/XML Nano, YAML JSON .

  • .
  • .
    
  •  HTML  XML.
    

  •     YAML (JSON).
    
  •  ,  ,     .
    

npm  yarn:
npm install nano-format
yarn add nano-format

Nano HTML

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>

HTML Nano

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();

API

  • nano2html(content, nextTag = null) Nano HTML. :

    • content (any): Nano .
    • nextTag (string|null): , (').
      :
    • HTML-.
  • html2nano(html) HTML- Nano. :

    • html (string): HTML- .
      :
    • Nano.
  • setSelfClosedTags(tags = null) . :

    • tags (string[] | null): null .
      :
    • .
  • setDefaultAttributes(attrs = null, value = undefined) . :

    • attrs (DefaultTagsAttributes | null): null .
    • value (string | undefined): (').
      :
    • .
  • resetAll() . :

    • ' , .

  ISC.