@@ -35,7 +35,7 @@ class Element {
3535 this . attributes = { } ;
3636 this . atom = el . atom ;
3737 this . type = el . type ;
38- this . file = el . file ;
38+ this . filename = el . file ;
3939 this . nodes = el . nodes ? el . nodes : [ ] ;
4040 this . attributes = el . attributes ? el . attributes : { } ;
4141 if ( this . attributes === undefined ) {
@@ -100,13 +100,13 @@ class Document extends Element {
100100 constructor ( el ) {
101101 super ( el ) ;
102102 this . id = "" ;
103- this . file = "module.md" ;
103+ this . filename = "module.md" ;
104104 this . root = el . root ;
105105 this . title = el . title ;
106106 this . parser = el . parser ;
107- this . file = el . file ;
108- if ( this . file === undefined ) {
109- this . file = "module.md" ;
107+ this . filename = el . file ;
108+ if ( this . filename === undefined ) {
109+ this . filename = "module.md" ;
110110 }
111111 this . id = el . id ? el . id : v4 ( ) ;
112112 this . nodes = el . nodes ;
@@ -804,28 +804,35 @@ function newElement(n) {
804804}
805805
806806class Module {
807- constructor ( mod , parser ) {
807+ constructor ( doc , parser ) {
808808 this . id = "" ;
809- this . file = "" ;
809+ this . filepath = "" ;
810810 this . dir = "" ; // calculated from file
811811 this . name = "" ; // calculated from file
812- this . id = v4 ( ) ;
813- if ( mod . id ) {
814- this . id = mod . id ;
812+ this . parser = new Parser ( ) ;
813+ if ( doc . id === undefined ) {
814+ doc . id = v4 ( ) ;
815815 }
816- if ( mod . file === undefined ) {
817- mod . file = "module.md" ;
816+ this . id = doc . id ;
817+ if ( doc . root === undefined ) {
818+ doc . root = "" ;
818819 }
819- if ( mod . root === undefined ) {
820- mod . root = "" ;
820+ if ( doc . filename === undefined ) {
821+ doc . filename = "module.md " ;
821822 }
822- this . file = path . join ( mod . root , mod . file ) ;
823- this . dir = mod . root ;
824- this . name = path . basename ( mod . file ) ;
825- this . parser = parser ? parser : new Parser ( ) ;
826- this . doc = this . parser . parse ( mod . doc ? mod . doc : mod ) ;
823+ this . filepath = path . join ( doc . root , doc . filename ) ;
824+ this . dir = doc . root ;
825+ this . name = doc . filename ;
826+ this . doc = this . parser . parse ( doc ) ;
827827 this . toc = new Toc ( ) ;
828828 this . toc . perform ( this . doc ) ;
829+ // this.file = path.join(doc.root, doc.file);
830+ // this.dir = doc.root
831+ // this.name = path.basename(doc.file)
832+ // this.parser = parser ? parser : new Parser();
833+ // this.doc = this.parser.parse(doc.doc ? doc.doc : doc);
834+ // this.toc = new Toc();
835+ // this.toc.perform(this.doc);
829836 }
830837 title ( ) {
831838 if ( this . doc === undefined ) {
@@ -853,7 +860,7 @@ function EmptyModule() {
853860 mod . id = "" ;
854861 mod . doc . id = "" ;
855862 mod . dir = "" ;
856- mod . file = "empty.md" ;
863+ mod . filepath = "empty.md" ;
857864 mod . name = "empty.md" ;
858865 return mod ;
859866}
@@ -864,7 +871,7 @@ class Modules {
864871 this . mods = { } ;
865872 }
866873 add ( mod ) {
867- this . mods [ mod . file ] = mod ;
874+ this . mods [ mod . filepath ] = mod ;
868875 this . current = mod ;
869876 return this . list ( ) ;
870877 }
0 commit comments