diff options
-rw-r--r-- | wiki-engine.el | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/wiki-engine.el b/wiki-engine.el index 804f439..5cd666b 100644 --- a/wiki-engine.el +++ b/wiki-engine.el @@ -85,6 +85,7 @@ And switch to the corresponding buffer." (when (plist-get status :error) (error "Wiki fetch failed: %s" (plist-get status :error))) (wiki-delete-http-header) + (call-interactively 'delete-trailing-whitespace) (let ((to-insert (buffer-string)) (_ (kill-buffer))) (wiki-save-string-and-switch to-insert title dir))) @@ -144,6 +145,7 @@ And switch to the corresponding buffer." ('mediawiki (format "%s/%s?action=raw" base-url title)) ('moinmoin (format "%s/%s?action=raw" base-url title)) ('oddmuse (format "%s?action=download;id=%s" base-url title)) + ('custom (format (plist-get site-info :wiki-url-format) base-url title)) (_ (error "Unknown engine: %s" engine))))) (defun wiki-engine-simple-fetch (site-id title) @@ -157,7 +159,8 @@ and if the title cannot be found locally, fetch remotely." (found-local (when (or wiki-fetch-prefer-local (eq engine 'local)) (wiki-find-file title (wiki-locate-dir site-id) - (eq engine 'local))))) + (eq engine 'local)))) + (post-proc (plist-get (alist-get site-id wiki-sites) :fetch-post-proc))) (if found-local (switch-to-buffer found-local) (wiki-fetch-url @@ -167,7 +170,8 @@ and if the title cannot be found locally, fetch remotely." (lambda () (wiki-mode) (setq-local wiki-site site-id - wiki-title title)))))) + wiki-title title) + (when post-proc (funcall post-proc))))))) (defun wiki-engine-mediawiki-api-wiki (api-base-url title) "Fetch the wikitext of TITLE using json api. @@ -336,9 +340,11 @@ If URL points to html title, open the corresponding raw title." wiki-sites))) (pcase-let ((`(,site-id . ,site-info) found-site)) (funcall (wiki-site-fetcher site-id) - (string-remove-prefix - (format "%s/" (wiki-engine-compute-base-url site-info)) - url)))) + (string-remove-suffix + "/" + (string-remove-prefix + (format "%s/" (wiki-engine-compute-base-url site-info)) + url))))) ) (provide 'wiki-engine) |