From 62b4f8649220b5beac3d0e40c851ce7c996ba0c4 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 6 Oct 2022 22:48:09 +0300 Subject: [PATCH] more experimenting... Signed-off-by: Alex A. Naanou --- pwiki/page.js | 27 +++++++++++++++++++++++++++ pwiki2.html | 12 +++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/pwiki/page.js b/pwiki/page.js index 2c81258..0d1020c 100755 --- a/pwiki/page.js +++ b/pwiki/page.js @@ -1594,6 +1594,33 @@ object.Constructor('Page', BasePage, { +//--------------------------------------------------------------------- +// Markdown renderer... +// XXX EXPERIMENTAL... + +var showdown = require('showdown') + +var MarkdownPage = +module.MarkdownPage = +object.Constructor('MarkdownPage', Page, { + actions: { + ...module.Page.prototype.actions, + + html: true, + }, + + markdown: new showdown.Converter(), + + get html(){ return async function(){ + return this.markdown.makeHtml(await this.raw) }.call(this) }, + set html(value){ + this.raw = this.markdown.makeMarkdown(value) }, +}) + +// XXX HACK... +var Page = MarkdownPage + + //--------------------------------------------------------------------- // Cached .text page... diff --git a/pwiki2.html b/pwiki2.html index ea7116a..a5338f9 100755 --- a/pwiki2.html +++ b/pwiki2.html @@ -23,6 +23,16 @@ + + + + + + +