@enjoys/context-engine 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/codeLens/awk.json +1 -1
- package/data/codeLens/azcli.json +10 -10
- package/data/codeLens/c.json +1 -1
- package/data/codeLens/caddy.json +1 -1
- package/data/codeLens/crontab.json +1 -1
- package/data/codeLens/doctest.json +10 -10
- package/data/codeLens/hcl.json +1 -1
- package/data/codeLens/html.json +1 -1
- package/data/codeLens/lua.json +1 -1
- package/data/codeLens/nginx.json +1 -1
- package/data/codeLens/pla.json +10 -10
- package/data/codeLens/xml.json +1 -1
- package/data/commands/angular.json +670 -312
- package/data/commands/c.json +30 -30
- package/data/commands/cpp.json +30 -30
- package/data/commands/crontab.json +25 -30
- package/data/commands/cypher.json +26 -30
- package/data/commands/dockerfile.json +26 -2
- package/data/commands/doctest.json +23 -24
- package/data/commands/dotenv.json +24 -11
- package/data/commands/ecl.json +26 -30
- package/data/commands/flow9.json +24 -24
- package/data/commands/freemarker2.json +24 -18
- package/data/commands/graphql.json +25 -11
- package/data/commands/html.json +25 -11
- package/data/commands/ini.json +26 -12
- package/data/commands/javascript.json +29 -30
- package/data/commands/less.json +25 -29
- package/data/commands/lexon.json +23 -11
- package/data/commands/liquid.json +26 -11
- package/data/commands/m3.json +26 -12
- package/data/commands/manifest.json +35 -731
- package/data/commands/markdown.json +26 -12
- package/data/commands/mdx.json +23 -10
- package/data/commands/mips.json +26 -18
- package/data/commands/msdax.json +23 -11
- package/data/commands/nestjs.json +516 -273
- package/data/commands/nextjs.json +250 -123
- package/data/commands/objective-c.json +26 -24
- package/data/commands/pascal.json +27 -24
- package/data/commands/pascaligo.json +26 -24
- package/data/commands/perl.json +30 -30
- package/data/commands/pla.json +23 -11
- package/data/commands/postiats.json +26 -24
- package/data/commands/powerquery.json +23 -11
- package/data/commands/powershell.json +28 -30
- package/data/commands/protobuf.json +27 -30
- package/data/commands/qsharp.json +26 -30
- package/data/commands/razor.json +25 -29
- package/data/commands/react.json +244 -210
- package/data/commands/redshift.json +27 -18
- package/data/commands/restructuredtext.json +29 -30
- package/data/commands/sb.json +23 -11
- package/data/commands/scheme.json +25 -18
- package/data/commands/scss.json +26 -29
- package/data/commands/shadcn.json +564 -410
- package/data/commands/sol.json +27 -30
- package/data/commands/sparql.json +25 -11
- package/data/commands/sql.json +16 -2
- package/data/commands/ssh_config.json +31 -30
- package/data/commands/st.json +23 -11
- package/data/commands/systemverilog.json +26 -24
- package/data/commands/tailwindcss.json +60 -53
- package/data/commands/tcl.json +23 -18
- package/data/commands/toml.json +25 -11
- package/data/commands/twig.json +23 -10
- package/data/commands/vb.json +27 -24
- package/data/commands/wgsl.json +24 -11
- package/data/commands/yaml.json +29 -30
- package/data/completion/awk.json +906 -202
- package/data/completion/azcli.json +886 -237
- package/data/completion/bicep.json +862 -367
- package/data/completion/crontab.json +906 -202
- package/data/completion/dotenv.json +895 -169
- package/data/completion/graphql.json +895 -180
- package/data/completion/hcl.json +906 -191
- package/data/completion/ini.json +906 -136
- package/data/completion/json.json +895 -169
- package/data/completion/lexon.json +856 -295
- package/data/completion/makefile.json +906 -202
- package/data/completion/markdown.json +906 -224
- package/data/completion/mdx.json +895 -87
- package/data/completion/mips.json +872 -377
- package/data/completion/perl.json +961 -202
- package/data/completion/pla.json +895 -154
- package/data/completion/powershell.json +906 -224
- package/data/completion/protobuf.json +884 -180
- package/data/completion/ssh_config.json +906 -158
- package/data/completion/xml.json +906 -158
- package/data/definition/abap.json +127 -1
- package/data/definition/apex.json +97 -1
- package/data/definition/coffee.json +51 -1
- package/data/definition/dart.json +105 -1
- package/data/definition/elixir.json +115 -1
- package/data/definition/flow9.json +208 -1
- package/data/definition/freemarker2.json +283 -1
- package/data/definition/html.json +853 -558
- package/data/definition/java.json +1127 -183
- package/data/definition/kotlin.json +72 -1
- package/data/definition/r.json +692 -83
- package/data/definition/ruby.json +789 -669
- package/data/definition/rust.json +852 -206
- package/data/definition/sb.json +339 -1
- package/data/definition/st.json +367 -1
- package/data/documentRangeFormatting/nestjs.json +57 -17
- package/data/documentRangeFormatting/nextjs.json +57 -17
- package/data/documentRangeFormatting/react.json +82 -78
- package/data/documentSymbol/abap.json +54 -12
- package/data/documentSymbol/apex.json +40 -10
- package/data/documentSymbol/awk.json +15 -1
- package/data/documentSymbol/bicep.json +39 -39
- package/data/documentSymbol/c.json +1 -1
- package/data/documentSymbol/clojure.json +46 -46
- package/data/documentSymbol/css.json +96 -96
- package/data/documentSymbol/dart.json +109 -19
- package/data/documentSymbol/dockerfile.json +1 -1
- package/data/documentSymbol/elixir.json +39 -39
- package/data/documentSymbol/go.json +1 -1
- package/data/documentSymbol/graphql.json +1 -1
- package/data/documentSymbol/hcl.json +1 -1
- package/data/documentSymbol/html.json +29 -1
- package/data/documentSymbol/java.json +1 -1
- package/data/documentSymbol/javascript.json +1 -1
- package/data/documentSymbol/julia.json +46 -46
- package/data/documentSymbol/kotlin.json +74 -14
- package/data/documentSymbol/less.json +25 -25
- package/data/documentSymbol/lua.json +22 -1
- package/data/documentSymbol/makefile.json +15 -1
- package/data/documentSymbol/markdown.json +36 -1
- package/data/documentSymbol/mysql.json +32 -32
- package/data/documentSymbol/nginx.json +1 -1
- package/data/documentSymbol/pascal.json +46 -46
- package/data/documentSymbol/perl.json +1 -1
- package/data/documentSymbol/pgsql.json +39 -39
- package/data/documentSymbol/php.json +1 -1
- package/data/documentSymbol/powershell.json +1 -1
- package/data/documentSymbol/protobuf.json +1 -1
- package/data/documentSymbol/python.json +1 -1
- package/data/documentSymbol/r.json +67 -67
- package/data/documentSymbol/redshift.json +60 -18
- package/data/documentSymbol/ruby.json +1 -1
- package/data/documentSymbol/rust.json +1 -1
- package/data/documentSymbol/scala.json +116 -20
- package/data/documentSymbol/scheme.json +25 -25
- package/data/documentSymbol/scss.json +39 -39
- package/data/documentSymbol/shell.json +1 -1
- package/data/documentSymbol/sql.json +1 -1
- package/data/documentSymbol/swift.json +88 -16
- package/data/documentSymbol/typescript.json +1 -1
- package/data/documentSymbol/vb.json +53 -53
- package/data/documentSymbol/yaml.json +1 -1
- package/data/foldingRange/angular.json +100 -99
- package/data/foldingRange/nestjs.json +94 -26
- package/data/foldingRange/nextjs.json +94 -26
- package/data/foldingRange/react.json +118 -120
- package/data/foldingRange/shadcn.json +94 -93
- package/data/formatting/abap.json +19 -11
- package/data/formatting/angular.json +63 -21
- package/data/formatting/apex.json +19 -11
- package/data/formatting/awk.json +1 -1
- package/data/formatting/azcli.json +18 -18
- package/data/formatting/bicep.json +18 -18
- package/data/formatting/c.json +1 -1
- package/data/formatting/caddy.json +1 -1
- package/data/formatting/cameligo.json +18 -18
- package/data/formatting/clojure.json +18 -18
- package/data/formatting/coffee.json +18 -18
- package/data/formatting/cpp.json +1 -1
- package/data/formatting/crontab.json +1 -1
- package/data/formatting/csharp.json +1 -1
- package/data/formatting/css.json +73 -73
- package/data/formatting/cypher.json +18 -18
- package/data/formatting/dart.json +43 -15
- package/data/formatting/docker-compose.json +24 -24
- package/data/formatting/dockerfile.json +1 -1
- package/data/formatting/doctest.json +18 -18
- package/data/formatting/dotenv.json +1 -1
- package/data/formatting/ecl.json +18 -18
- package/data/formatting/elixir.json +43 -18
- package/data/formatting/flow9.json +18 -18
- package/data/formatting/freemarker2.json +18 -18
- package/data/formatting/go.json +1 -1
- package/data/formatting/graphql.json +1 -1
- package/data/formatting/hcl.json +26 -1
- package/data/formatting/html.json +26 -1
- package/data/formatting/ini.json +1 -1
- package/data/formatting/java.json +1 -1
- package/data/formatting/javascript.json +1 -1
- package/data/formatting/julia.json +18 -18
- package/data/formatting/kotlin.json +33 -13
- package/data/formatting/less.json +48 -18
- package/data/formatting/lexon.json +18 -18
- package/data/formatting/liquid.json +18 -18
- package/data/formatting/lua.json +1 -1
- package/data/formatting/m3.json +18 -18
- package/data/formatting/makefile.json +1 -1
- package/data/formatting/markdown.json +26 -1
- package/data/formatting/mdx.json +18 -18
- package/data/formatting/mips.json +18 -18
- package/data/formatting/msdax.json +18 -18
- package/data/formatting/mysql.json +43 -18
- package/data/formatting/nginx.json +1 -1
- package/data/formatting/objective-c.json +18 -18
- package/data/formatting/pascal.json +18 -18
- package/data/formatting/pascaligo.json +18 -18
- package/data/formatting/perl.json +1 -1
- package/data/formatting/pgsql.json +43 -18
- package/data/formatting/php.json +1 -1
- package/data/formatting/pla.json +18 -18
- package/data/formatting/postiats.json +18 -18
- package/data/formatting/powerquery.json +18 -18
- package/data/formatting/powershell.json +1 -1
- package/data/formatting/protobuf.json +1 -1
- package/data/formatting/python.json +1 -1
- package/data/formatting/qsharp.json +18 -18
- package/data/formatting/r.json +32 -32
- package/data/formatting/razor.json +18 -18
- package/data/formatting/redis-cli.json +1 -1
- package/data/formatting/redis.json +18 -18
- package/data/formatting/redshift.json +43 -18
- package/data/formatting/restructuredtext.json +18 -18
- package/data/formatting/ruby.json +1 -1
- package/data/formatting/rust.json +1 -1
- package/data/formatting/sb.json +18 -18
- package/data/formatting/scala.json +48 -16
- package/data/formatting/scheme.json +18 -18
- package/data/formatting/scss.json +48 -18
- package/data/formatting/shadcn.json +63 -61
- package/data/formatting/shell.json +1 -1
- package/data/formatting/sol.json +18 -18
- package/data/formatting/sparql.json +18 -18
- package/data/formatting/sql.json +1 -1
- package/data/formatting/ssh_config.json +1 -1
- package/data/formatting/st.json +18 -18
- package/data/formatting/swift.json +58 -18
- package/data/formatting/systemd.json +1 -1
- package/data/formatting/systemverilog.json +18 -18
- package/data/formatting/tcl.json +18 -18
- package/data/formatting/toml.json +1 -1
- package/data/formatting/twig.json +18 -18
- package/data/formatting/typescript.json +1 -1
- package/data/formatting/vb.json +18 -18
- package/data/formatting/wgsl.json +18 -18
- package/data/formatting/xml.json +26 -1
- package/data/formatting/yaml.json +1 -1
- package/data/hover/apex.json +281 -6
- package/data/hover/awk.json +251 -6
- package/data/hover/crontab.json +251 -6
- package/data/hover/dotenv.json +242 -4
- package/data/hover/graphql.json +251 -6
- package/data/hover/lexon.json +250 -5
- package/data/hover/markdown.json +226 -9
- package/data/hover/mdx.json +250 -5
- package/data/hover/perl.json +251 -6
- package/data/hover/pla.json +264 -5
- package/data/hover/powershell.json +252 -7
- package/data/hover/protobuf.json +251 -6
- package/data/hover/redis.json +355 -40
- package/data/hover/ssh_config.json +251 -6
- package/data/hover/xml.json +231 -7
- package/data/inlineCompletions/c.json +49 -1
- package/data/inlineCompletions/cpp.json +61 -1
- package/data/inlineCompletions/csharp.json +73 -1
- package/data/inlineCompletions/css.json +125 -125
- package/data/inlineCompletions/dart.json +136 -26
- package/data/inlineCompletions/elixir.json +34 -34
- package/data/inlineCompletions/go.json +67 -1
- package/data/inlineCompletions/html.json +1 -1
- package/data/inlineCompletions/java.json +67 -1
- package/data/inlineCompletions/javascript.json +97 -1
- package/data/inlineCompletions/kotlin.json +88 -18
- package/data/inlineCompletions/less.json +76 -28
- package/data/inlineCompletions/lua.json +37 -1
- package/data/inlineCompletions/mysql.json +34 -34
- package/data/inlineCompletions/pgsql.json +34 -34
- package/data/inlineCompletions/php.json +43 -1
- package/data/inlineCompletions/python.json +73 -1
- package/data/inlineCompletions/ruby.json +49 -1
- package/data/inlineCompletions/rust.json +61 -1
- package/data/inlineCompletions/scala.json +130 -25
- package/data/inlineCompletions/scss.json +34 -34
- package/data/inlineCompletions/shell.json +1 -1
- package/data/inlineCompletions/sql.json +43 -1
- package/data/inlineCompletions/swift.json +112 -22
- package/data/inlineCompletions/typescript.json +97 -1
- package/data/linkedEditingRange/azcli.json +6 -6
- package/data/linkedEditingRange/crontab.json +6 -6
- package/data/linkedEditingRange/docker-compose.json +6 -6
- package/data/linkedEditingRange/doctest.json +6 -6
- package/data/linkedEditingRange/dotenv.json +13 -6
- package/data/linkedEditingRange/ini.json +13 -6
- package/data/linkedEditingRange/json.json +13 -6
- package/data/linkedEditingRange/lexon.json +6 -6
- package/data/linkedEditingRange/mips.json +6 -6
- package/data/linkedEditingRange/msdax.json +6 -6
- package/data/linkedEditingRange/nestjs.json +18 -10
- package/data/linkedEditingRange/nextjs.json +24 -11
- package/data/linkedEditingRange/pla.json +6 -6
- package/data/linkedEditingRange/react.json +74 -75
- package/data/linkedEditingRange/redis-cli.json +6 -6
- package/data/linkedEditingRange/redis.json +6 -6
- package/data/linkedEditingRange/ssh_config.json +6 -6
- package/data/linkedEditingRange/systemd.json +6 -6
- package/data/linkedEditingRange/toml.json +13 -6
- package/data/linkedEditingRange/wgsl.json +6 -6
- package/data/linkedEditingRange/xml.json +13 -13
- package/data/linkedEditingRange/yaml.json +13 -6
- package/data/onTypeFormatting/angular.json +63 -14
- package/data/onTypeFormatting/nestjs.json +64 -16
- package/data/onTypeFormatting/nextjs.json +72 -17
- package/data/onTypeFormatting/react.json +148 -127
- package/data/onTypeFormatting/shadcn.json +63 -54
- package/data/rangeSemanticTokens/angular.json +196 -140
- package/data/rangeSemanticTokens/nestjs.json +195 -27
- package/data/rangeSemanticTokens/nextjs.json +199 -28
- package/data/rangeSemanticTokens/react.json +77 -216
- package/data/rangeSemanticTokens/shadcn.json +203 -140
- package/data/rename/angular.json +121 -131
- package/data/rename/nestjs.json +122 -32
- package/data/rename/nextjs.json +116 -31
- package/data/rename/react.json +133 -88
- package/data/rename/shadcn.json +73 -79
- package/data/selectionRange/abap.json +58 -34
- package/data/selectionRange/angular.json +126 -95
- package/data/selectionRange/apex.json +58 -34
- package/data/selectionRange/awk.json +56 -34
- package/data/selectionRange/azcli.json +43 -24
- package/data/selectionRange/bicep.json +56 -34
- package/data/selectionRange/c.json +62 -39
- package/data/selectionRange/caddy.json +53 -34
- package/data/selectionRange/cameligo.json +56 -34
- package/data/selectionRange/clojure.json +57 -34
- package/data/selectionRange/coffee.json +59 -34
- package/data/selectionRange/cpp.json +73 -44
- package/data/selectionRange/crontab.json +39 -29
- package/data/selectionRange/csharp.json +69 -39
- package/data/selectionRange/css.json +95 -55
- package/data/selectionRange/cypher.json +57 -34
- package/data/selectionRange/dart.json +65 -34
- package/data/selectionRange/docker-compose.json +54 -34
- package/data/selectionRange/dockerfile.json +56 -34
- package/data/selectionRange/doctest.json +47 -24
- package/data/selectionRange/dotenv.json +33 -24
- package/data/selectionRange/ecl.json +58 -34
- package/data/selectionRange/elixir.json +63 -34
- package/data/selectionRange/flow9.json +57 -34
- package/data/selectionRange/freemarker2.json +58 -34
- package/data/selectionRange/go.json +64 -39
- package/data/selectionRange/graphql.json +58 -34
- package/data/selectionRange/hcl.json +56 -34
- package/data/selectionRange/html.json +63 -34
- package/data/selectionRange/ini.json +38 -24
- package/data/selectionRange/java.json +68 -39
- package/data/selectionRange/javascript.json +65 -39
- package/data/selectionRange/julia.json +65 -39
- package/data/selectionRange/kotlin.json +68 -39
- package/data/selectionRange/less.json +58 -34
- package/data/selectionRange/lexon.json +38 -24
- package/data/selectionRange/liquid.json +58 -34
- package/data/selectionRange/lua.json +59 -34
- package/data/selectionRange/m3.json +57 -34
- package/data/selectionRange/makefile.json +53 -34
- package/data/selectionRange/markdown.json +57 -34
- package/data/selectionRange/mdx.json +63 -34
- package/data/selectionRange/mips.json +43 -29
- package/data/selectionRange/msdax.json +52 -34
- package/data/selectionRange/mysql.json +51 -34
- package/data/selectionRange/nestjs.json +35 -21
- package/data/selectionRange/nextjs.json +35 -22
- package/data/selectionRange/nginx.json +53 -34
- package/data/selectionRange/objective-c.json +64 -39
- package/data/selectionRange/pascal.json +53 -34
- package/data/selectionRange/pascaligo.json +57 -34
- package/data/selectionRange/perl.json +59 -34
- package/data/selectionRange/pgsql.json +50 -34
- package/data/selectionRange/php.json +65 -39
- package/data/selectionRange/pla.json +52 -29
- package/data/selectionRange/postiats.json +61 -34
- package/data/selectionRange/powerquery.json +56 -34
- package/data/selectionRange/powershell.json +65 -39
- package/data/selectionRange/protobuf.json +58 -34
- package/data/selectionRange/python.json +66 -39
- package/data/selectionRange/qsharp.json +62 -39
- package/data/selectionRange/r.json +57 -34
- package/data/selectionRange/razor.json +63 -34
- package/data/selectionRange/react.json +103 -87
- package/data/selectionRange/redis-cli.json +38 -24
- package/data/selectionRange/redis.json +38 -24
- package/data/selectionRange/redshift.json +49 -34
- package/data/selectionRange/restructuredtext.json +58 -34
- package/data/selectionRange/ruby.json +65 -39
- package/data/selectionRange/rust.json +73 -44
- package/data/selectionRange/sb.json +43 -29
- package/data/selectionRange/scala.json +65 -39
- package/data/selectionRange/scheme.json +52 -34
- package/data/selectionRange/scss.json +58 -34
- package/data/selectionRange/shadcn.json +120 -89
- package/data/selectionRange/shell.json +1 -1
- package/data/selectionRange/sol.json +63 -39
- package/data/selectionRange/sparql.json +58 -34
- package/data/selectionRange/sql.json +50 -34
- package/data/selectionRange/ssh_config.json +37 -29
- package/data/selectionRange/st.json +49 -29
- package/data/selectionRange/swift.json +73 -44
- package/data/selectionRange/systemd.json +47 -34
- package/data/selectionRange/systemverilog.json +62 -39
- package/data/selectionRange/tailwindcss.json +49 -34
- package/data/selectionRange/tcl.json +57 -34
- package/data/selectionRange/toml.json +49 -29
- package/data/selectionRange/twig.json +58 -34
- package/data/selectionRange/typescript.json +75 -44
- package/data/selectionRange/vb.json +59 -39
- package/data/selectionRange/wgsl.json +61 -34
- package/data/selectionRange/xml.json +51 -34
- package/data/selectionRange/yaml.json +54 -34
- package/data/semanticTokens/angular.json +269 -198
- package/data/semanticTokens/nestjs.json +245 -35
- package/data/semanticTokens/nextjs.json +265 -38
- package/data/semanticTokens/react.json +230 -215
- package/data/semanticTokens/shadcn.json +235 -180
- package/data/signatureHelp/nestjs.json +201 -128
- package/data/signatureHelp/nextjs.json +185 -127
- package/data/signatureHelp/react.json +285 -281
- package/package.json +1 -1
package/data/hover/mdx.json
CHANGED
|
@@ -4,35 +4,280 @@
|
|
|
4
4
|
"import": {
|
|
5
5
|
"contents": [
|
|
6
6
|
{
|
|
7
|
-
"value": "**import**
|
|
7
|
+
"value": "```mdx\nimport { Button } from './components/Button'\nimport Chart from './Chart'\n```\n**import** brings JavaScript/React components into MDX. Must appear at the top of the file."
|
|
8
8
|
}
|
|
9
9
|
]
|
|
10
10
|
},
|
|
11
11
|
"export": {
|
|
12
12
|
"contents": [
|
|
13
13
|
{
|
|
14
|
-
"value": "**export**
|
|
14
|
+
"value": "```mdx\nexport const metadata = { title: 'My Post' }\n\nexport default function Layout({ children }) {\n return <article>{children}</article>\n}\n```\n**export** exposes values from MDX. `export default` sets a wrapper layout component."
|
|
15
15
|
}
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"default": {
|
|
19
19
|
"contents": [
|
|
20
20
|
{
|
|
21
|
-
"value": "**default**
|
|
21
|
+
"value": "```mdx\nexport default function Layout({ children }) {\n return <div className=\"prose\">{children}</div>\n}\n```\n**export default** defines the layout wrapper. MDX content is passed as `children`."
|
|
22
22
|
}
|
|
23
23
|
]
|
|
24
24
|
},
|
|
25
25
|
"from": {
|
|
26
26
|
"contents": [
|
|
27
27
|
{
|
|
28
|
-
"value": "**from**
|
|
28
|
+
"value": "```mdx\nimport { useState } from 'react'\nimport styles from './page.module.css'\n```\n**from** specifies the module path: npm packages, relative paths, or aliased paths."
|
|
29
29
|
}
|
|
30
30
|
]
|
|
31
31
|
},
|
|
32
32
|
"as": {
|
|
33
33
|
"contents": [
|
|
34
34
|
{
|
|
35
|
-
"value": "**as**
|
|
35
|
+
"value": "```mdx\nimport { Button as PrimaryButton } from './components'\nimport * as Icons from './icons'\n```\n**as** renames an import binding to avoid naming conflicts."
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"JSX": {
|
|
40
|
+
"contents": [
|
|
41
|
+
{
|
|
42
|
+
"value": "```mdx\n# My Article\n\nSome markdown text.\n\n<Button variant=\"primary\" onClick={() => alert('clicked')}>\n Click me\n</Button>\n```\n**JSX** can be used inline with Markdown in MDX. Components must be imported or provided via MDXProvider."
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"expression": {
|
|
47
|
+
"contents": [
|
|
48
|
+
{
|
|
49
|
+
"value": "```mdx\n# Hello {name}\n\nThe result is {2 + 2}.\n\nToday is {new Date().toLocaleDateString()}.\n```\n**Expressions** in `{}` embed JavaScript values and logic inline. Supports variables, arithmetic, and conditionals."
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"frontmatter": {
|
|
54
|
+
"contents": [
|
|
55
|
+
{
|
|
56
|
+
"value": "```mdx\n---\ntitle: Getting Started\ndescription: Learn MDX basics\nauthor: Jane Doe\ndate: 2024-01-15\n---\n```\n**Frontmatter** is YAML metadata between `---` delimiters at the top of the file."
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"MDXProvider": {
|
|
61
|
+
"contents": [
|
|
62
|
+
{
|
|
63
|
+
"value": "```jsx\nimport { MDXProvider } from '@mdx-js/react'\n\nconst components = {\n h1: props => <h1 className=\"title\" {...props} />,\n code: CodeBlock,\n a: CustomLink\n}\n\n<MDXProvider components={components}>{children}</MDXProvider>\n```\n**MDXProvider** supplies custom components that replace default HTML elements in MDX."
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"components": {
|
|
68
|
+
"contents": [
|
|
69
|
+
{
|
|
70
|
+
"value": "```mdx\nimport { Tabs, Tab } from './Tabs'\nimport { Callout } from './Callout'\n\n<Callout type=\"warning\">\n This is important!\n</Callout>\n```\n**Components** are React elements used directly in MDX for interactive, reusable content blocks."
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"heading": {
|
|
75
|
+
"contents": [
|
|
76
|
+
{
|
|
77
|
+
"value": "```mdx\n# H1 Title\n## H2 Section\n### H3 Subsection\n## Dynamic {version}\n```\n**Headings** use standard Markdown `#` syntax. Can contain JSX expressions in MDX."
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"code_block": {
|
|
82
|
+
"contents": [
|
|
83
|
+
{
|
|
84
|
+
"value": "````mdx\n```javascript title=\"example.js\" {3-4} showLineNumbers\nfunction hello() {\n console.log('Hello')\n}\n```\n````\n**Code blocks** use triple backticks with optional language, title, and line highlighting meta."
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"inline_code": {
|
|
89
|
+
"contents": [
|
|
90
|
+
{
|
|
91
|
+
"value": "```mdx\nUse the `useState` hook for state management.\n```\n**Inline code** uses single backticks. Can be customized via MDXProvider."
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"link": {
|
|
96
|
+
"contents": [
|
|
97
|
+
{
|
|
98
|
+
"value": "```mdx\n[External link](https://example.com)\n[Internal link](/docs/getting-started)\n```\n**Links** use standard Markdown syntax. Internal links are handled by framework routers."
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"image": {
|
|
103
|
+
"contents": [
|
|
104
|
+
{
|
|
105
|
+
"value": "```mdx\n\n\nimport screenshot from './screenshot.png'\n<img src={screenshot} alt=\"Screenshot\" width={600} />\n```\n**Images** use Markdown `![]()` or JSX `<img>`. Import images for bundler optimization."
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"table": {
|
|
110
|
+
"contents": [
|
|
111
|
+
{
|
|
112
|
+
"value": "```mdx\n| Feature | Supported |\n|---------|:---------:|\n| Markdown | Yes |\n| JSX | Yes |\n```\n**Tables** use pipe-delimited Markdown syntax. Colon placement controls alignment."
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"list": {
|
|
117
|
+
"contents": [
|
|
118
|
+
{
|
|
119
|
+
"value": "```mdx\n- Item one\n - Nested item\n1. First step\n- [ ] Todo incomplete\n- [x] Todo complete\n```\n**Lists** support unordered, ordered, and task list syntax. Can contain JSX as list items."
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"blockquote": {
|
|
124
|
+
"contents": [
|
|
125
|
+
{
|
|
126
|
+
"value": "```mdx\n> Standard blockquote text.\n> > Nested quote\n```\n**Blockquotes** use `>` prefix. Consider custom Callout components for better styling."
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"emphasis": {
|
|
131
|
+
"contents": [
|
|
132
|
+
{
|
|
133
|
+
"value": "```mdx\n*italic* or _italic_\n**bold** or __bold__\n***bold italic***\n~~strikethrough~~\n```\n**Text emphasis** uses standard Markdown formatting syntax."
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"hr": {
|
|
138
|
+
"contents": [
|
|
139
|
+
{
|
|
140
|
+
"value": "```mdx\n---\n```\n**Horizontal rule** creates a thematic break. Must have blank lines before and after."
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
"comment": {
|
|
145
|
+
"contents": [
|
|
146
|
+
{
|
|
147
|
+
"value": "```mdx\n{/* This is an MDX comment */}\n{/* It won't appear in the output */}\n```\n**Comments** use JSX syntax `{/* */}`. Preferred over HTML comments."
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"useState": {
|
|
152
|
+
"contents": [
|
|
153
|
+
{
|
|
154
|
+
"value": "```mdx\nimport { useState } from 'react'\n\nexport const Counter = () => {\n const [count, setCount] = useState(0)\n return <button onClick={() => setCount(c => c + 1)}>Count: {count}</button>\n}\n\n<Counter />\n```\n**useState** enables interactive state in MDX documents."
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
"props": {
|
|
159
|
+
"contents": [
|
|
160
|
+
{
|
|
161
|
+
"value": "```mdx\nexport default function Layout({ children, ...props }) {\n return <article><h1>{props.title}</h1>{children}</article>\n}\n```\n**Props** are passed to MDX documents by the rendering framework."
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
"remark_plugins": {
|
|
166
|
+
"contents": [
|
|
167
|
+
{
|
|
168
|
+
"value": "```javascript\n{\n remarkPlugins: [remarkGfm, remarkMath, remarkToc],\n rehypePlugins: [rehypeSlug, rehypeHighlight]\n}\n```\n**Plugins** extend MDX processing. Remark transforms Markdown AST, rehype transforms HTML AST."
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
"math": {
|
|
173
|
+
"contents": [
|
|
174
|
+
{
|
|
175
|
+
"value": "```mdx\nInline math: $E = mc^2$\n\n$$\n\\sum_{i=1}^{n} x_i\n$$\n```\n**Math** support requires `remark-math` and `rehype-katex` plugins. Uses LaTeX syntax."
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
"GFM": {
|
|
180
|
+
"contents": [
|
|
181
|
+
{
|
|
182
|
+
"value": "```mdx\n~~strikethrough~~\nhttps://auto.link\n- [x] task list\n| table | support |\n```\n**GFM** (GitHub Flavored Markdown) adds autolinks, tables, task lists, strikethrough. Enable with `remark-gfm`."
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
"Tabs": {
|
|
187
|
+
"contents": [
|
|
188
|
+
{
|
|
189
|
+
"value": "```mdx\nimport { Tabs, Tab } from 'nextra/components'\n\n<Tabs items={['npm', 'yarn', 'pnpm']}>\n <Tab>npm install package</Tab>\n <Tab>yarn add package</Tab>\n <Tab>pnpm add package</Tab>\n</Tabs>\n```\n**Tabs** component shows switchable panels for alternatives."
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
"Steps": {
|
|
194
|
+
"contents": [
|
|
195
|
+
{
|
|
196
|
+
"value": "```mdx\nimport { Steps } from 'nextra/components'\n\n<Steps>\n### Install dependencies\nnpm install mdx\n### Create your first file\nCreate hello.mdx\n</Steps>\n```\n**Steps** renders numbered step-by-step instructions."
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
"Callout": {
|
|
201
|
+
"contents": [
|
|
202
|
+
{
|
|
203
|
+
"value": "```mdx\nimport { Callout } from 'nextra/components'\n\n<Callout type=\"warning\">\n Be careful with this operation.\n</Callout>\n```\n**Callout** displays styled admonition blocks: `info`, `warning`, `error`, `default`."
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
"Cards": {
|
|
208
|
+
"contents": [
|
|
209
|
+
{
|
|
210
|
+
"value": "```mdx\nimport { Cards, Card } from 'nextra/components'\n\n<Cards>\n <Card title=\"Getting Started\" href=\"/docs/start\" />\n <Card title=\"API Reference\" href=\"/docs/api\" />\n</Cards>\n```\n**Cards** renders a grid of navigation cards for landing pages."
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
"FileTree": {
|
|
215
|
+
"contents": [
|
|
216
|
+
{
|
|
217
|
+
"value": "```mdx\nimport { FileTree } from 'nextra/components'\n\n<FileTree>\n <FileTree.Folder name=\"src\" defaultOpen>\n <FileTree.File name=\"index.ts\" />\n </FileTree.Folder>\n</FileTree>\n```\n**FileTree** renders an interactive file/folder tree visualization."
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
"remarkGfm": {
|
|
222
|
+
"contents": [
|
|
223
|
+
{
|
|
224
|
+
"value": "```javascript\nimport remarkGfm from 'remark-gfm'\n\nexport default {\n remarkPlugins: [remarkGfm]\n}\n```\n**remark-gfm** enables GitHub Flavored Markdown: tables, task lists, autolinks, strikethrough, footnotes."
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
"next_mdx": {
|
|
229
|
+
"contents": [
|
|
230
|
+
{
|
|
231
|
+
"value": "```javascript\nimport createMDX from '@next/mdx'\nconst withMDX = createMDX({\n extension: /\\.mdx?$/,\n options: { remarkPlugins: [], rehypePlugins: [] }\n})\nexport default withMDX({ pageExtensions: ['md', 'mdx', 'tsx'] })\n```\n**@next/mdx** integrates MDX with Next.js. MDX files become routes."
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
"compile": {
|
|
236
|
+
"contents": [
|
|
237
|
+
{
|
|
238
|
+
"value": "```javascript\nimport { compile } from '@mdx-js/mdx'\nconst code = await compile('# Hello', {\n outputFormat: 'function-body'\n})\n```\n**compile** transforms MDX source into JavaScript."
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
"evaluate": {
|
|
243
|
+
"contents": [
|
|
244
|
+
{
|
|
245
|
+
"value": "```javascript\nimport { evaluate } from '@mdx-js/mdx'\nimport * as runtime from 'react/jsx-runtime'\nconst { default: Content } = await evaluate('# Hello', runtime)\n```\n**evaluate** compiles and runs MDX at runtime. Useful for CMS or dynamic content."
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
"useMDXComponents": {
|
|
250
|
+
"contents": [
|
|
251
|
+
{
|
|
252
|
+
"value": "```typescript\nimport type { MDXComponents } from 'mdx/types'\nexport function useMDXComponents(components: MDXComponents) {\n return {\n h1: ({ children }) => <h1 className=\"text-4xl\">{children}</h1>,\n ...components\n }\n}\n```\n**useMDXComponents** (Next.js) customizes MDX element rendering globally."
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
"directive": {
|
|
257
|
+
"contents": [
|
|
258
|
+
{
|
|
259
|
+
"value": "```mdx\n:::note\nThis is a note directive.\n:::\n\n:::tip[Custom title]\nHelpful tip here.\n:::\n```\n**Directives** (via `remark-directive`) add container blocks. Used by Docusaurus."
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
"toc": {
|
|
264
|
+
"contents": [
|
|
265
|
+
{
|
|
266
|
+
"value": "```mdx\nimport { TOC } from './components/TOC'\n<TOC />\n\n## Introduction\n## Getting Started\n```\n**Table of Contents** can be auto-generated from headings or rendered with custom components."
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
},
|
|
270
|
+
"embed": {
|
|
271
|
+
"contents": [
|
|
272
|
+
{
|
|
273
|
+
"value": "```mdx\n<iframe src=\"https://codesandbox.io/embed/example\" width=\"100%\" height=\"500\" />\n\nimport { YouTube } from './components/YouTube'\n<YouTube id=\"dQw4w9WgXcQ\" />\n```\n**Embeds** use JSX to include iframes, videos, or interactive demos."
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
"aside": {
|
|
278
|
+
"contents": [
|
|
279
|
+
{
|
|
280
|
+
"value": "```mdx\nimport { Aside } from './components/Aside'\n\n<Aside>\n **Related:** See the [config guide](/docs/config).\n</Aside>\n```\n**Aside** renders supplementary content as a sidebar or margin note."
|
|
36
281
|
}
|
|
37
282
|
]
|
|
38
283
|
}
|
package/data/hover/perl.json
CHANGED
|
@@ -4,42 +4,287 @@
|
|
|
4
4
|
"variables": {
|
|
5
5
|
"contents": [
|
|
6
6
|
{
|
|
7
|
-
"value": "```perl\nmy $scalar = \"hello\"; # single value\nmy @array = (1, 2, 3); # ordered list\nmy %hash = (a => 1); # key-value pairs\n
|
|
7
|
+
"value": "```perl\nmy $scalar = \"hello\"; # single value\nmy @array = (1, 2, 3); # ordered list\nmy %hash = (a => 1); # key-value pairs\n$array[0] # array element\n$hash{key} # hash value\n```\n**Variable types** — `$` scalar, `@` array, `%` hash. Sigils change based on access context."
|
|
8
8
|
}
|
|
9
9
|
]
|
|
10
10
|
},
|
|
11
11
|
"regex": {
|
|
12
12
|
"contents": [
|
|
13
13
|
{
|
|
14
|
-
"value": "```perl\n$str =~ /pattern/; # match\n$str =~ s/old/new/g; # substitute\n$str =~ tr/a-z/A-Z/; # transliterate\nif ($str =~ /^(\\w+)/) {\n print \"$1\\n\"
|
|
14
|
+
"value": "```perl\n$str =~ /pattern/; # match\n$str =~ s/old/new/g; # substitute\n$str =~ tr/a-z/A-Z/; # transliterate\nif ($str =~ /^(\\w+)/) {\n print \"$1\\n\";\n}\n```\n**Regex** is Perl's superpower. `=~` binds, `!~` negates. Captures in `$1`, `$2`, etc."
|
|
15
15
|
}
|
|
16
16
|
]
|
|
17
17
|
},
|
|
18
18
|
"file_io": {
|
|
19
19
|
"contents": [
|
|
20
20
|
{
|
|
21
|
-
"value": "```perl\nopen(my $fh, '<', 'file.txt') or die $!;\nwhile (<$fh>) {
|
|
21
|
+
"value": "```perl\nopen(my $fh, '<', 'file.txt') or die $!;\nwhile (<$fh>) {\n chomp;\n print \"$_\\n\";\n}\nclose($fh);\n```\n**File I/O** uses three-arg open. `<` read, `>` write, `>>` append. `<$fh>` reads line by line."
|
|
22
22
|
}
|
|
23
23
|
]
|
|
24
24
|
},
|
|
25
25
|
"one_liners": {
|
|
26
26
|
"contents": [
|
|
27
27
|
{
|
|
28
|
-
"value": "```bash\
|
|
28
|
+
"value": "```bash\nperl -pi -e 's/old/new/g' file.txt\nperl -ne 'print if /pattern/' file.txt\nperl -ane '$s+=$F[0]; END{print $s}' data.txt\n```\n**One-liners** — `-n` loops, `-p` loops with print, `-i` in-place edit, `-a` autosplit."
|
|
29
29
|
}
|
|
30
30
|
]
|
|
31
31
|
},
|
|
32
32
|
"special_vars": {
|
|
33
33
|
"contents": [
|
|
34
34
|
{
|
|
35
|
-
"value": "```perl\n$_ # default variable\n@_ # subroutine arguments\n$! # system error message\n$@ # eval error\n$/ # input record separator\n
|
|
35
|
+
"value": "```perl\n$_ # default variable\n@_ # subroutine arguments\n$! # system error message\n$@ # eval error\n$/ # input record separator\n$0 # program name\n```\n**Special variables** — `$_` is default for many functions."
|
|
36
36
|
}
|
|
37
37
|
]
|
|
38
38
|
},
|
|
39
39
|
"strict": {
|
|
40
40
|
"contents": [
|
|
41
41
|
{
|
|
42
|
-
"value": "```perl\nuse strict
|
|
42
|
+
"value": "```perl\nuse strict;\nuse warnings;\n```\n**strict** and **warnings** should always be enabled. They catch typos and common bugs."
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
},
|
|
46
|
+
"my": {
|
|
47
|
+
"contents": [
|
|
48
|
+
{
|
|
49
|
+
"value": "```perl\nmy $x = 10;\nmy @list = (1, 2, 3);\nmy %map = (key => 'val');\n```\n**my** declares a lexically scoped variable. Always preferred over package globals."
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"our": {
|
|
54
|
+
"contents": [
|
|
55
|
+
{
|
|
56
|
+
"value": "```perl\nour $VERSION = '1.0';\nour @EXPORT = qw(func1 func2);\n```\n**our** declares a package global variable. Visible across the package. Use sparingly."
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"local": {
|
|
61
|
+
"contents": [
|
|
62
|
+
{
|
|
63
|
+
"value": "```perl\nlocal $/ = undef; # slurp mode\nmy $content = <$fh>;\n```\n**local** temporarily overrides a global variable. Value is restored when scope exits. Use for `$/`, `$\\`, etc."
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
"sub": {
|
|
68
|
+
"contents": [
|
|
69
|
+
{
|
|
70
|
+
"value": "```perl\nsub greet {\n my ($name) = @_;\n return \"Hello, $name!\";\n}\nmy $result = greet('World');\n```\n**sub** defines a subroutine. Arguments in `@_`. Use `my` to unpack. Returns last expression or explicit `return`."
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
"chomp": {
|
|
75
|
+
"contents": [
|
|
76
|
+
{
|
|
77
|
+
"value": "```perl\nchomp(my $line = <STDIN>);\nchomp(@lines);\n```\n**chomp** removes the trailing newline from a string. Safe to call multiple times. Returns number of chars removed."
|
|
78
|
+
}
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
"chop": {
|
|
82
|
+
"contents": [
|
|
83
|
+
{
|
|
84
|
+
"value": "```perl\nchop($string);\n```\n**chop** removes the last character regardless of what it is. Use `chomp` to remove only newlines."
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"split": {
|
|
89
|
+
"contents": [
|
|
90
|
+
{
|
|
91
|
+
"value": "```perl\nmy @fields = split(/,/, $line);\nmy @words = split(' ', $text);\nmy ($user, $pass) = split(/:/, $entry, 2);\n```\n**split** divides a string by a pattern. Third arg limits the number of fields."
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
"join": {
|
|
96
|
+
"contents": [
|
|
97
|
+
{
|
|
98
|
+
"value": "```perl\nmy $csv = join(',', @fields);\nmy $path = join('/', @parts);\n```\n**join** concatenates list elements with a separator string."
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
"push": {
|
|
103
|
+
"contents": [
|
|
104
|
+
{
|
|
105
|
+
"value": "```perl\npush @array, $value;\npush @array, @more_values;\n```\n**push** appends elements to the end of an array. Returns the new array length."
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"pop": {
|
|
110
|
+
"contents": [
|
|
111
|
+
{
|
|
112
|
+
"value": "```perl\nmy $last = pop @array;\n```\n**pop** removes and returns the last element of an array."
|
|
113
|
+
}
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
"shift": {
|
|
117
|
+
"contents": [
|
|
118
|
+
{
|
|
119
|
+
"value": "```perl\nmy $first = shift @array;\nmy $arg = shift; # shifts @_ in sub\n```\n**shift** removes and returns the first element. In subs, `shift` without args shifts `@_`."
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
},
|
|
123
|
+
"unshift": {
|
|
124
|
+
"contents": [
|
|
125
|
+
{
|
|
126
|
+
"value": "```perl\nunshift @array, $value;\n```\n**unshift** prepends elements to the beginning of an array."
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
},
|
|
130
|
+
"map": {
|
|
131
|
+
"contents": [
|
|
132
|
+
{
|
|
133
|
+
"value": "```perl\nmy @doubled = map { $_ * 2 } @numbers;\nmy @upper = map { uc($_) } @strings;\n```\n**map** transforms each element of a list. Returns a new list. The block receives `$_`."
|
|
134
|
+
}
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"grep": {
|
|
138
|
+
"contents": [
|
|
139
|
+
{
|
|
140
|
+
"value": "```perl\nmy @evens = grep { $_ % 2 == 0 } @numbers;\nmy @matches = grep { /pattern/ } @lines;\n```\n**grep** filters a list. Returns elements where the block evaluates to true."
|
|
141
|
+
}
|
|
142
|
+
]
|
|
143
|
+
},
|
|
144
|
+
"sort": {
|
|
145
|
+
"contents": [
|
|
146
|
+
{
|
|
147
|
+
"value": "```perl\nmy @sorted = sort @array;\nmy @num = sort { $a <=> $b } @numbers;\nmy @rev = sort { $b cmp $a } @strings;\n```\n**sort** orders a list. `<=>` for numeric, `cmp` for string comparison. `$a`/`$b` are special sort variables."
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
},
|
|
151
|
+
"chomp_line": {
|
|
152
|
+
"contents": [
|
|
153
|
+
{
|
|
154
|
+
"value": "```perl\nwhile (my $line = <$fh>) {\n chomp $line;\n # process\n}\n```\n**Diamond operator** `<>` reads one line at a time. Returns `undef` at EOF. `<STDIN>` reads from standard input."
|
|
155
|
+
}
|
|
156
|
+
]
|
|
157
|
+
},
|
|
158
|
+
"die": {
|
|
159
|
+
"contents": [
|
|
160
|
+
{
|
|
161
|
+
"value": "```perl\nopen(my $fh, '<', $file) or die \"Cannot open $file: $!\";\ndie \"Something went wrong\" unless $condition;\n```\n**die** throws an exception. Usually paired with `or` for error handling. `$!` contains the system error."
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
},
|
|
165
|
+
"warn": {
|
|
166
|
+
"contents": [
|
|
167
|
+
{
|
|
168
|
+
"value": "```perl\nwarn \"This is a warning\\n\";\n```\n**warn** prints a message to STDERR without terminating. Adds file and line number if no trailing newline."
|
|
169
|
+
}
|
|
170
|
+
]
|
|
171
|
+
},
|
|
172
|
+
"eval": {
|
|
173
|
+
"contents": [
|
|
174
|
+
{
|
|
175
|
+
"value": "```perl\neval {\n # risky code\n 1;\n} or do {\n my $err = $@;\n warn \"Caught: $err\";\n};\n```\n**eval** block catches exceptions. Check `$@` for error. The block form is preferred over string eval."
|
|
176
|
+
}
|
|
177
|
+
]
|
|
178
|
+
},
|
|
179
|
+
"ref": {
|
|
180
|
+
"contents": [
|
|
181
|
+
{
|
|
182
|
+
"value": "```perl\nmy $aref = [1, 2, 3]; # array ref\nmy $href = {a => 1, b => 2}; # hash ref\nmy $type = ref($aref); # 'ARRAY'\n@{$aref} # dereference array\n%{$href} # dereference hash\n```\n**References** — `\\` creates references, `${}`, `@{}`, `%{}` dereference. `ref()` returns the type."
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
},
|
|
186
|
+
"bless": {
|
|
187
|
+
"contents": [
|
|
188
|
+
{
|
|
189
|
+
"value": "```perl\npackage Dog;\nsub new {\n my ($class, %args) = @_;\n return bless \\%args, $class;\n}\nsub bark { print \"Woof!\\n\" }\n```\n**bless** associates a reference with a class (package). This is Perl's OOP mechanism."
|
|
190
|
+
}
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
"use": {
|
|
194
|
+
"contents": [
|
|
195
|
+
{
|
|
196
|
+
"value": "```perl\nuse strict;\nuse warnings;\nuse File::Basename;\nuse List::Util qw(sum max min);\n```\n**use** loads a module at compile time. `qw()` imports specific functions. Equivalent to `BEGIN { require Module; Module->import(...) }`."
|
|
197
|
+
}
|
|
198
|
+
]
|
|
199
|
+
},
|
|
200
|
+
"require": {
|
|
201
|
+
"contents": [
|
|
202
|
+
{
|
|
203
|
+
"value": "```perl\nrequire 'config.pl';\nrequire Module::Name;\n```\n**require** loads a file or module at runtime. Unlike `use`, it doesn't call `import()`."
|
|
204
|
+
}
|
|
205
|
+
]
|
|
206
|
+
},
|
|
207
|
+
"package": {
|
|
208
|
+
"contents": [
|
|
209
|
+
{
|
|
210
|
+
"value": "```perl\npackage MyApp::Utils;\nuse Exporter 'import';\nour @EXPORT_OK = qw(helper_func);\n```\n**package** declares a namespace. Use `Exporter` to make functions importable by other code."
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
},
|
|
214
|
+
"qw": {
|
|
215
|
+
"contents": [
|
|
216
|
+
{
|
|
217
|
+
"value": "```perl\nmy @list = qw(apple banana cherry);\nuse POSIX qw(floor ceil);\n```\n**qw()** creates a list of strings split on whitespace. No commas or quotes needed."
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
"print": {
|
|
222
|
+
"contents": [
|
|
223
|
+
{
|
|
224
|
+
"value": "```perl\nprint \"Hello, World!\\n\";\nprint $fh \"data\\n\";\nprint STDERR \"error\\n\";\n```\n**print** outputs to a filehandle (default STDOUT). No parentheses needed. Does not add newline."
|
|
225
|
+
}
|
|
226
|
+
]
|
|
227
|
+
},
|
|
228
|
+
"say": {
|
|
229
|
+
"contents": [
|
|
230
|
+
{
|
|
231
|
+
"value": "```perl\nuse feature 'say';\nsay \"Hello, World!\";\nsay $fh \"data\";\n```\n**say** is like `print` but automatically adds a newline. Requires `use feature 'say'` or `use v5.10`."
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
},
|
|
235
|
+
"printf": {
|
|
236
|
+
"contents": [
|
|
237
|
+
{
|
|
238
|
+
"value": "```perl\nprintf \"%-20s %5d %8.2f\\n\", $name, $age, $score;\nsprintf(\"%.2f\", $value);\n```\n**printf** formatted output. `sprintf` returns the string instead of printing."
|
|
239
|
+
}
|
|
240
|
+
]
|
|
241
|
+
},
|
|
242
|
+
"chomp_vs_chop": {
|
|
243
|
+
"contents": [
|
|
244
|
+
{
|
|
245
|
+
"value": "```perl\nchomp $str; # remove trailing \\n only\nchop $str; # remove last char (any)\n```\n**chomp** vs **chop** — `chomp` is usually what you want; it only removes the input record separator."
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
},
|
|
249
|
+
"exists": {
|
|
250
|
+
"contents": [
|
|
251
|
+
{
|
|
252
|
+
"value": "```perl\nif (exists $hash{key}) { ... }\nif (exists $array[5]) { ... }\n```\n**exists** checks if a hash key or array index has been defined. Doesn't trigger autovivification."
|
|
253
|
+
}
|
|
254
|
+
]
|
|
255
|
+
},
|
|
256
|
+
"delete": {
|
|
257
|
+
"contents": [
|
|
258
|
+
{
|
|
259
|
+
"value": "```perl\ndelete $hash{key};\ndelete $array[3];\n```\n**delete** removes a key from a hash or an element from an array."
|
|
260
|
+
}
|
|
261
|
+
]
|
|
262
|
+
},
|
|
263
|
+
"defined": {
|
|
264
|
+
"contents": [
|
|
265
|
+
{
|
|
266
|
+
"value": "```perl\nif (defined $value) { ... }\nmy $name = $input // 'default';\n```\n**defined** checks if a value is not `undef`. `//` (defined-or) provides a default for undefined values."
|
|
267
|
+
}
|
|
268
|
+
]
|
|
269
|
+
},
|
|
270
|
+
"foreach": {
|
|
271
|
+
"contents": [
|
|
272
|
+
{
|
|
273
|
+
"value": "```perl\nforeach my $item (@list) {\n print \"$item\\n\";\n}\n\nfor my $i (0 .. $#array) {\n print \"$i: $array[$i]\\n\";\n}\n```\n**foreach** iterates over a list. `for` and `foreach` are interchangeable. `$#array` is the last index."
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
},
|
|
277
|
+
"while": {
|
|
278
|
+
"contents": [
|
|
279
|
+
{
|
|
280
|
+
"value": "```perl\nwhile (<$fh>) {\n chomp;\n process($_);\n}\n\nwhile (my ($k, $v) = each %hash) {\n print \"$k => $v\\n\";\n}\n```\n**while** loops. Commonly used with filehandle reads and `each` for hash iteration."
|
|
281
|
+
}
|
|
282
|
+
]
|
|
283
|
+
},
|
|
284
|
+
"unless": {
|
|
285
|
+
"contents": [
|
|
286
|
+
{
|
|
287
|
+
"value": "```perl\nunless ($condition) {\n print \"Not true\\n\";\n}\ndie \"Error\" unless $ok;\n```\n**unless** is the opposite of `if`. Executes when the condition is false. Avoid `unless ... else`."
|
|
43
288
|
}
|
|
44
289
|
]
|
|
45
290
|
}
|