diff --git a/pwiki/page.js b/pwiki/page.js index a80205e..fac307c 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -838,8 +838,9 @@ object.Constructor('Page', BasePage, { // -> () // -> ... // + // XXX do we need to make .macro.__proto__ module level object??? // XXX ASYNC make these support async page getters... - macros: { + macros: { __proto__: { // // @([ ][ local]) // @(name=[ default=][ local]) @@ -855,6 +856,7 @@ object.Constructor('Page', BasePage, { // - .renderer // - .root // + // NOTE: default value is parsed when accessed... arg: Macro( ['name', 'default', ['local']], function(args){ @@ -868,7 +870,8 @@ object.Constructor('Page', BasePage, { args.name : v return v - || args.default }), + || (args.default + && this.parse(args.default)) }), '': Macro( ['name', 'default', ['local']], function(args){ @@ -887,6 +890,7 @@ object.Constructor('Page', BasePage, { // // | - // + // XXX REVISE... filter: function(args, body, state, expand=true){ var that = this @@ -1299,6 +1303,9 @@ object.Constructor('Page', BasePage, { 'content': ['slot'], // XXX EXPERIMENTAL... + // + // NOTE: var value is parsed only on assignment and not on dereferencing... + // // XXX INC_DEC do we need inc/dec and parent??? 'var': Macro( ['name', 'text', @@ -1616,7 +1623,23 @@ object.Constructor('Page', BasePage, { // nesting rules... 'else': ['macro'], 'join': ['macro'], - }, + } }, + + // XXX EXPERIMENTAL... + // + // Define a global macro... + // .defmacro(, ) + // .defmacro(, , ) + // -> this + // + // XXX do we need this??? + defmacro: function(name, args, func){ + this.macros[name] = + arguments.length == 2 ? + arguments[1] + : Macro(args, func) + return this }, + // direct actions... // @@ -2413,8 +2436,8 @@ module.System = { text: object.doc`
-
ParseError: @(msg)
- Page: [@(path)] +
ParseError: @(msg "no message")
+ Page: [@(path "@source(./path)")]
`,}, RecursionError: { text: 'RECURSION ERROR: @source(../path)' }, diff --git a/pwiki/parser.js b/pwiki/parser.js index b0d46bc..397c89e 100755 --- a/pwiki/parser.js +++ b/pwiki/parser.js @@ -256,7 +256,7 @@ module.BaseParser = { // XXX should this be cached??? var macro_pattern = this.MACRO_PATTERN - ?? this.buildMacroPattern(Object.keys(page.macros)) + ?? this.buildMacroPattern(Object.deepKeys(page.macros)) var macro_pattern_groups = this.MACRO_PATTERN_GROUPS ?? this.countMacroPatternGroups() var macro_args_pattern = this.MACRO_ARGS_PATTERN @@ -482,7 +482,7 @@ module.BaseParser = { // XXX add line number and page path... '@include("./ParseError' +':path=' - // XXX use pwiki.encodeElem(..) ??? + // XXX use pwpath.encodeElem(..) ??? + page.path +':msg=' + err.message diff --git a/pwiki2.html b/pwiki2.html index a77e17a..de1a8cf 100755 --- a/pwiki2.html +++ b/pwiki2.html @@ -158,7 +158,7 @@ body.loading .page.spinner span { .error { background: lightyellow; padding: 1em; - box-shadow: inset 3px 5px 15px 5px rgba(0,0,0,0.05); + box-shadow: inset 3px 5px 15px 5px rgba(0,0,0,0.03); border: dashed red 1px; } diff --git a/pwiki2.js b/pwiki2.js index d81716c..e7c0742 100755 --- a/pwiki2.js +++ b/pwiki2.js @@ -36,8 +36,9 @@ * - * * -* XXX BUG? can't use < and > (both?) in page title... * XXX parser: error handling: revise page quoting... +* ...need a standard mechanism to quote urls, url-args and paths... +* XXX BUG? can't use < and > (both?) in page title... * XXX parser: error handling: add line number + context... (???) * XXX BUG: parser: * This will break: @@ -45,6 +46,9 @@ * This will not: * await pwiki.parse('@source(.)') * XXX ASAP test: can we store the file handler with permissions in a ServiceWorker?? +* XXX Q: do we need macros for printing errors and the like??? +* XXX Q: do we need a macro to define user macros??? +* ...see: .defmacro(..) * XXX the parser should handle all action return values, including: * - lists -- XXX * - strings -- DONE