Skip to content

Commit

Permalink
Fixed the issue when mathjax replaced (some-text) in nodes outside po…
Browse files Browse the repository at this point in the history
…st content.
  • Loading branch information
svetlyak40wt committed May 8, 2024
1 parent 3a88f8d commit 7e5f082
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 18 deletions.
8 changes: 8 additions & 0 deletions example/blog/math-example.post
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
;;;;;
title: Math Example
tags: plugin,math
created-at: 2024-05-09 10:00
format: md
;;;;;

When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are \[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]
5 changes: 1 addition & 4 deletions example/blog/second.post
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
;;;;;
title: Github Actions Badger
tags: project, math
tags: project
created-at: 2024-04-05 10:00
format: md
;;;;;

When \(a \ne 0\), there are two solutions to \(ax^2 + bx + c = 0\) and they are
\[x = {-b \pm \sqrt{b^2-4ac} \over 2a}.\]

Сегодня расскажу ещё про один мой проект, который так и не превратился в продукт. Правда в отличие от 12forks.com, этот проект жив до сих пор. Проект связан с GitHub и полезен тем, кто развивает фреймворк или библиотеку, предназначенную для разных платформ, языков программирования или операционных систем.

<!--more-->
Expand Down
13 changes: 12 additions & 1 deletion src/plugins/mathjax.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@
(in-package #:staticl/plugins/mathjax)


;; Here we explicitly tell MathJax to work only inside "content" and "excerpt"
;; HTML nodes, because "staticl-page" class should be on each "body" node
;; in StatiCL themes.
(defparameter *code-to-inject* "
<script>
MathJax = {
options: {
ignoreHtmlClass: 'staticl-page',
processHtmlClass: 'content|excerpt'
},
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)'], ['\\[', '\\]']]
},
Expand All @@ -28,8 +35,12 @@ MathJax = {
<script src='https://polyfill.io/v3/polyfill.min.js?features=es6'></script>
<script id='MathJax-script' async src='https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'></script>
")

"
"


(defclass mathjax (plugin)
((force :initarg :force
Expand Down Expand Up @@ -57,5 +68,5 @@ MathJax = {
when (and (typep item 'content-with-injections-mixin)
(or (force-mathjax-p node)
(has-tag-p item (math-tag-name node))))
do (add-injection item "head"
do (add-injection item "after_content"
*code-to-inject*)))
5 changes: 4 additions & 1 deletion src/server.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#:autoreload))
(in-package #:staticl/server)

(defvar *port* nil)
(defvar *app* nil)
(defvar *server* nil)
(defvar *thread* nil)
Expand Down Expand Up @@ -188,6 +189,7 @@
:address interface)))
(url (format nil "http://~A:~A/"
interface port)))
(setf *port* port)
(open-browser url)

(labels ((build-site (changed-file)
Expand Down Expand Up @@ -229,7 +231,8 @@
(defun stop ()
(when *server*
(clack:stop *server*)
(setf *server* nil))
(setf *server* nil)
(setf *port* nil))
(when *thread*
(when (thread-alive-p *thread*)
(destroy-thread *thread*))
Expand Down
2 changes: 1 addition & 1 deletion themes/hyde/base.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{/foreach}
{/if}
</head>
<body>
<body class="staticl-page">
<div class="navigation">
<a href="/">{$site.title}</a> |
{foreach $link in $site.navigation.items}
Expand Down
6 changes: 3 additions & 3 deletions themes/hyde/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ a.anchor { color: black }
.title { margin-left: 1em }
.article-meta { margin-left: 2.2em; margin-bottom: 2.2em }
.archive-title { font-size: 1em } .article-title { font-size: 2em }
.article-content { margin-left: 2.2em }
.content { margin-left: 2.2em }
.fineprint { font-size: .9em; margin-top: .5em; display: flex; flex-direction: column}
.fineprint > hr {width: 100%}
.fineprint-items {display: flex; gap: 2rem; justify-content: center; align-items: center;}
Expand Down Expand Up @@ -64,15 +64,15 @@ span.paren6:hover { color : inherit; background-color : #FFBAFF; }
margin-bottom: 1em;
}

.article-meta, .article-content {
.article-meta, .content {
float: left;
margin-left: 0em;
margin-right: 0em;
width: 90%;
padding-left: 5%;
}

.article, .article-content {
.excerpt, .content {
margin-left: 0em;
text-align: justify;
}
Expand Down
2 changes: 1 addition & 1 deletion themes/hyde/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="article-meta">
<a class="article-title" href="{$obj.url}">{$obj.title}</a>
<div class="date"> posted on {$obj.created_at | date}</div>
<div class="article">{$obj.excerpt |noAutoescape}</div>
<div class="excerpt">{$obj.excerpt |noAutoescape}</div>
{if $obj.has_more}<p><a href="{$obj.url}">Read more...</a></p>{/if}
</div>
{/foreach}
Expand Down
2 changes: 1 addition & 1 deletion themes/hyde/post.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{/if}
</div>{\n}
</div>{\n}
<div class="article-content">{\n}
<div class="content">{\n}
{$content.html |noAutoescape}
</div>{\n}
<div class="relative-nav">{\n}
Expand Down
2 changes: 1 addition & 1 deletion themes/readable/base.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{/foreach}
{/if}
</head>
<body>
<body class="staticl-page">
<div class="container-fluid">
<div class="row-fluid">
<div class="offset2 span8">
Expand Down
4 changes: 2 additions & 2 deletions themes/readable/index.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
{template index}
<h1 class="page-header">{$content.title}</h1>
{foreach $obj in $content.items}
<div class="row-fluid">
<h1><a href="{$obj.url}">{$obj.title}</a></h1>
<div class="row-fluid excerpt">
<h2><a href="{$obj.url}">{$obj.title}</a></h2>
<p class="date-posted">posted on {$obj.created_at | date}</p>
{$obj.excerpt |noAutoescape}

Expand Down
6 changes: 3 additions & 3 deletions themes/readable/post.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{namespace coleslaw.theme.readable}

{template post}
<div class="row-fluid">{\n}
<div class="row-fluid content">{\n}
<h1 class="page-header">{$content.title}</h1>{\n}
<p>
{if $content.tags}
Expand All @@ -12,8 +12,8 @@
{/if}
</p>
<p class="date-posted">
{if $content.date}
Written on {$content.date}
{if $content.created_at}
Written on {$content.created_at | date}
{/if}
</p>

Expand Down

0 comments on commit 7e5f082

Please sign in to comment.