import {TextNode} from './nodes';

function no_san(v) { return v; }
export class FormatProperties
{
    identifier;

    constructor( identifier, props = {} )
    {
        this.identifier = identifier;
        Object.assign( this, props );
        TextNode.add_sanitizer( this.identifier, props.text_sanitize || no_san );
    }

    sanitize( text )
    {
        TextNode.sanitize( this.identifier, text );
    }
}

export class MarkupFormatProperties extends FormatProperties
{
    static default_props = {
        quote: null,            // no default quote
        brackets: ['', ''],      //
        eq: '=',
        term: '/',
        self_attribute: false
    };

    constructor( identifier = '', props = {} )
    {
        super( identifier, Object.assign({}, MarkupFormatProperties.default_props, props ) );
    }

    get l_bracket() { return this.brackets[0]; }
    get r_bracket() { return this.brackets[1]; }
}


@@ -97,26 +97,20 @@
 s%0A%7B%0A    
-identifier
+name
 ;%0A%0A    c
@@ -121,26 +121,20 @@
 ructor( 
-identifier
+name
 , props 
@@ -163,31 +163,19 @@
 his.
-identifier = identifier
+name = name
 ;%0A  
@@ -247,26 +247,20 @@
 r( this.
-identifier
+name
 , props.
@@ -352,26 +352,20 @@
 e( this.
-identifier
+name
 , text )
@@ -646,26 +646,20 @@
 ructor( 
-identifier
+name
  = '', p
@@ -695,18 +695,12 @@
 er( 
-identifier
+name
 , Ob

use name instead of identifier