fix additional javascript problems, and try to make the highlighting more attractive

This commit is contained in:
Greg Gauthier 2021-04-03 18:15:27 +01:00
parent d13151eabf
commit 48dd51960f
4 changed files with 30 additions and 10 deletions

View File

@ -16,8 +16,9 @@ paginate = 10
[params] [params]
subtitle = "A Journal" subtitle = "A Journal"
brand = "<img src=\"/img/ipse-solus-logo.png\" alt=\"\"/><br/> <center>Ipse Solus</center>" brand = "<img src=\"/img/ipse-solus-logo.png\" alt=\"\"/><br/> <center>Ipse Solus</center>"
highlightjs = "androidstudio" highlightjs = "tomorrow"
highlightjs_extra_languages = ["yaml", "xml-dtd"] highlightjs_extra_languages = ["yaml"]
custom_js = ["js/math-code.js"]
dateFormat = "02 Jan 2006, 15:04" dateFormat = "02 Jan 2006, 15:04"
[menu] [menu]

View File

@ -10,11 +10,11 @@ Here's a snippet of Go.
```go ```go
func str2int(strnum string) int { func str2int(strnum string) int {
i, err := strconv.Atoi(strnum) i, err := strconv.Atoi(strnum)
if err != nil { if err != nil {
return 9999 return 9999
} }
return i return i
} }
``` ```

View File

@ -10,7 +10,7 @@ Unfortunately, out of the box, it wasn't working. I tried all sorts of suggestio
Then, after a day of staring blankly at the problem, I suddenly realized what was wrong. There was a simple `regex` typo in the htaccess configuration that came from nextcloud. Let's see if you can see the difference. Here's what nextcloud gives you: Then, after a day of staring blankly at the problem, I suddenly realized what was wrong. There was a simple `regex` typo in the htaccess configuration that came from nextcloud. Let's see if you can see the difference. Here's what nextcloud gives you:
```xml ```apache
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
RewriteEngine on RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} DavClnt RewriteCond %{HTTP_USER_AGENT} DavClnt
@ -27,7 +27,7 @@ Then, after a day of staring blankly at the problem, I suddenly realized what wa
and here is what I ended up running successfully with: and here is what I ended up running successfully with:
```xml ```apache
<IfModule mod_rewrite.c> <IfModule mod_rewrite.c>
RewriteEngine on RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} DavClnt RewriteCond %{HTTP_USER_AGENT} DavClnt
@ -45,4 +45,3 @@ and here is what I ended up running successfully with:
Can you see it? Hint: RewriteRules require leading forward-slashes to work. But REGEX rules require leading back-slashes to escape special characters in uris. So, I had to change this `^\.` to this `^/\.` and everything started working. Can you see it? Hint: RewriteRules require leading forward-slashes to work. But REGEX rules require leading back-slashes to escape special characters in uris. So, I had to change this `^\.` to this `^/\.` and everything started working.
Hopefully, for those of you into self-hosting, this will save you the hours of pain and suffering it cost me. Hopefully, for those of you into self-hosting, this will save you the hours of pain and suffering it cost me.

20
static/js/math-code.js Normal file
View File

@ -0,0 +1,20 @@
(function() {
var i, text, code, codes = document.getElementsByTagName('code');
for (i = 0; i < codes.length;) {
code = codes[i];
if (code.parentNode.tagName !== 'PRE' && code.childElementCount === 0) {
text = code.textContent;
if (/^\$[^$]/.test(text) && /[^$]\$$/.test(text)) {
text = text.replace(/^\$/, '\\(').replace(/\$$/, '\\)');
code.textContent = text;
}
if (/^\\\((.|\s)+\\\)$/.test(text) || /^\\\[(.|\s)+\\\]$/.test(text) ||
/^\$(.|\s)+\$$/.test(text) ||
/^\\begin\{([^}]+)\}(.|\s)+\\end\{[^}]+\}$/.test(text)) {
code.outerHTML = code.innerHTML; // remove <code></code>
continue;
}
}
i++;
}
})();