diff --git a/README.md b/README.md index aafe913..8a59f9a 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ are likely to change, the implementation / API **will definitely** change! ;)_ without requiring setting up and maintaining a write-convert-embed workflow. - This was a requirement on the _ImageGrid.Viewer_ project and as a + This was a requirement on the _\ImageGrid.Viewer_ project and as a side-effect pWiki hosts it's own documentation too. - _Pluggable storage and synchronization_ mechanisms diff --git a/bootstrap.js b/bootstrap.js index 85ccffc..669a039 100755 --- a/bootstrap.js +++ b/bootstrap.js @@ -1,3 +1,3 @@ // This file is generated automatically, all changes made here will be lost. -var Bootstrap = {"Doc":{"text":"@include(./About)\r\n"},"Templates":{"text":"
\r\nXXX Genereal template description...\r\n
\r\n\r\n\r\n\t\t
@quote(./raw)\r\n\t\r\n
\r\n\r\nXXX Genereal template description...\r\n
\r\n\r\n\r\n\t\t
@quote(./raw)\r\n\t\r\n\r\n<pwiki-comment> ... </pwiki-comment>\r\n\r\nor\r\n\r\n\\@pwiki-comment( ... )\r\n\r\n\r\n\r\nThis will enable writing documents (mainly in _markdown_) that are usable \r\nbot from within pWiki as well as outside.\r\n\r\n\r\n## Macros\r\n\r\n### now ()\r\n\r\nGet current date in seconds since epoch, this is equivalet Javascript's\r\n`Date.now()`.\r\n\r\nThis is mostly used for automatically creating paths (see: todo / outline)\r\n\r\nThis is different from `$NOW` in path (see: Doc/Path) in that this gets \r\nthe date once per page load, i.e. the date changes on page load, while \r\n`$NOW` is set every time the path is used, i.e. on every click or script\r\nuse.\r\n\r\n**Example:**\r\n```\r\n\\@now()\r\n```\r\nWill produce: `@now()` \r\n\r\n_NOTE: when viewing from outside of pWiki, this should look like: `1471389217848`_\r\n\r\n\r\n\r\n### filter (name)\r\n\r\nEnable or disable a page filter.\r\n\r\nA filter is a way to transform the page source.\r\n\r\nArguments:\r\n- `name` -- filter name. If name is preceded with a '-' then it \r\nwill be forced off. This is useful for disabling _default_ filters, or \r\nfilters added previously in templates.\r\n\r\nFilters:\r\n- wikiword (default)\r\n- markdown\r\n\r\n**Example:**\r\n- `[./_edit]` -- _see the macro at the end of the page._\r\n\r\n\r\n\r\n### include (src isolated text)\r\n\r\nInclude a page. The included page is rendered independently from current\r\npage and is inserted as-is in macro body.\r\n\r\nNote that this will produce a `include` tag in the code that contains \r\nthe included page, this makes this tag not suitable for use anywhere \r\nbut an html element body.\r\n\r\nArguments:\r\n- `src` -- path to source page.\r\n- `isolated` -- prevent slots from included page from affecting the including page. \r\n- `text` -- is used when recursive include is detected and ignored otherwise.\r\n\r\n_For examples see `slot` macro exaples below._\r\n\r\n\r\n\r\n### source (src) / quote (src)\r\n\r\nInsert a page without rendering. This is similar to include but will not\r\nrender the page. \r\n\r\nThe difference between `source` and `quote` is:\r\n- _source_ includes the page as-is\r\n- _quotes_ escapes the page (i.e. _quotes_ it's source) for its code to \r\n display in the rendered HTML correctly.\r\n\r\nArguments:\r\n- `src` -- path to source page.\r\n\r\n**Example:**\r\n\r\n[Templates/\\_css] / [bootstrap css](bootstrap/Templates/_css.html):\r\n\r\n\r\n\r\n### slot (name text)\r\n\r\nDefine or fill a slot.\r\n\r\nFirst occurrence of a `name` will _define_ a slot and fill it with `text`.\r\nEach new occurrence of a name will change slot content.\r\n\r\n**Example:**\r\n\r\n[Templates/\\_view] / [bootstrap view](bootstrap/Templates/_view.html):\r\n```\r\n@source(Templates/_view)\r\n```\r\n\r\n[Templates/\\_edit] / [bootstrap edit](bootstrap/Templates/_edit.html):\r\n```\r\n@source(Templates/_edit)\r\n```\r\n\r\n\r\n### macro (name src sort) / else ()\r\n\r\nApply macro to source page and include the result.\r\n\r\nThis is similar to include but does not require a separate page.\r\n\r\nBoth `name` and `src` are optional.\r\n\r\nIf `name` is given a _named macro_ is defined. This macro can be later \r\nreferenced (used) by name. A named macro can be redefined/overridden.\r\n\r\nIf `src` is given a macro is applied to a specific page or range of pages\r\n(see: WikiPath).\r\n\r\nFor a macro to be useful it must have a body (`text`), either defined as\r\na named macro or in the current macro.\r\n\r\nArguments:\r\n- `name` -- macro name (optional).\r\n- `src` -- path to source page (optional).\r\n- `sort` -- space separated list of methods to use for item sorting\r\n\r\n\r\n`else` macro is applicable inside `macro`. it is used when the `src` path\r\nof `macro` matches no pages.\r\n\r\n**Example:**\r\n\r\n[Templates/pages] / [bootstrap pages](bootstrap/Templates/pages.html):\r\n```\r\n@source(Templates/pages)\r\n```\r\n\r\n\r\n\r\n\r\n"},"Doc/Path":{"text":"#  pWiki Path\r\n\r\nXXX a Wiki is a set of pages, mostly top level pages, mosty titled in\r\nWikiWord style, pWiki follows this culture but does not restrict either \r\npage nesting or title formatting. But following this style is recommended.\r\n\r\nXXX write a set of recommendations...\r\n\r\n\r\n\r\n## Basic terminology\r\n\r\n**Path** \r\n_One or more strings (or parts) separated by \"/\" that identifies a view._\r\n\r\nWe call the last _part_ in a path sequence a _title_.\r\n\r\nWe call the sub-path without the _title_ a _basedir_ or simply _dir_.\r\n\r\nIn pWiki, there is no distinction between a page and a _directory_, thus\r\nwe do not use the later term, instead, we may use the term _sub-page_.\r\n\r\nPaths are case sensitive.\r\n\r\n\r\n**Page** \r\n_A set of data associated with a path._\r\n\r\nA page is identified by it's path, but this does not require every\r\nsub-path of that path to exist -- the full path is the identifier, not\r\na sequence of path parts.\r\n\r\nSome pages are _bootstrapped_, i.e. are predefined in pWiki, these pages\r\ncan be overridden but can not be removed.\r\n\r\n\r\n**View** \r\n_A path that resolves to a page that may or may not be at that specific\r\npath._\r\n\r\nA _view's_ path may match that of a specific page or may not match any\r\npage directly, but any view will resolve to a page via the _acquisition \r\nprocess_\r\n\r\nAny page is a view, every view resolves to a page, but not every view \r\nis a page.\r\n\r\n(see: _Page acquisiton_ below)\r\n\r\n\r\n**WikiWord** \r\n_XXX_\r\n\r\n\r\n## Page acquisition\r\n\r\npWiki path system differs from how traditional file system paths are \r\nhandled. In pWiki if a path does not reference a page directly (i.e. \r\nit's a _view_), a search is conducted to find an alternative page. This \r\nsearch is called _page acquisition_.\r\n\r\n**Acquisition process:** \r\n_A set of rules defining how a page is retrieved via a path._\r\n\r\n\r\nThis is used as a simple and uniform mechanism to:\r\n- Get default pages for specific situations \r\n Like [Templates/EmptyPage] to handle the _page not found_ condition.\r\n- define generic templates/pages accessible by multiple pages in path \r\n A good example would be the viewer used to show this page [Templates/\\_view]\r\n and all of it's _chrome_ like the path in the header and links in the \r\n footer
\r\n+<pwiki-comment> ... </pwiki-comment> + +or + +\@pwiki-comment( ... ) ++ + +This will enable writing documents (mainly in _markdown_) that are usable +bot from within pWiki as well as outside. + ## Macros @@ -139,9 +162,10 @@ Arguments: **Example:** [Templates/\_css] / [bootstrap css](bootstrap/Templates/_css.html): -``` + ### slot (name text) diff --git a/wiki.js b/wiki.js index 0b2b876..db85686 100755 --- a/wiki.js +++ b/wiki.js @@ -48,6 +48,11 @@ var setWikiWords = function(text, show_brackets, skip){ .replace( Wiki.__wiki_link__, function(l){ + // check if wikiword is escaped... + if(l[0] == '\\'){ + return l.slice(1) + } + var path = l[0] == '[' ? l.slice(1, -1) : l var i = [].slice.call(arguments).slice(-2)[0] @@ -125,7 +130,9 @@ var macro = { macro: { "pwiki-comment": Macro('hide in pWiki', [], - function(context, elem, state){ return '' }), + function(context, elem, state){ + return '' + }), now: Macro('Create a now id', [], function(context, elem, state){ return ''+Date.now() }), @@ -570,6 +577,12 @@ var macro = { // get actual element content... var text = $('