docs: highlight npx in bash blocks and polish English copy

Use Prism insertBefore for CLI commands like npx, tighten tutorial and reference wording, and keep YAML titles free of backticks so sidebar and page headings stay correct.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Yang Jun
2026-06-07 13:22:08 +08:00
co-authored by Cursor
parent f7250f4601
commit 5d1b63563a
126 changed files with 224 additions and 217 deletions
+2
View File
@@ -2,6 +2,8 @@
'use strict'
require('./prism-bash-extend')
const { resolve, basename } = require('path')
const { readFileSync } = require('fs')
const cheerio = require('cheerio')
+18 -27
View File
@@ -5,7 +5,12 @@
* Hexo loads scripts from docs/scripts/ during init, before `hexo generate`
* highlights fenced code via syntax_highlighter: prismjs.
*
* To highlight another command, add its name to EXTRA_BASH_COMMANDS below.
* Bash highlights known commands via a large hard-coded regex (see prism-bash).
* insertBefore is the supported extension point when a command is not in that list.
* Add names to EXTRA_BASH_COMMANDS as needed.
*
* After editing this file, run `npx hexo clean` before generate/serve so
* Hexo re-highlights cached pages (db.json does not invalidate on script changes).
*/
const EXTRA_BASH_COMMANDS = [
'npx'
@@ -14,30 +19,16 @@ const EXTRA_BASH_COMMANDS = [
const Prism = require('prismjs')
require('prismjs/components/prism-bash')
function extendBashCommandHighlighting (commands) {
const bash = Prism.languages.bash
if (!bash || !bash.function) return
const escaped = EXTRA_BASH_COMMANDS.map((cmd) =>
cmd.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
)
const fnToken = bash.function
const pattern = fnToken.pattern
if (!(pattern instanceof RegExp)) return
const source = pattern.source
const listMatch = source.match(/\(\?:([^)]+)\)(?=\(\?\=)/)
if (!listMatch) return
const existing = listMatch[1]
const toAdd = commands.filter((cmd) => {
const re = new RegExp(`(?:^|\\|)${cmd.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}(?:\\||$)`)
return !re.test(existing)
})
if (toAdd.length === 0) return
const extended = `${existing}|${toAdd.join('|')}`
fnToken.pattern = new RegExp(
source.replace(/\(\?:([^)]+)\)(?=\(\?\=)/, `(?:${extended})`),
pattern.flags
)
}
extendBashCommandHighlighting(EXTRA_BASH_COMMANDS)
Prism.languages.insertBefore('bash', 'function', {
'cli-command': {
pattern: new RegExp(
`(^|[\\s;|&]|[<>]\\()(?:${escaped.join('|')})(?=$|[)\\s;|&])`
),
lookbehind: true,
alias: ['builtin', 'class-name']
}
})
+1 -1
View File
@@ -114,7 +114,7 @@ filters:
tags:
overview: overview.html
"#": inline_comment.html
"# (inline comment)": inline_comment.html
assign: assign.html
capture: capture.html
case: case.html
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`abs`'
title: Abs
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`append`'
title: Append
---
{% since %}v1.9.1{% endsince %}
@@ -1,5 +1,5 @@
---
title: '`array_to_sentence_string`'
title: Array to sentence string
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`at_least`'
title: At least
---
{% since %}v8.4.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`at_most`'
title: At most
---
{% since %}v8.4.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`base64_decode`'
title: Base64 decode
---
{% since %}v10.24.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`base64_encode`'
title: Base64 encode
---
{% since %}v10.24.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`capitalize`'
title: Capitalize
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`ceil`'
title: Ceil
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`cgi_escape`'
title: CGI escape
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`compact`'
title: Compact
---
{% since %}v9.22.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`concat`'
title: Concat
---
{% since %}v2.0.0{% endsince %}
+6 -6
View File
@@ -1,20 +1,20 @@
---
title: '`date`'
title: Date
---
{% since %}v1.9.1{% endsince %}
The `date` filter is used to convert a timestamp into the specified format.
* LiquidJS tries to conform to Shopify/Liquid, which uses Ruby's core [Time#strftime(string)](https://www.ruby-doc.org/core/Time.html#method-i-strftime). There're differences with [Ruby's format flags](https://ruby-doc.org/core/strftime_formatting_rdoc.html):
* LiquidJS tries to conform to Shopify/Liquid, which uses Ruby's core [Time#strftime(string)](https://www.ruby-doc.org/core/Time.html#method-i-strftime). There are differences with [Ruby's format flags](https://ruby-doc.org/core/strftime_formatting_rdoc.html):
* `%Z` (since v10.11.1) is replaced by the passed-in timezone name from `LiquidOption` or in-place value (see TimeZone below). If passed-in timezone is an offset number instead of string, it'll behave like `%z`. If there's none passed-in timezone, it returns [the runtime's default time zone](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/resolvedOptions#timezone).
* LiquidJS provides an additional `%q` flag for date ordinals. e.g. `{{ '2023/02/02' | date: '%d%q of %b'}}` => `02nd of Feb`
* Date literals are firstly converted to `Date` object via [new Date()][jsDate], that means literal values are considered in runtime's time zone by default.
* Date literals are first converted to a `Date` object via [new Date()][jsDate], which means literal values are considered in the runtime's time zone by default.
* The format filter argument is optional:
* If not provided, it defaults to `%A, %B %-e, %Y at %-l:%M %P %z`.
* The above default can be overridden by [`dateFormat`](/api/interfaces/LiquidOptions.html#dateFormat) LiquidJS option.
* LiquidJS `date` supports locale specific weekdays and month names, which will fallback to English where `Intl` is not supported.
* Ordinals (`%q`) and Jekyll specific date filters are English-only.
* [`locale`](/api/interfaces/LiquidOptions.html#locale) can be set when creating Liquid instance. Defaults to `Intl.DateTimeFormat().resolvedOptions.locale`).
* [`locale`](/api/interfaces/LiquidOptions.html#locale) can be set when creating a Liquid instance. Defaults to `Intl.DateTimeFormat().resolvedOptions().locale`.
### Examples
```liquid
@@ -26,10 +26,10 @@ The `date` filter is used to convert a timestamp into the specified format.
```
# TimeZone
* During output, LiquidJS uses local timezone which can override by:
* During output, LiquidJS uses the local timezone, which can be overridden by:
* setting a timezone in-place when calling `date` filter, or
* setting the [`timezoneOffset`](/api/interfaces/LiquidOptions.html#timezoneOffset) LiquidJS option
* It defaults to runtime's time one.
* It defaults to the runtime's timezone.
* Offset can be set as,
* minutes: `-360` means `'+06:00'` and `360` means `'-06:00'`
* timeZone ID: `Asia/Colombo` or `America/New_York`
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`date_to_long_string`'
title: Date to long string
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`date_to_rfc822`'
title: Date to RFC822
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`date_to_string`'
title: Date to string
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`date_to_xmlschema`'
title: Date to XML schema
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`default`'
title: Default
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`divided_by`'
title: Divided by
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`downcase`'
title: Downcase
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`escape`'
title: Escape
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`escape_once`'
title: Escape once
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`find`'
title: Find
---
{% since %}v10.11.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`find_exp`'
title: Find exp
---
{% since %}v10.11.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`find_index`'
title: Find index
---
{% since %}v10.21.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`find_index_exp`'
title: Find index exp
---
{% since %}v10.21.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`first`'
title: First
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`floor`'
title: Floor
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`group_by`'
title: Group by
---
{% since %}v10.11.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`group_by_exp`'
title: Group by exp
---
{% since %}v10.11.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`has`'
title: Has
---
{% since %}v10.21.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`has_exp`'
title: Has exp
---
{% since %}v10.21.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`hmac_sha256`'
title: HMAC SHA256
---
{% since %}vNEXT{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`inspect`'
title: Inspect
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`join`'
title: Join
---
{% since %}v1.9.1{% endsince %}
+2 -2
View File
@@ -1,10 +1,10 @@
---
title: '`json`'
title: JSON
---
{% since %}v9.10.0{% endsince %}
Convert values to string via `JSON.stringify()`, for debug purpose.
Convert values to string via `JSON.stringify()`, for debugging purposes.
Input
```liquid
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`jsonify`'
title: Jsonify
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`last`'
title: Last
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`lstrip`'
title: Lstrip
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`map`'
title: Map
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`minus`'
title: Minus
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`modulo`'
title: Modulo
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`newline_to_br`'
title: Newline to br
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`normalize_whitespace`'
title: Normalize whitespace
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`number_of_words`'
title: Number of words
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -5,7 +5,7 @@ description: Description and demo for each Liquid filter
LiquidJS implements business-logic independent filters that are typically implemented in [shopify/liquid][shopify/liquid]. This section contains the specification and demos for all the filters implemented by LiquidJS.
There's 40+ filters supported by LiquidJS. These filters can be categorized into these groups:
There are 40+ filters supported by LiquidJS. These filters can be categorized into these groups:
Categories | Filters
--- | ---
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`plus`'
title: Plus
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`pop`'
title: Pop
---
{% since %}v10.11.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`prepend`'
title: Prepend
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`push`'
title: Push
---
{% since %}v10.8.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`raw`'
title: Raw
---
{% since %}v9.37.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`reject`'
title: Reject
---
{% since %}v10.21.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`reject_exp`'
title: Reject exp
---
{% since %}v10.21.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`remove`'
title: Remove
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`remove_first`'
title: Remove first
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`remove_last`'
title: Remove last
---
{% since %}v10.2.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`replace`'
title: Replace
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`replace_first`'
title: Replace first
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`replace_last`'
title: Replace last
---
{% since %}v10.2.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`reverse`'
title: Reverse
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`round`'
title: Round
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`rstrip`'
title: Rstrip
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`sha256`'
title: SHA256
---
{% since %}vNEXT{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`shift`'
title: Shift
---
{% since %}v10.11.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`size`'
title: Size
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`slice`'
title: Slice
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`slugify`'
title: Slugify
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`sort`'
title: Sort
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`sort_natural`'
title: Sort natural
---
{% since %}v8.4.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`split`'
title: Split
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`strip`'
title: Strip
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`strip_html`'
title: Strip HTML
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`strip_newlines`'
title: Strip newlines
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`sum`'
title: Sum
---
{% since %}v10.10.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`times`'
title: Times
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`to_integer`'
title: To integer
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`truncate`'
title: Truncate
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`truncatewords`'
title: Truncatewords
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`uniq`'
title: Uniq
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`unshift`'
title: Unshift
---
{% since %}v10.11.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`upcase`'
title: Upcase
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`uri_escape`'
title: URI escape
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`url_decode`'
title: URL decode
---
{% since %}v6.1.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`url_encode`'
title: URL encode
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`where`'
title: Where
---
{% since %}v8.1.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`where_exp`'
title: Where exp
---
{% since %}v10.12.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`xml_escape`'
title: XML escape
---
{% since %}v10.13.0{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`assign`'
title: Assign
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`capture`'
title: Capture
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -4,7 +4,7 @@ title: Case
{% since %}v1.9.1{% endsince %}
Creates a switch statement to compare a variable with different values. `case` initializes the switch statement, and `when` compares its values.
Creates a switch statement to compare a variable with different values. `case` initializes the switch statement, and `when` tags compare values.
Input
```liquid
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`cycle`'
title: Cycle
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`decrement`'
title: Decrement
---
{% since %}v1.9.1{% endsince %}
+5 -5
View File
@@ -1,5 +1,5 @@
---
title: '`include`'
title: Include
---
{% since %}v1.9.1{% endsince %}
@@ -22,11 +22,11 @@ If [extname][extname] option is set, the above `.liquid` extension becomes optio
{% include 'footer' %}
```
When a partial template is rendered by `include`, the code inside it can access its parent's variables but its parent cannot access variables defined inside a included template.
When a partial template is rendered by `include`, the code inside it can access its parent's variables but its parent cannot access variables defined inside an included template.
## Passing Variables
Variables defined in parent's scope can be passed to a the partial template by listing them as parameters on the `include` tag:
Variables defined in the parent's scope can be passed to the partial template by listing them as parameters on the `include` tag:
```liquid
{% assign my_variable = 'apples' %}
@@ -86,7 +86,7 @@ For example, the following template:
{% include article.html header="HEADER" content="CONTENT" %}
```
`article.html` with following content:
`article.html` with the following content:
```liquid
<article>
@@ -95,7 +95,7 @@ For example, the following template:
</article>
```
Note that we're referencing the first parameter by `include.header` instead of `header`. Will output following:
Note that we're referencing the first parameter by `include.header` instead of `header`. It will output the following:
```html
<article>
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`increment`'
title: Increment
---
{% since %}v1.9.1{% endsince %}
+1 -1
View File
@@ -1,5 +1,5 @@
---
title: '`#`'
title: Inline comment
---
{% since %}v9.38.0{% endsince %}
+4 -4
View File
@@ -1,5 +1,5 @@
---
title: '`layout`'
title: Layout
---
{% since %}v1.9.1{% endsince %}
@@ -31,7 +31,7 @@ If [extname][extname] option is set, the `.liquid` extension becomes optional:
```
{% note info Scoping %}
When a partial template is rendered by the `layout` tag, its template have access for its caller's variables but not vice versa. Variables defined in `layout` will be popped out before control returning to its caller.
When a partial template is rendered by the `layout` tag, its template has access to its caller's variables but not vice versa. Variables defined in `layout` will be popped out before control returns to its caller.
{% endnote %}
## Multiple Blocks
@@ -53,7 +53,7 @@ The `layout` file can contain multiple blocks, each with a specified name. The f
## Default Block Contents
In the above `layout` files, blocks has empty contents. But it's not necessarily be empty, in which case, the block contents in `layout` files will be used as default templates. The following snippets are also equivalent to the above examples:
In the above `layout` files, blocks have empty contents. They do not necessarily need to be empty; in that case, the block contents in `layout` files will be used as default templates. The following snippets are also equivalent to the above examples:
```liquid
// default-layout.liquid
@@ -68,7 +68,7 @@ In the above `layout` files, blocks has empty contents. But it's not necessarily
## Passing Variables
Variables defined in current template can be passed to a the `layout` template by listing them as parameters on the `layout` tag:
Variables defined in the current template can be passed to the `layout` template by listing them as parameters on the `layout` tag:
```liquid
{% assign my_variable = 'apples' %}
+1 -1
View File
@@ -5,7 +5,7 @@ description: Description and demo for each Liquid tag
LiquidJS implements business-logic independent tags that are typically implemented in [shopify/liquid][shopify/liquid]. This section contains the specification and demos for all the tags implemented by LiquidJS.
There're a dozen of tags supported by LiquidJS, with all tags in [shopify/liquid][shopify/liquid]. These tags can be categorized into these groups:
There are a dozen tags supported by LiquidJS, including all tags in [shopify/liquid][shopify/liquid]. These tags can be categorized into these groups:
Category | Purpose | Tags
--- | --- | ---

Some files were not shown because too many files have changed in this diff Show More