diff --git a/.gitignore b/.gitignore index 9889e0a5..b073caed 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,5 @@ website/build/ website/yarn.lock website/node_modules website/i18n/* +website/static/static/katex.* +website/static/static/fonts diff --git a/.stylelintrc b/.stylelintrc index 9079658d..c7943ff6 100644 --- a/.stylelintrc +++ b/.stylelintrc @@ -2,5 +2,8 @@ "extends": "stylelint-config-standard", "rules": { "indentation": 4, - } + }, + "ignoreFiles": [ + "**/*.min.css" + ] } diff --git a/cli.js b/cli.js index be79285c..4da5fe79 100755 --- a/cli.js +++ b/cli.js @@ -62,22 +62,13 @@ const program = require("commander") .option("-i, --input ", "Read LaTeX input from the given file.") .option("-o, --output ", "Write html output to the given file."); -program.command('markdown-help') - .description('Print markdown version of the help') - .action(() => { - console.log(); - console.log(program.options.map(option => `### \`${option.flags}\` -${option.description}${((option.bool && option.defaultValue !== undefined) - ? ' (default: ' + option.defaultValue + ')' : '')} -`) - .concat(['### `-h, --help`\nOutput usage information']) - .join('\n')); - process.exit(); - }); +if (require.main !== module) { + module.exports = program; + return; +} const options = program.parse(process.argv); - function readMacros() { if (options.macroFile) { fs.readFile(options.macroFile, "utf-8", function(err, data) { diff --git a/docs/support_table.md b/docs/support_table.md index a613f8da..be9b21fc 100644 --- a/docs/support_table.md +++ b/docs/support_table.md @@ -2,7 +2,11 @@ id: support_table title: Support Table --- - +This is a list of TeX functions, sorted alphabetically. This list includes functions that KaTeX supports and some that it doesn't support. There is a similar page, with functions [sorted by type](./supported.md). + +If you know the shape of a character, but not its name, [Detexify](http://detexify.kirelabs.org/classify.html) can help. + +{@stylesheet: katex.min.css} -This is a list of TeX functions, sorted alphabetically. This list includes functions that KaTeX supports and some that it doesn't support. There is a similar page, with functions [sorted by type](./supported.md). - -If you know the shape of a character, but not its name, [Detexify](http://detexify.kirelabs.org/classify.html) can help. - ## Symbols |Symbol/Function | Rendered | Source or Comment| diff --git a/docs/supported.md b/docs/supported.md index cd0bc26e..65b38891 100644 --- a/docs/supported.md +++ b/docs/supported.md @@ -2,7 +2,11 @@ id: supported title: Supported Functions --- - +This is a list of TeX functions supported by KaTeX. It is sorted into logical groups. + +There is a similar [Support Table](./support_table.md), sorted alphabetically, that lists both supported and un-supported functions. + +{@stylesheet: katex.min.css} -This is a list of TeX functions supported by KaTeX. It is sorted into logical groups. - -There is a similar [Support Table](./support_table.md), sorted alphabetically, that lists both supported and un-supported functions.
diff --git a/release.sh b/release.sh index 4f602d26..97ae424e 100755 --- a/release.sh +++ b/release.sh @@ -116,9 +116,9 @@ sed -i.bak -E '/^\/dist\/$/d' .gitignore rm -f .gitignore.bak git add .gitignore dist/ -# Edit docs to use CSS from CDN (#1520) -# grep -l '{@stylesheet: static/katex.min.css}' docs/*.md | xargs sed -i.bak \ -# 's|{@stylesheet: static/katex.min.css}||' +# Edit docs to use CSS from CDN +grep -l '{@stylesheet: katex.min.css}' docs/*.md | xargs sed -i.bak \ + 's|{@stylesheet: katex.min.css}||' # Update the version number in CDN URLs included in the README and the documentation, # and regenerate the Subresource Integrity hash for these files. @@ -130,9 +130,9 @@ pushd website yarn run version "${VERSION}" # Restore docs to use local built CSS -# for file in ../docs/*.md.bak; do -# mv -f "$file" "${file%.bak}" -# done +for file in ../docs/*.md.bak; do + mv -f "$file" "${file%.bak}" +done USE_SSH=true yarn publish-gh-pages popd diff --git a/website/lib/build.js b/website/lib/build.js new file mode 100644 index 00000000..bfbc1933 --- /dev/null +++ b/website/lib/build.js @@ -0,0 +1,16 @@ +const fs = require('fs-extra'); + +// generate cli.md +const cli = require('../../cli'); +const template = fs.readFileSync('../docs/cli.md.template'); + +fs.writeFileSync('../docs/cli.md', [template, + ...cli.options.map(option => `### \`${option.flags}\` +${option.description}${((option.bool && option.defaultValue !== undefined) +? ' (default: ' + option.defaultValue + ')' : '')} +`), + '### `-h, --help`\nOutput usage information', ''].join('\n')); + +// copy local built CSS and fonts +fs.copySync('../dist/katex.min.css', 'static/static/katex.min.css'); +fs.copySync('../dist/fonts', 'static/static/fonts'); diff --git a/website/lib/empty_thead.js b/website/lib/empty-thead.js similarity index 100% rename from website/lib/empty_thead.js rename to website/lib/empty-thead.js diff --git a/website/lib/remarkableKatex.js b/website/lib/remarkable-katex.js similarity index 100% rename from website/lib/remarkableKatex.js rename to website/lib/remarkable-katex.js diff --git a/website/package.json b/website/package.json index ccaf0dc8..cf7746fe 100644 --- a/website/package.json +++ b/website/package.json @@ -1,15 +1,16 @@ { "scripts": { - "prestart": "cp ../docs/cli.md.template ../docs/cli.md && node ../cli.js markdown-help >> ../docs/cli.md", - "start": "docusaurus-start", - "build": "npm run prestart && docusaurus-build", - "publish-gh-pages": "npm run prestart && docusaurus-publish", + "start": "node lib/build.js && docusaurus-start", + "build": "node lib/build.js && docusaurus-build", + "publish-gh-pages": "node lib/build.js && docusaurus-publish", "write-translations": "docusaurus-write-translations", - "version": "npm run prestart && docusaurus-version", + "version": "node lib/build.js && docusaurus-version", "rename-version": "docusaurus-rename-version" }, "devDependencies": { - "docusaurus": "^1.3.2" + "docusaurus": "^1.3.2", + "fs-extra": "^7.0.0", + "remarkable-embed": "^0.4.1" }, "dependencies": {} } diff --git a/website/siteConfig.js b/website/siteConfig.js index cfc3e6a4..95ce5c7b 100644 --- a/website/siteConfig.js +++ b/website/siteConfig.js @@ -12,6 +12,14 @@ // If on netlify, use '/'. Otherwise use '/KaTeX/'. const baseUrl = process.env.BASE_URL || (process.env.CONTEXT ? '/' : '/KaTeX/'); +// Plugin for Remarkable to inject variables +const {Plugin: Embed} = require('remarkable-embed'); +const embed = new Embed(); + + // {@stylesheet: path} +embed.register('stylesheet', + path => ``); + /* List of projects/orgs using your project for the users page */ const users = [ { @@ -66,8 +74,9 @@ const siteConfig = { }, markdownPlugins: [ - require('./lib/remarkableKatex'), - require('./lib/empty_thead'), + embed.hook, + require('./lib/remarkable-katex'), + require('./lib/empty-thead'), ], scripts: [