Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for latex preamble #677

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/out/404.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charSet="utf-8" class="next-head"/><link rel="preload" href="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/404.js" as="script"/><link rel="preload" href="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/_app.js" as="script"/><link rel="preload" href="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/_error.js" as="script"/><link rel="preload" href="/_next/static/runtime/webpack-2ef50c24cc8d478adafc.js" as="script"/><link rel="preload" href="/_next/static/chunks/commons.eb02219a61ab5016dbbe.js" as="script"/><link rel="preload" href="/_next/static/runtime/main-3978781480e8c13aefab.js" as="script"/></head><body><div id="__next"><div data-reactroot="">404</div></div><script>__NEXT_DATA__ = {"props":{"pageProps":{}},"page":"/404","query":{},"buildId":"s7O4q0ISzv1r8jtwIkXLb","nextExport":true};__NEXT_LOADED_PAGES__=[];__NEXT_REGISTER_PAGE=function(r,f){__NEXT_LOADED_PAGES__.push([r, f])}</script><script async="" id="__NEXT_PAGE__/404" src="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/404.js"></script><script async="" id="__NEXT_PAGE__/_app" src="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/_app.js"></script><script async="" id="__NEXT_PAGE__/_error" src="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/_error.js"></script><script src="/_next/static/runtime/webpack-2ef50c24cc8d478adafc.js" async=""></script><script src="/_next/static/chunks/commons.eb02219a61ab5016dbbe.js" async=""></script><script src="/_next/static/runtime/main-3978781480e8c13aefab.js" async=""></script></body></html>
<!DOCTYPE html><html><head><meta charSet="utf-8" class="next-head"/><link rel="preload" href="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/404.js" as="script"/><link rel="preload" href="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/_app.js" as="script"/><link rel="preload" href="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/_error.js" as="script"/><link rel="preload" href="/_next/static/runtime/webpack-2ef50c24cc8d478adafc.js" as="script"/><link rel="preload" href="/_next/static/chunks/commons.eb02219a61ab5016dbbe.js" as="script"/><link rel="preload" href="/_next/static/runtime/main-3978781480e8c13aefab.js" as="script"/></head><body><div id="__next"><div data-reactroot="">404</div></div><script>__NEXT_DATA__ = {"props":{"pageProps":{}},"page":"/404","query":{},"buildId":"FkkSF_dNiGxHgj6cjrt8V","nextExport":true};__NEXT_LOADED_PAGES__=[];__NEXT_REGISTER_PAGE=function(r,f){__NEXT_LOADED_PAGES__.push([r, f])}</script><script async="" id="__NEXT_PAGE__/404" src="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/404.js"></script><script async="" id="__NEXT_PAGE__/_app" src="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/_app.js"></script><script async="" id="__NEXT_PAGE__/_error" src="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/_error.js"></script><script src="/_next/static/runtime/webpack-2ef50c24cc8d478adafc.js" async=""></script><script src="/_next/static/chunks/commons.eb02219a61ab5016dbbe.js" async=""></script><script src="/_next/static/runtime/main-3978781480e8c13aefab.js" async=""></script></body></html>

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/out/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><html><head><meta charSet="utf-8" class="next-head"/><title class="next-head"></title><link rel="shortcut icon" type="image/ico" href="/_static/favicon.ico" class="next-head"/><link rel="stylesheet" href="/_static/page.css" class="next-head"/><link rel="stylesheet" href="/_static/markdown.css" class="next-head"/><link rel="stylesheet" href="/_static/highlight.css" class="next-head"/><link rel="stylesheet" href="/_static/[email protected]" class="next-head"/><link rel="stylesheet" href="/_static/sequence-diagram-min.css" class="next-head"/><script type="text/javascript" src="/_static/underscore-min.js" class="next-head"></script><script type="text/javascript" src="/_static/webfont.js" class="next-head"></script><script type="text/javascript" src="/_static/snap.svg.min.js" class="next-head"></script><script type="text/javascript" src="/_static/tweenlite.min.js" class="next-head"></script><script type="text/javascript" src="/_static/mermaid.min.js" class="next-head"></script><script type="text/javascript" src="/_static/sequence-diagram-min.js" class="next-head"></script><script type="text/javascript" src="/_static/[email protected]" class="next-head"></script><script type="text/javascript" src="/_static/mhchem.min.js" class="next-head"></script><script type="text/javascript" src="/_static/[email protected]" class="next-head"></script><script type="text/javascript" src="/_static/[email protected]" class="next-head"></script><script type="text/javascript" src="/_static/viz.js" class="next-head"></script><script type="text/javascript" src="/_static/full.render.js" class="next-head"></script><link rel="preload" href="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/index.js" as="script"/><link rel="preload" href="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/_app.js" as="script"/><link rel="preload" href="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/_error.js" as="script"/><link rel="preload" href="/_next/static/runtime/webpack-2ef50c24cc8d478adafc.js" as="script"/><link rel="preload" href="/_next/static/chunks/commons.eb02219a61ab5016dbbe.js" as="script"/><link rel="preload" href="/_next/static/runtime/main-3978781480e8c13aefab.js" as="script"/></head><body><div id="__next"><main data-theme=""><div id="page-ctn" contenteditable="false"><section class="markdown-body"></section></div></main></div><script>__NEXT_DATA__ = {"props":{"pageProps":{}},"page":"/","query":{},"buildId":"s7O4q0ISzv1r8jtwIkXLb","nextExport":true};__NEXT_LOADED_PAGES__=[];__NEXT_REGISTER_PAGE=function(r,f){__NEXT_LOADED_PAGES__.push([r, f])}</script><script async="" id="__NEXT_PAGE__/" src="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/index.js"></script><script async="" id="__NEXT_PAGE__/_app" src="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/_app.js"></script><script async="" id="__NEXT_PAGE__/_error" src="/_next/static/s7O4q0ISzv1r8jtwIkXLb/pages/_error.js"></script><script src="/_next/static/runtime/webpack-2ef50c24cc8d478adafc.js" async=""></script><script src="/_next/static/chunks/commons.eb02219a61ab5016dbbe.js" async=""></script><script src="/_next/static/runtime/main-3978781480e8c13aefab.js" async=""></script></body></html>
<!DOCTYPE html><html><head><meta charSet="utf-8" class="next-head"/><title class="next-head"></title><link rel="shortcut icon" type="image/ico" href="/_static/favicon.ico" class="next-head"/><link rel="stylesheet" href="/_static/page.css" class="next-head"/><link rel="stylesheet" href="/_static/markdown.css" class="next-head"/><link rel="stylesheet" href="/_static/highlight.css" class="next-head"/><link rel="stylesheet" href="/_static/[email protected]" class="next-head"/><link rel="stylesheet" href="/_static/sequence-diagram-min.css" class="next-head"/><script type="text/javascript" src="/_static/underscore-min.js" class="next-head"></script><script type="text/javascript" src="/_static/webfont.js" class="next-head"></script><script type="text/javascript" src="/_static/snap.svg.min.js" class="next-head"></script><script type="text/javascript" src="/_static/tweenlite.min.js" class="next-head"></script><script type="text/javascript" src="/_static/mermaid.min.js" class="next-head"></script><script type="text/javascript" src="/_static/sequence-diagram-min.js" class="next-head"></script><script type="text/javascript" src="/_static/[email protected]" class="next-head"></script><script type="text/javascript" src="/_static/mhchem.min.js" class="next-head"></script><script type="text/javascript" src="/_static/[email protected]" class="next-head"></script><script type="text/javascript" src="/_static/[email protected]" class="next-head"></script><script type="text/javascript" src="/_static/viz.js" class="next-head"></script><script type="text/javascript" src="/_static/full.render.js" class="next-head"></script><link rel="preload" href="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/index.js" as="script"/><link rel="preload" href="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/_app.js" as="script"/><link rel="preload" href="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/_error.js" as="script"/><link rel="preload" href="/_next/static/runtime/webpack-2ef50c24cc8d478adafc.js" as="script"/><link rel="preload" href="/_next/static/chunks/commons.eb02219a61ab5016dbbe.js" as="script"/><link rel="preload" href="/_next/static/runtime/main-3978781480e8c13aefab.js" as="script"/></head><body><div id="__next"><main data-theme=""><div id="page-ctn" contenteditable="false"><section class="markdown-body"></section></div></main></div><script>__NEXT_DATA__ = {"props":{"pageProps":{}},"page":"/","query":{},"buildId":"FkkSF_dNiGxHgj6cjrt8V","nextExport":true};__NEXT_LOADED_PAGES__=[];__NEXT_REGISTER_PAGE=function(r,f){__NEXT_LOADED_PAGES__.push([r, f])}</script><script async="" id="__NEXT_PAGE__/" src="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/index.js"></script><script async="" id="__NEXT_PAGE__/_app" src="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/_app.js"></script><script async="" id="__NEXT_PAGE__/_error" src="/_next/static/FkkSF_dNiGxHgj6cjrt8V/pages/_error.js"></script><script src="/_next/static/runtime/webpack-2ef50c24cc8d478adafc.js" async=""></script><script src="/_next/static/chunks/commons.eb02219a61ab5016dbbe.js" async=""></script><script src="/_next/static/runtime/main-3978781480e8c13aefab.js" async=""></script></body></html>
6 changes: 4 additions & 2 deletions app/pages/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ export default class PreviewPage extends React.Component {
hide_yaml_meta: hideYamlMeta = 1,
sequence_diagrams: sequenceDiagrams = {},
flowchart_diagrams: flowchartDiagrams = {},
toc = {}
toc = {},
katex_preamble = []
} = options
// markdown-it
this.md = new MarkdownIt({
Expand All @@ -201,7 +202,8 @@ export default class PreviewPage extends React.Component {
this.md
.use(mk, {
...DEFAULT_OPTIONS.katex,
...katex
...katex,
_preamble: katex_preamble
})
.use(blockUml, {
...DEFAULT_OPTIONS.uml,
Expand Down
8 changes: 7 additions & 1 deletion app/pages/katex.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ https://github.com/runarberg/markdown-it-math
It differs in that it takes (a subset of) LaTeX as input and relies on KaTeX
for rendering output.
*/

/* jslint node: true */
'use strict'

Expand Down Expand Up @@ -158,6 +157,13 @@ export default function math_plugin (md, options) {

options = options || {}
options.macros = options.macros || {}
const preamble = options._preamble

if (Array.isArray(preamble) && preamble.length) {
katex.renderToString(preamble.join("\n"), {macros: options.macros, globalGroup: true})
}

options._preamble = undefined

// set KaTeX as the renderer for markdown-it-simplemath
var katexInline = function (latex) {
Expand Down
2 changes: 1 addition & 1 deletion app/tsconfig.tsbuildinfo

Large diffs are not rendered by default.