Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/nikola
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d6c2efb61ad1
Choose a base ref
...
head repository: getnikola/nikola
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 55f6670d0ffd
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Apr 13, 2017

  1. Warn if user has KaTeX CSS in conf.py

    h/t @felixfontein
    
    Signed-off-by: Chris Warrick <kwpolska@gmail.com>
    Kwpolska committed Apr 13, 2017
    Copy the full SHA
    7fd9548 View commit details
  2. Update math docs and config examples

    Signed-off-by: Chris Warrick <kwpolska@gmail.com>
    Kwpolska committed Apr 13, 2017
    Copy the full SHA
    55f6670 View commit details
Showing with 54 additions and 27 deletions.
  1. +42 −19 docs/manual.txt
  2. +7 −8 nikola/conf.py.in
  3. +5 −0 nikola/nikola.py
61 changes: 42 additions & 19 deletions docs/manual.txt
Original file line number Diff line number Diff line change
@@ -1948,33 +1948,53 @@ Math

Nikola supports math input via MathJax (by default) or KaTeX. It is activated
via the math roles and directives of reStructuredText and the usual LaTeX
delimiters (backslash-parentheses, backslash-brackets) for other input formats.
delimiters for other input formats.

Configuration
-------------

Nikola uses MathJax by default. If you want to use KaTeX (faster and prettier,
but may not support every feature yet), set ``USE_KATEX = True`` in
``conf.py``.

To use mathematics in a post, you **must** add the ``mathjax`` tag, no matter
which renderer you are using. (Exception: posts that are Jupyter Notebooks are
automatically marked as math)

We **DO NOT** support the old, deprecated and error-prone ``$inline$``
delimiters by default. If you want to use them, please add them manually,
like this:
By default, Nikola will accept ``\(.\)`` for inline math; ``\[.\]`` and
``$$.$$`` for display math. If you want to use the old ``$..$`` syntax as well
(which may conflict with running text!), you need to use special config for
your renderer:

.. code:: python

MATHJAX_CONFIG = """
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\\(","\\\)"] ],
displayMath: [ ['$$','$$'], ["\\\[","\\\]"] ],
processEscapes: true
},
displayAlign: 'left', // Change this to 'center' to center equations.
"HTML-CSS": {
styles: {'.MathJax_Display': {"margin": 0}}
}
});
</script>
"""
MATHJAX_CONFIG = """
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {
inlineMath: [ ['$','$'], ["\\\(","\\\)"] ],
displayMath: [ ['$$','$$'], ["\\\[","\\\]"] ],
processEscapes: true
},
displayAlign: 'center', // Change this to 'left' if you want left-aligned equations.
"HTML-CSS": {
styles: {'.MathJax_Display': {"margin": 0}}
}
});
</script>
"""

KATEX_AUTO_RENDER = """
delimiters: [
{left: "$$", right: "$$", display: true},
{left: "\\\[", right: "\\\]", display: true},
{left: "$", right: "$", display: false},
{left: "\\\(", right: "\\\)", display: false}
]
"""

Inline usage
------------

Inline mathematics are produced using the reST `math` **role** or the LaTeX
backslash-parentheses delimiters:
@@ -1997,6 +2017,9 @@ Note that some input formats (including Markdown) require using **double
backslashes** in the delimiters (``\\(inline math\\)``). Please check your
output first before reporting bugs.

Display usage
-------------

Display mathematics are produced using the reST `math` **directive** or the
LaTeX backslash-brackets delimiters:

15 changes: 7 additions & 8 deletions nikola/conf.py.in
Original file line number Diff line number Diff line change
@@ -953,9 +953,8 @@ PRETTY_URLS = ${PRETTY_URLS}
# Do you want a add a Mathjax config file?
# MATHJAX_CONFIG = ""

# If you are using Jupyter Notebooks, or want support for the $.$
# syntax (not recommended due to confusion with running text!), just add this
# one:
# If you want support for the $.$ syntax (wihch may conflict with running
# text!), just use this config:
# MATHJAX_CONFIG = """
# <script type="text/x-mathjax-config">
# MathJax.Hub.Config({
@@ -964,20 +963,20 @@ PRETTY_URLS = ${PRETTY_URLS}
# displayMath: [ ['$$','$$'], ["\\\[","\\\]"] ],
# processEscapes: true
# },
# displayAlign: 'left', // Change this to 'center' to center equations.
# displayAlign: 'center', // Change this to 'left' if you want left-aligned equations.
# "HTML-CSS": {
# styles: {'.MathJax_Display': {"margin": 0}}
# }
# });
# </script>
# """

# Want to use KaTeX instead of MathJax? While KaTeX is less featureful,
# it's faster and the output looks better.
# Want to use KaTeX instead of MathJax? While KaTeX may not support every
# feature yet, it's faster and the output looks better.
# USE_KATEX = False

# If you want to use the old (buggy) inline math $.$ with KaTeX, then
# you might want to use this config.
# KaTeX auto-render settings. If you want support for the $.$ syntax (wihch may
# conflict with running text!), just use this config:
# KATEX_AUTO_RENDER = """
# delimiters: [
# {left: "$$", right: "$$", display: true},
5 changes: 5 additions & 0 deletions nikola/nikola.py
Original file line number Diff line number Diff line change
@@ -828,6 +828,11 @@ def __init__(self, **config):
utils.LOGGER.warn('The moot comment system has been renamed to muut by the upstream. Setting COMMENT_SYSTEM to "muut".')
self.config['COMMENT_SYSTEM'] = 'muut'

# Detect manually added KaTeX CSS (#2715/#2717)
# TODO: remove on v8
if 'katex.min.css' in self.config.get('EXTRA_HEAD_DATA', ''):
utils.LOGGER.warn("KaTeX CSS is now added by Nikola whenever needed (if your theme supports it). Please remove katex.min.css from EXTRA_HEAD_DATA in conf.py.")

# Handle old plugin names (from before merging the taxonomy PR #2535)
for old_plugin_name, new_plugin_names in TAXONOMY_COMPATIBILITY_PLUGIN_NAME_MAP.items():
if old_plugin_name in self.config['DISABLED_PLUGINS']: