aboutsummaryrefslogtreecommitdiff
path: root/wiki-markup.el
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2023-07-23 23:05:13 +1000
committerYuchen Pei <id@ypei.org>2023-07-23 23:05:13 +1000
commitf2d3c6ca51bfbf7620ddde9faf83ec5fd973abf5 (patch)
tree625166378b99cac24ddcd36e0cbf6c04fee37d1e /wiki-markup.el
parent38ca3c5e5a075f15732f38a674666fa6db4b63f5 (diff)
Add a mediawiki API fetcher.
Applicable to wikihow. Also clean up the code to reduce duplication with fetching and finding files. And fix when the wiki entry is under a directory naming itself which is common in mediawiki: both foo and foo/bar could be a valid wiki title. So locally files need to have an extension (by default .wiki). Also add the extension to auto-mode-alist.
Diffstat (limited to 'wiki-markup.el')
-rw-r--r--wiki-markup.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/wiki-markup.el b/wiki-markup.el
index 4809695..61cdca8 100644
--- a/wiki-markup.el
+++ b/wiki-markup.el
@@ -90,8 +90,13 @@ This can be overriden with .dir-locals.el."
(unless wiki-site
(setq-local wiki-site
(let ((guessed
- (intern (file-name-base
- (directory-file-name default-directory)))))
+ (intern (replace-regexp-in-string
+ (format
+ "%s/\\(.+?\\)/.*"
+ (regexp-quote
+ (expand-file-name wiki-local-dir)))
+ "\\1"
+ default-directory))))
(if (alist-get guessed wiki-sites)
guessed
'local))))