mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-26 05:32:59 +00:00
Implement math expression parsing. Closes #61.
This commit is contained in:
parent
a2f867f3cb
commit
ba3b3609dd
5 changed files with 52 additions and 2 deletions
|
@ -6,6 +6,7 @@
|
||||||
- New pages show up with an 'N' next to them (as they do in a MediaWiki installation)
|
- New pages show up with an 'N' next to them (as they do in a MediaWiki installation)
|
||||||
- Page deletions show up in red with a line though them
|
- Page deletions show up in red with a line though them
|
||||||
- Uploads show with an arrow next to them along with the size of the uploaded file
|
- Uploads show with an arrow next to them along with the size of the uploaded file
|
||||||
|
- Added mathematical expression parsing between dollar signs.
|
||||||
|
|
||||||
# Changed
|
# Changed
|
||||||
- Enhanced the dev help page some more
|
- Enhanced the dev help page some more
|
||||||
|
|
|
@ -94,6 +94,7 @@ Key | Value | Explanation
|
||||||
`editing` | boolean | Determines whether editing is enabled. Set to false to disable disting for all users (anonymous or otherwise).
|
`editing` | boolean | Determines whether editing is enabled. Set to false to disable disting for all users (anonymous or otherwise).
|
||||||
`maxpagesize` | integer | The maximum number of characters allowed on a single page. The default is 135,000 characters, which is about 50 pages.
|
`maxpagesize` | integer | The maximum number of characters allowed on a single page. The default is 135,000 characters, which is about 50 pages.
|
||||||
`clean_raw_html`| boolean | Whether page sources should be cleaned of HTML before rendering. If set to true any raw HTML will be escaped before rendering. Note that this shouldn't affect code blocks - they should alwys be escaped. It is STRONGLY recommended that you keep this option turned on, **_ESPECIALLY_** if you allow anonymous edits as no sanitizing whatsoever is performed on the HTML. If you need a feature that the markdown parser doesn't have, please open an issue. Also note that some parsers may override this setting and escape HTML sequences anyway.
|
`clean_raw_html`| boolean | Whether page sources should be cleaned of HTML before rendering. If set to true any raw HTML will be escaped before rendering. Note that this shouldn't affect code blocks - they should alwys be escaped. It is STRONGLY recommended that you keep this option turned on, **_ESPECIALLY_** if you allow anonymous edits as no sanitizing whatsoever is performed on the HTML. If you need a feature that the markdown parser doesn't have, please open an issue. Also note that some parsers may override this setting and escape HTML sequences anyway.
|
||||||
|
`enable_math_rendering` | boolean | Whether to enable client side mathematical expression parsing. When enabled LaTeX mathematical expressions can be enclosed in dollar signs like so: `$x^2$`. Turn off if you don't use it.
|
||||||
`anonedits` | boolean | Determines whether users who aren't logged in are allowed to edit your wiki. Set to true to allow anonymous users to edit the wiki.
|
`anonedits` | boolean | Determines whether users who aren't logged in are allowed to edit your wiki. Set to true to allow anonymous users to edit the wiki.
|
||||||
`defaultpage` | string | The name of the page that will act as the home page for the wiki. This page will be served if the user didn't specify a page.
|
`defaultpage` | string | The name of the page that will act as the home page for the wiki. This page will be served if the user didn't specify a page.
|
||||||
`defaultaction` | action name | The default action. This action will be performed if no other action is specified. It is recommended you set this to "view" - that way the user automatically views the default page (see above).
|
`defaultaction` | action name | The default action. This action will be performed if no other action is specified. It is recommended you set this to "view" - that way the user automatically views the default page (see above).
|
||||||
|
|
|
@ -100,6 +100,11 @@ $settings->parser = "parsedown";
|
||||||
// STRONGLY recommended that you keep this option turned on.
|
// STRONGLY recommended that you keep this option turned on.
|
||||||
$settings->clean_raw_html = true;
|
$settings->clean_raw_html = true;
|
||||||
|
|
||||||
|
// Whether to enable client side rendering of methematical expressions.
|
||||||
|
// Math expressions should be enclosed inside of dollar signs ($).
|
||||||
|
// Turn off if you don't use it.
|
||||||
|
$settings->enable_math_rendering = true;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
///////////////////////////// Access and Security /////////////////////////////
|
///////////////////////////// Access and Security /////////////////////////////
|
||||||
|
@ -1035,7 +1040,7 @@ class page_renderer
|
||||||
"{sitename}" => $logo_html,
|
"{sitename}" => $logo_html,
|
||||||
"v0.11-dev" => $version,
|
"v0.11-dev" => $version,
|
||||||
"{favicon-url}" => $settings->favicon,
|
"{favicon-url}" => $settings->favicon,
|
||||||
"{header-html}" => self::get_css_as_html(),
|
"{header-html}" => self::get_header_html(),
|
||||||
|
|
||||||
"{navigation-bar}" => self::render_navigation_bar($settings->nav_links, $settings->nav_links_extra, "top"),
|
"{navigation-bar}" => self::render_navigation_bar($settings->nav_links, $settings->nav_links_extra, "top"),
|
||||||
"{navigation-bar-bottom}" => self::render_navigation_bar($settings->nav_links_bottom, [], "bottom"),
|
"{navigation-bar-bottom}" => self::render_navigation_bar($settings->nav_links_bottom, [], "bottom"),
|
||||||
|
@ -1084,6 +1089,25 @@ class page_renderer
|
||||||
return self::render($title, $content, self::$minimal_content_template);
|
return self::render($title, $content, self::$minimal_content_template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function get_header_html()
|
||||||
|
{
|
||||||
|
global $settings;
|
||||||
|
$result = self::get_css_as_html();
|
||||||
|
|
||||||
|
if(!empty($settings->enable_math_rendering))
|
||||||
|
$result .= "<script type='text/x-mathjax-config'>
|
||||||
|
MathJax.Hub.Config({
|
||||||
|
tex2jax: {
|
||||||
|
inlineMath: [ ['$','$'], ['\\\\(','\\\\)'] ],
|
||||||
|
processEscapes: true,
|
||||||
|
skipTags: ['script','noscript','style','textarea','pre','code']
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script async src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML'></script>";
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
public static function get_css_as_html()
|
public static function get_css_as_html()
|
||||||
{
|
{
|
||||||
global $settings;
|
global $settings;
|
||||||
|
|
21
core.php
21
core.php
|
@ -650,7 +650,7 @@ class page_renderer
|
||||||
"{sitename}" => $logo_html,
|
"{sitename}" => $logo_html,
|
||||||
"{version}" => $version,
|
"{version}" => $version,
|
||||||
"{favicon-url}" => $settings->favicon,
|
"{favicon-url}" => $settings->favicon,
|
||||||
"{header-html}" => self::get_css_as_html(),
|
"{header-html}" => self::get_header_html(),
|
||||||
|
|
||||||
"{navigation-bar}" => self::render_navigation_bar($settings->nav_links, $settings->nav_links_extra, "top"),
|
"{navigation-bar}" => self::render_navigation_bar($settings->nav_links, $settings->nav_links_extra, "top"),
|
||||||
"{navigation-bar-bottom}" => self::render_navigation_bar($settings->nav_links_bottom, [], "bottom"),
|
"{navigation-bar-bottom}" => self::render_navigation_bar($settings->nav_links_bottom, [], "bottom"),
|
||||||
|
@ -699,6 +699,25 @@ class page_renderer
|
||||||
return self::render($title, $content, self::$minimal_content_template);
|
return self::render($title, $content, self::$minimal_content_template);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function get_header_html()
|
||||||
|
{
|
||||||
|
global $settings;
|
||||||
|
$result = self::get_css_as_html();
|
||||||
|
|
||||||
|
if(!empty($settings->enable_math_rendering))
|
||||||
|
$result .= "<script type='text/x-mathjax-config'>
|
||||||
|
MathJax.Hub.Config({
|
||||||
|
tex2jax: {
|
||||||
|
inlineMath: [ ['$','$'], ['\\\\(','\\\\)'] ],
|
||||||
|
processEscapes: true,
|
||||||
|
skipTags: ['script','noscript','style','textarea','pre','code']
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<script async src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_CHTML'></script>";
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
public static function get_css_as_html()
|
public static function get_css_as_html()
|
||||||
{
|
{
|
||||||
global $settings;
|
global $settings;
|
||||||
|
|
|
@ -97,6 +97,11 @@ $settings->parser = "parsedown";
|
||||||
// STRONGLY recommended that you keep this option turned on.
|
// STRONGLY recommended that you keep this option turned on.
|
||||||
$settings->clean_raw_html = true;
|
$settings->clean_raw_html = true;
|
||||||
|
|
||||||
|
// Whether to enable client side rendering of methematical expressions.
|
||||||
|
// Math expressions should be enclosed inside of dollar signs ($).
|
||||||
|
// Turn off if you don't use it.
|
||||||
|
$settings->enable_math_rendering = true;
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
///////////////////////////// Access and Security /////////////////////////////
|
///////////////////////////// Access and Security /////////////////////////////
|
||||||
|
|
Loading…
Reference in a new issue