diff --git a/bin/build-apidoc.sh b/bin/build-apidoc.sh index 7e07d4bfb..3ef7d65cd 100755 --- a/bin/build-apidoc.sh +++ b/bin/build-apidoc.sh @@ -11,8 +11,6 @@ for file in $(find docs/source/api -name "*.md"); do -e 's/\(\]([^_)]*\)\/_/\1\//g' \ -e 's/\(\]([^)]*\.\)md/\1html/g' \ -e 's/\](_/\](/g' \ - -e 's/{%/{% raw %}{%{% endraw %}/g' \ - -e 's/{{/{% raw %}{{{% endraw %}/g' \ -e '1 s/"/\"/g' \ -e '1 s//\>/g' \ @@ -20,9 +18,7 @@ for file in $(find docs/source/api -name "*.md"); do -e '1 s/^# \(.*\)/---\ntitle: "\1"\nauto: true\n---/' \ $file target=${file/\/_/\/} - if [ "$file" != "$target" ]; then - mv $file $target - fi + cat $file | ./bin/escape-nunjucks.js > $target done cp -r docs/source/api docs/source/zh-cn/api diff --git a/bin/escape-nunjucks.js b/bin/escape-nunjucks.js new file mode 100755 index 000000000..e5c12c8fe --- /dev/null +++ b/bin/escape-nunjucks.js @@ -0,0 +1,18 @@ +#!/usr/bin/env node + +// In Hexo, content inside markdown code/code fences, +// will not go through nunjucks. +// So we're escaping special chars outside code only. +let backTick = 0 +process.stdin.on('data', (buffer) => { + for (const c of buffer.toString()) { + if (c === '`') { + backTick++ + } + const shouldEscape = '{%%}'.includes(c) && backTick % 2 === 0 + if (shouldEscape) { + const code = c.charCodeAt(0).toString(16) + process.stdout.write(`&#x${code};`) + } else process.stdout.write(c) + } +}) diff --git a/docs/themes/navy/source/css/_variables.styl b/docs/themes/navy/source/css/_variables.styl index c2f46034b..581ac6649 100644 --- a/docs/themes/navy/source/css/_variables.styl +++ b/docs/themes/navy/source/css/_variables.styl @@ -21,11 +21,11 @@ vendor-prefixes = webkit moz ms official --color-default: #d1d2d4 --color-default-invert: #444 --color-gray: invert(#999) - --color-border: invert(#e3e3e3) + --color-border: #6a6a6a --color-backgrond: #fff --color-navy: hsl(210, 25%, 12%) --color-news-bg: darken(hsl(210, 25%, 12%), 5%) - --color-navy-lighter: lighten(hsl(210, 25%, 12%), 10%) + --color-navy-lighter: lighten(hsl(210, 25%, 12%), 7%) --color-content-bg: #1c1c1c --color-link: #0e83cd --color-link-hover: lighten(#0e83cd, 10%) diff --git a/src/context/context.ts b/src/context/context.ts index bb980d9a5..d5a1b2f86 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -8,14 +8,14 @@ import { InternalUndefinedVariableError } from '../util/error' export class Context { /** * insert a Context-level empty scope, - * for tags like {% capture %} {% assign %} to operate + * for tags like `{% capture %}` `{% assign %}` to operate */ private scopes: Scope[] = [{}] private registers = {} /** * user passed in scope - * {% increment %}, {% decrement %} changes this scope, - * whereas {% capture %}, {% assign %} only hide this scope + * `{% increment %}`, `{% decrement %}` changes this scope, + * whereas `{% capture %}`, `{% assign %}` only hide this scope */ public environments: Scope /**