diff --git a/docs/languages.md b/docs/languages.md index cbc1499..e4b62f7 100644 --- a/docs/languages.md +++ b/docs/languages.md @@ -62,6 +62,8 @@ class Article: Recognizes PHP open tags, variables (`$name`), declaration names, class/interface names, keywords, common builtin functions, property access (`->name`, `::name`), strings, comments, and numbers. +Heredocs and nowdocs (`<<` and the `%r{…}` regex — end at the delimiter matching the one that opened them, counting depth so an inner pair does not close the literal early. + ```rust fn main() { let mut count = 1; @@ -207,6 +211,9 @@ Recognizes: - 70+ common commands as builtin functions: `grep`, `git`, `npm`, `docker`, `kubectl`, ... - Variables: `$VAR`, `${VAR}`, `$@`, `$?` - Strings (double-quoted strings support `$` interpolation) +- Heredocs: `< out.txt` — stays shell. - Command-line options `-x`, `--foo` ```bash @@ -302,6 +309,8 @@ print(square(4)) Recognizes POD doc blocks (`=head1 ... =cut`), `sub` declarations, `$scalar` / `@array` / `%hash` sigil variables, special variables (`$_`, `@ARGV`), regex binds (`=~ /.../`), and list builtins. +The quoting operators `q{…}`, `qq{…}`, `qw(…)` and `qr{…}` end at the delimiter matching their opener, so a `#` inside one is text rather than a comment. + ```perl use strict; my $name = "world"; @@ -328,6 +337,8 @@ function Get-Greeting { Write-Host "hi $Name" } Recognizes `defmodule` / `def` / `defp` declarations, `:atoms`, module attributes (`@doc` colored as doc when followed by `"""`), capitalized module names, string interpolation `#{...}`, and the `|>` pipe. +Sigils close on the delimiter matching their opener: `~s{…}`, `~w[…]`, and `~r//` as a regex. A `"` delimiter is left to the ordinary string rules, so that `~s"""…"""` is not cut at its second quote. + ```elixir defmodule Greeter do def hello(name), do: IO.puts("hi " <> name) diff --git a/docs/languages.zh-CN.md b/docs/languages.zh-CN.md index 5a627a2..0b3372c 100644 --- a/docs/languages.zh-CN.md +++ b/docs/languages.zh-CN.md @@ -62,6 +62,8 @@ class Article: 识别 PHP 起始标签、变量(`$name`)、声明名、类/接口名、关键字、常见内置函数、属性访问(`->name`, `::name`)、字符串、注释和数字。 +heredoc 与 nowdoc(`<<` 以及正则 `%r{…}` —— 结束于与开启字符配对的那个定界符,并会计数嵌套深度,因此内层的一对不会让字面量提前闭合。 + ```rust fn main() { let mut count = 1; @@ -207,6 +211,9 @@ fn main() { - 70+ 常用命令作为内置函数:`grep`, `git`, `npm`, `docker`, `kubectl`, ... - 变量:`$VAR`, `${VAR}`, `$@`, `$?` - 字符串(双引号支持 `$` 内插) +- heredoc:`< out.txt` —— 仍留在 + shell 一侧。 - 命令行选项 `-x`, `--foo` ```bash @@ -302,6 +309,8 @@ print(square(4)) 识别 POD 文档块(`=head1 ... =cut`)、`sub` 声明、`$标量` / `@数组` / `%哈希` 符号变量、特殊变量(`$_`、`@ARGV`)、正则绑定(`=~ /.../`)和列表内建函数。 +引用运算符 `q{…}`、`qq{…}`、`qw(…)`、`qr{…}` 结束于与开启字符配对的定界符,因此其中的 `#` 是文本而不是注释。 + ```perl use strict; my $name = "world"; @@ -328,6 +337,8 @@ function Get-Greeting { Write-Host "hi $Name" } 识别 `defmodule` / `def` / `defp` 声明、`:atom` 原子、模块属性(后接 `"""` 的 `@doc` 按文档注释着色)、大写模块名、字符串插值 `#{...}` 和 `|>` 管道。 +sigil 结束于与开启字符配对的定界符:`~s{…}`、`~w[…]`,以及作为正则的 `~r//`。`"` 不被当作 sigil 定界符,交回给普通字符串规则处理,这样 `~s"""…"""` 才不会在第二个引号处被截断。 + ```elixir defmodule Greeter do def hello(name), do: IO.puts("hi " <> name)