Skip to content

Commit 0944b51

Browse files
committed
changes
1 parent 8b48587 commit 0944b51

20 files changed

+108
-83
lines changed

dist/document.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export declare class Document extends Element {
33
id: string;
44
root: string;
55
title: string;
6-
file: string;
6+
filename: string;
77
section_id?: number;
88
snippets?: {};
99
parser?: {

dist/document.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ export class Document extends Element {
44
constructor(el) {
55
super(el);
66
this.id = "";
7-
this.file = "module.md";
7+
this.filename = "module.md";
88
this.root = el.root;
99
this.title = el.title;
1010
this.parser = el.parser;
11-
this.file = el.file;
12-
if (this.file === undefined) {
13-
this.file = "module.md";
11+
this.filename = el.file;
12+
if (this.filename === undefined) {
13+
this.filename = "module.md";
1414
}
1515
this.id = el.id ? el.id : uuidv4();
1616
this.nodes = el.nodes;

dist/element.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { Node } from "./node";
22
export declare class Element implements Node {
33
atom: string;
44
type: string;
5-
file?: string;
5+
filename?: string;
66
nodes: Node[];
77
attributes: {};
88
constructor(el: any);

dist/element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export class Element {
44
this.attributes = {};
55
this.atom = el.atom;
66
this.type = el.type;
7-
this.file = el.file;
7+
this.filename = el.file;
88
this.nodes = el.nodes ? el.nodes : [];
99
this.attributes = el.attributes ? el.attributes : {};
1010
if (this.attributes === undefined) {

dist/empty_mod.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function EmptyModule() {
1212
mod.id = "";
1313
mod.doc.id = "";
1414
mod.dir = "";
15-
mod.file = "empty.md";
15+
mod.filepath = "empty.md";
1616
mod.name = "empty.md";
1717
return mod;
1818
}

dist/index.js

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -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

806806
class 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
}

dist/module.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { Toc } from "./toc";
33
import { Parser } from "./parser";
44
export declare class Module {
55
id: string;
6-
file: string;
6+
filepath: string;
77
dir: string;
88
name: string;
99
parser: Parser;
1010
doc: Document;
1111
toc: Toc;
12-
constructor(mod: any, parser?: Parser);
12+
constructor(doc: any, parser?: Parser);
1313
title(): string;
1414
toString(): string;
1515
}

dist/module.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,35 @@ import { v4 as uuid } from "uuid";
33
import path from "path-browserify";
44
import { Parser } from "./parser";
55
export class Module {
6-
constructor(mod, parser) {
6+
constructor(doc, parser) {
77
this.id = "";
8-
this.file = "";
8+
this.filepath = "";
99
this.dir = ""; // calculated from file
1010
this.name = ""; // calculated from file
11-
this.id = uuid();
12-
if (mod.id) {
13-
this.id = mod.id;
11+
this.parser = new Parser();
12+
if (doc.id === undefined) {
13+
doc.id = uuid();
1414
}
15-
if (mod.file === undefined) {
16-
mod.file = "module.md";
15+
this.id = doc.id;
16+
if (doc.root === undefined) {
17+
doc.root = "";
1718
}
18-
if (mod.root === undefined) {
19-
mod.root = "";
19+
if (doc.filename === undefined) {
20+
doc.filename = "module.md";
2021
}
21-
this.file = path.join(mod.root, mod.file);
22-
this.dir = mod.root;
23-
this.name = path.basename(mod.file);
24-
this.parser = parser ? parser : new Parser();
25-
this.doc = this.parser.parse(mod.doc ? mod.doc : mod);
22+
this.filepath = path.join(doc.root, doc.filename);
23+
this.dir = doc.root;
24+
this.name = doc.filename;
25+
this.doc = this.parser.parse(doc);
2626
this.toc = new Toc();
2727
this.toc.perform(this.doc);
28+
// this.file = path.join(doc.root, doc.file);
29+
// this.dir = doc.root
30+
// this.name = path.basename(doc.file)
31+
// this.parser = parser ? parser : new Parser();
32+
// this.doc = this.parser.parse(doc.doc ? doc.doc : doc);
33+
// this.toc = new Toc();
34+
// this.toc.perform(this.doc);
2835
}
2936
title() {
3037
if (this.doc === undefined) {

dist/modules.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export class Modules {
55
this.mods = {};
66
}
77
add(mod) {
8-
this.mods[mod.file] = mod;
8+
this.mods[mod.filepath] = mod;
99
this.current = mod;
1010
return this.list();
1111
}

dist/node.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ export interface Node {
22
atom: string;
33
nodes: Node[];
44
type: string;
5-
file?: string;
5+
filename?: string;
66
toString(): string;
77
toHtml(): string;
88
}

0 commit comments

Comments
 (0)