### Basic Dockerfile Setup Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/dockerfile/default.txt This Dockerfile sets up a basic PHP-FPM environment. It installs necessary packages and configures the working directory and command. ```dockerfile FROM ubuntu MAINTAINER laurent@docker.com ARG debug=0 COPY www.conf /etc/php5/fpm/pool.d/ RUN apt-get update \ && apt-get install -y php5-fpm php-apc php5-curl php5-gd php5-intl php5-mysql RUN mkdir /tmp/sessions ENV APPLICATION_ENV dev USER www-data EXPOSE 80 VOLUME ["/var/www/html"] WORKDIR "/var/www/html" CMD [ "/usr/sbin/php5-fpm", "-F" ] ``` -------------------------------- ### Copying Configuration and Installing Packages Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/dockerfile/default.expect.txt This snippet demonstrates copying a configuration file and installing necessary PHP-FPM packages using apt-get. ```dockerfile COPY www.conf /etc/php5/fpm/pool.d/ RUN apt-get update \ && apt-get install -y php5-fpm php-apc php5-curl php5-gd php5-intl php5-mysql ``` -------------------------------- ### Installing Software with RUN Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/dockerfile.txt Installs multiple packages using apt-get update and install. Also demonstrates running a command with arguments. ```dockerfile RUN apt-get update && apt-get install -y software-properties-common zsh curl wget git htop unzip vim telnet ``` ```dockerfile RUN ["/bin/bash", "-c", "echo hello ${USER}"] ``` -------------------------------- ### Preview with Language, Limit, and Start Offset Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with a specified width, language, limit, and start offset for samples. ```sh node examples/preview.js --width=80 --lang typescript --limit=10 --start=0 ``` -------------------------------- ### Theme Configuration Example Source: https://github.com/webdiscus/ansilight/blob/master/tools/build-theme/README.md Example JSON configuration for the theme build process. Specifies source directory, target directory, and a list of themes to convert. ```json { "sourceDir": "node_modules/highlight.js/styles", "targetDir": "themes", "themes": [ "default", "github", "vs", "vs2015" ] } ``` -------------------------------- ### Preview with Language, Limit, and Different Start Offset Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with a specified width, language, limit, and a different start offset for samples. ```sh node examples/preview.js --width=80 --lang typescript --limit=10 --start=100 ``` -------------------------------- ### Screenshot Themes Configuration Example Source: https://github.com/webdiscus/ansilight/blob/master/tools/screenshot-themes/README.md Example JSON configuration for the screenshot themes tool. Customize options like language, dimensions, output paths, and display delays. ```json { "lang": "javascript", "width": 100, "padding": 1, "start": 0, "limit": 1, "header": false, "footer": false, "themes": [], "outputDir": "docs/theme-screenshots", "galleryPath": "docs/theme-gallery.md", "galleryColumns": 2, "crop": "auto", "cropTolerance": 24, "cropPadding": 0, "openWindowDelay": 800, "displayDelay": 150, "closeWindow": true } ``` -------------------------------- ### POST Request Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/http/default.expect.txt This example shows a basic POST request with JSON payload. Ensure the Content-Type and Content-Length headers are correctly set. ```http POST /task?id=1 HTTP/1.1 Host: example.org Content-Type: application/json; charset=utf-8 Content-Length: 19 {"status": "ok", "extended": true} ``` -------------------------------- ### Basic Dockerfile Setup Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/dockerfile.txt Sets the base image, maintainer, environment variables, and working directory. ```dockerfile FROM ubuntu:14.04 MAINTAINER example@example.com ENV foo /bar WORKDIR ${foo} # WORKDIR /bar ADD . $foo # ADD . /bar COPY $foo /quux # COPY $foo /quux ARG VAR=FOO ``` -------------------------------- ### Setting the Command to Run Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/dockerfile/default.expect.txt This snippet specifies the command to execute when the container starts. ```dockerfile CMD [ "/usr/sbin/php5-fpm", "-F" ] ``` -------------------------------- ### Basic Dockerfile Setup Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/dockerfile/default.expect.txt This snippet shows the fundamental instructions for building a Docker image, including the base image, maintainer information, and argument definitions. ```dockerfile FROM ubuntu MAINTAINER laurent@docker.com ARG debug=0 ``` -------------------------------- ### GraphQL Input Type Example Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/graphql.txt Illustrates a GraphQL input type for story-like subscriptions. ```graphql input StoryLikeSubscribeInput { storyId: string clientSubscriptionId: string } ``` -------------------------------- ### More Inline Code Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/markdown/code.txt Another example of inline code. ```text more code ``` -------------------------------- ### Install Ansilight Source: https://github.com/webdiscus/ansilight/blob/master/README.npm.md Install the ansilight package using npm. Requires Node.js 18+ and is ESM only. ```sh npm install ansilight ``` -------------------------------- ### Group by Theme Example Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Demonstrates grouping snippets by theme when multiple themes and languages are specified. ```sh node examples/preview.js --theme github vs2015 --lang scss javascript --group theme ``` -------------------------------- ### GraphQL Mutation Example Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/graphql.txt Demonstrates a GraphQL mutation with variables and conditional inclusion of fields. ```graphql mutation Hero($episode: Episode, $withFriends: Boolean!) { hero(episode: $episode) { name friends @include(if: $withFriends) { name ... on Droid { primaryFunction } ... on Human { height } } } } ``` -------------------------------- ### GraphQL Query Example Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/graphql.txt Shows a basic GraphQL query to retrieve hero's name and friends. ```graphql query HeroNameAndFriends { hero { name friends { name } } } ``` -------------------------------- ### Group by Language Example Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Demonstrates grouping snippets by language when multiple themes and languages are specified. ```sh node examples/preview.js --theme github vs2015 --lang css typescript --group lang ``` -------------------------------- ### Using keywords 'class', 'set', 'get', and 'valid' as identifiers Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/keyword_as_identifier.expect.txt Demonstrates using keywords like 'class', 'set', 'get', and 'valid' as identifiers for a class and its methods/properties. This syntax is supported in modern JavaScript. ```javascript class A { set value(x) { } get valid() { } } ``` -------------------------------- ### Basic XML Structure Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/xml.txt A simple example of an XML document structure. ```xml Content ``` -------------------------------- ### GraphQL Fragment Example Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/graphql.txt Defines a reusable GraphQL fragment for character comparison fields. ```graphql fragment comparisonFields on Character { name appearsIn friends { name } } ``` -------------------------------- ### CSS Keyframes Animation Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/css/sample.txt Defines an animation named 'example' with vendor prefixes for cross-browser compatibility. ```css @-ms-keyframes example { from {background-color: red;} to {background-color: yellow;} } ``` ```css @-o-keyframes example { from {background-color: red;} to {background-color: yellow;} } ``` -------------------------------- ### Importing Modules in Main.js Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/modules.txt Shows how to import named exports, default exports, and aliased exports from another module. Also includes an example of a dynamic import. ```javascript //------ main.js ------ import _, { each, something as otherthing } from 'underscore'; const file = import("https://file.io/file.js") ``` -------------------------------- ### CSS Pseudo-class and Pseudo-element Examples Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/css/css_consistency.expect.txt Covers highlighting for a visited pseudo-class and pseudo-elements like ::after and ::before with content. Includes both double-colon and single-colon syntax for pseudo-elements. ```css a:visited { color: blue; } div::after { content: "test"; } div:after { content: "test"; } div::before { content: open-quote; } div:before { content: open-quote; } ``` -------------------------------- ### Basic UNION ALL Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/sql/set-operator.expect.txt Demonstrates the UNION ALL operator to combine rows from two VALUES clauses. UNION ALL includes all rows, including duplicates. ```sql SELECT * FROM VALUES 1, 2, 3 UNION ALL VALUES 1, 2, 3; ``` -------------------------------- ### Valid Arrow Function Syntaxes Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/arrow-function.txt Examples of correctly formed arrow functions. ```javascript const good = () => 0; ``` ```javascript const good = (x) => 0; ``` -------------------------------- ### Analyze Theme Scopes and Snippets Source: https://github.com/webdiscus/ansilight/blob/master/tools/README.md Run these commands to analyze highlight.js theme token scopes and check the coverage of example snippets. The output will be saved in the reports directory. ```sh npm run analyze-theme-scopes ``` ```sh npm run analyze-snippets-coverage ``` ```sh npm run analyze-snippets ``` -------------------------------- ### Setting Default Command with CMD Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/dockerfile.txt Specifies the default command to run when a container starts. Supports both exec and shell forms. ```dockerfile CMD ["executable","param1","param2"] ``` ```dockerfile CMD command param1 param2 ``` -------------------------------- ### Inline Code Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/markdown/code.expect.txt Shows how to format inline code using backticks. This is useful for referencing variables, functions, or short code snippets within prose. ```plaintext `code` ``` ```plaintext `more code` ``` -------------------------------- ### GraphQL Query Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/graphql/default.txt This query retrieves hero information for a specific episode, including droid or human specific fields. ```graphql query HeroForEpisode($ep: Episode!) { hero(episode: $ep) { name ... on Droid { primaryFunction } ... on Human { height } } } ``` -------------------------------- ### CSS Attribute and Language Selectors Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/css/sample.expect.txt Selects elements based on attribute values (href containing 'example') and language codes (lang starting with 'en'). Increases font size. ```css a[href*="example"], *[lang^=en] { font-size: 2em; } ``` -------------------------------- ### Class with Decorators and Decorator Factories Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/decorator-factories.expect.txt Demonstrates applying various decorators, including those created by factories, to a class, its properties, constructor parameters, and methods. This example showcases the flexibility of decorator factories in configuring decorator behavior. ```typescript export class MyClass { @baz(123) private myAttribute: string; constructor( @bar(true) private x, @bar(qux(quux(true))) private y) { } @bar() private myMethod( @bar() z) { console.log( 'Hello world.' ); } } ``` -------------------------------- ### Binary, Hexadecimal, and Octal Literals Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/numbers.txt Shows binary, hexadecimal, and octal literals, including examples with underscore separators. ```javascript let nibbles = 0b1010_0001_1000_0101; let message = 0xA0_B0_C0; ``` ```javascript 0xff 0xdead_beef ``` ```javascript 0o52 0O52 ``` -------------------------------- ### Basic Preview with Theme Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a basic preview with a specified width and theme. ```sh node examples/preview.js --width=80 --theme github ``` -------------------------------- ### Preview with Theme and Limit Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with a specified width, theme, and a limit on the number of samples. ```sh node examples/preview.js --width=80 --theme github --limit=30 ``` -------------------------------- ### Preview with Theme and Single Language Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with a specified width, theme, and a single language. ```sh node examples/preview.js --width=80 --theme github --lang css ``` -------------------------------- ### Preview with Multiple Themes and Limit Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with a specified width, multiple themes, and a limit on the number of samples. ```sh node examples/preview.js --width=80 --theme github vs2015 --limit=60 ``` -------------------------------- ### Preview with Theme and Multiple Languages Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with a specified width, theme, and multiple languages. ```sh node examples/preview.js --width=80 --theme github --lang css typescript ``` -------------------------------- ### Integer Number Literals in Haskell Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/haskell/numbers.expect.txt Shows integer literals. The 'g0' example demonstrates a standard integer. The 'h' prefixed examples showcase hexadecimal integer representations, including the use of underscores for improved readability. ```haskell g0 = 1e+23 h0 = 0xffff h1 = 0xff_ff h2 = 0x_ffff h3 = 0x__ffff ``` -------------------------------- ### Executing Java Shell Commands with Heredoc Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/bash/strings.expect.txt This example shows how to execute Java shell commands using a heredoc. The 'jshell' command is used to run Java code, with input provided between 'EOF' markers. ```bash jshell -s - << EOF System.out.printf("Procs: %s%n", getdata()) EOF ``` -------------------------------- ### TypeScript Decorator Factory Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/decorator-factories.txt This example shows a TypeScript class with decorators applied to the class itself, a private attribute, constructor parameters, and a private method. Decorator factories like @foo('foo'), @baz(123), and @bar(true) are used to configure the decorators with specific values. ```typescript @foo('foo') export class MyClass { @baz(123) private myAttribute: string; constructor(@bar(true) private x, @bar(qux(quux(true))) private y) { } @bar() private myMethod(@bar() z) { console.log('Hello world.'); } } ``` -------------------------------- ### GraphQL Mutation Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/graphql/default.txt Use this mutation to update project details in the urban database. Ensure you provide valid urbanDatabaseId, GlobalID, Description, and studyArea. ```graphql mutation updateMyUrbanEvent($studyArea: PolygonInput!, $myDescription: String!) { updateProjects( urbanDatabaseId : "9c3ba6c054f945acabd1256bcbcf8XXX" projects : [{ attributes: { GlobalID: "078D217A-1764-4AA2-9D23-6FCDA01F0XXX", Description: $myDescription }, geometry: $studyArea }] ) { attributes { GlobalID CustomID Description } geometry { rings } } } ``` -------------------------------- ### Run Theme Build Source: https://github.com/webdiscus/ansilight/blob/master/tools/build-theme/README.md Execute the theme build process. Use this to convert all default highlight.js themes. ```sh npm run build-theme ``` -------------------------------- ### Indented JavaScript Code Block Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/markdown/code.txt An example of an indented JavaScript code block. ```javascript can be indented ``` -------------------------------- ### Preview with Multiple Themes, Languages, and Grouping by Language Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with multiple themes and languages, grouped by language. ```sh node examples/preview.js --width=80 --theme github github-dark --lang css typescript --group lang ``` -------------------------------- ### JSX Return Statement Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/jsx.txt Example of returning a JSX element from a function or component. ```javascript return (); ``` -------------------------------- ### Preview with Single Language Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with a specified language. ```sh node examples/preview.js --lang css ``` -------------------------------- ### Passing Variables to 'cat' with Here-Strings Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/bash/strings.expect.txt These examples illustrate different ways to pass a Bash variable to the 'cat' command using here-strings. They show variations in quoting and variable expansion. ```bash cat <<< '$VARIABLE' ``` ```bash cat <<< "$VARIABLE" ``` ```bash cat <<< $VARIABLE ``` ```bash cat <<< `$VARIABLE` ``` -------------------------------- ### Preview with Multiple Themes, Languages, and Grouping by Theme Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with multiple themes and languages, grouped by theme. ```sh node examples/preview.js --width=80 --theme github github-dark --lang css typescript --group theme ``` -------------------------------- ### Build All Themes Source: https://github.com/webdiscus/ansilight/blob/master/tools/build-theme/README.md Convert all available highlight.js themes. This is a comprehensive build option. ```sh npm run build-theme -- --all ``` -------------------------------- ### Basic Arithmetic Expression in Regex Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/regex.expect.txt Demonstrates a basic arithmetic expression within a regex pattern. This example highlights how numbers and division operators can be part of a regex. ```javascript `Bad ${foo / 1000}` ``` -------------------------------- ### Bash Command with Number Argument Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/bash/no-numbers.expect.txt This example shows a typical Bash command where a number is used as an argument. Bash does not strictly define the semantics for numbers as command-line parameters, which affects how they are highlighted. ```bash tail -10 access.log ``` -------------------------------- ### Multi-line Docker Run Command Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/shell/command-continuation.txt Use a backslash to continue a long `docker run` command across multiple lines. This improves readability for complex container setups. ```shell $ docker run \ --publish=7474:7474 --publish=7687:7687 \ --volume=/neo4j/data:/data \ --volume=/neo4j/plugins:/plugins \ --volume=/neo4j/conf:/conf \ --volume=/logs/neo4j:/logs \ --user="$(id -u neo4j):$(id -g neo4j)" \ --group-add=$groups \ neo4j:3.4 ``` -------------------------------- ### Invalid Numeric Literals Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/numbers.expect.txt Illustrates examples that are not valid numeric literals, such as identifiers that resemble numbers. ```typescript let x1 = _52; // This is an identifier, not a numeric literal ``` -------------------------------- ### Setting Entrypoint with ENTRYPOINT Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/dockerfile.txt Configures a container that will run as an executable. Supports both exec and shell forms. ```dockerfile ENTRYPOINT ["executable", "param1", "param2"] ``` ```dockerfile ENTRYPOINT command param1 param2 ``` -------------------------------- ### Preview with Multiple Languages Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with multiple specified languages. ```sh node examples/preview.js --lang css typescript ``` -------------------------------- ### Invalid Pseudo-Numeric Expressions Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/numbers.txt Lists examples of invalid numeric literal syntax that will result in errors. ```javascript // invalid pseudo-numeric expressions 1__0 0b1__0 1e_1 0b1e1 0N 00. ``` -------------------------------- ### Show Interface Configuration Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/shell/prompt-with-slash.expect.txt View the current configuration of a specific interface. This command helps in verifying applied settings and troubleshooting. ```shell show configuration ``` -------------------------------- ### Applying SCSS Mixin to a Selector Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/scss/default.expect.txt Shows how to apply the 'button' mixin with a specific parameter to a CSS selector. This example demonstrates calling the mixin with 'red' to set the button's background color. ```scss button { @include button(red); } ``` -------------------------------- ### Using Keywords as Accessor Identifiers in Classes Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/keyword_as_identifier.txt Illustrates the use of keywords like 'set' and 'get' as identifiers for setter and getter methods within a JavaScript class. This syntax is supported in modern JavaScript. ```javascript class A { set value(x) { } get valid() { } } ``` -------------------------------- ### Fenced Code Block Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/markdown.txt Demonstrates a standard fenced code block for multi-line code examples. ```markdown so are code segments ``` -------------------------------- ### Create Products Table Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/sql/combos.expect.txt Creates a 'products' table with an auto-incrementing primary key, name, and price. ```sql CREATE TABLE products ( product_id INT PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100), price DECIMAL(10, 2) ); ``` -------------------------------- ### Preview with Extra Languages Source: https://github.com/webdiscus/ansilight/blob/master/examples/README.md Run a preview with custom extra languages. ```sh node examples/preview.js --lang extra-css extra-typescript ``` -------------------------------- ### Expressions Containing Numeric Literals Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/numbers.txt Shows examples of expressions where numeric literals are used, such as calling methods on them. ```javascript // expressions containing numeric literals 0..toString, 1e1.toString, fn(.5) ``` -------------------------------- ### JavaScript Template Literal Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/inline-languages.txt A basic JavaScript template literal example showing conditional string interpolation. ```javascript let foo = true; `hello ${foo ? `Mr ${name}` : 'there'}`; foo = false; ``` -------------------------------- ### Invalid Arrow Function Syntaxes Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/arrow-function.txt Examples of incorrect arrow function syntax that would cause errors. ```javascript const bad = (a => [...a, b]); ``` ```javascript const bad = (_ => doSomething()); ``` ```javascript const bad = (() => 0); ``` ```javascript const bad = ((a, b) => [...a, b]); ``` -------------------------------- ### Setting XML Options Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/pgsql/xml.expect.txt Illustrates how to set the XML option for document or content processing. ```SQL SET XML OPTION DOCUMENT; ``` ```SQL SET XML OPTION CONTENT; ``` -------------------------------- ### Import and Use Custom Theme Source: https://github.com/webdiscus/ansilight/blob/master/README.md Import a custom theme file copied into your project to style code with Ansilight. ```js import ansilight from 'ansilight'; import theme from './stackoverflow-light.js'; console.log(ansilight(code, { theme })); ``` -------------------------------- ### Expressions Not Containing Numeric Literals Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/numbers.txt Provides examples of expressions that might appear similar but do not contain numeric literals themselves. ```javascript // expressions not containing numeric literals x0.e1 ``` -------------------------------- ### Creating Session Directory and Setting Environment Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/dockerfile/default.expect.txt This snippet includes creating a directory for sessions and setting the application environment variable. ```dockerfile RUN mkdir /tmp/sessions ENV APPLICATION_ENV dev ``` -------------------------------- ### Build Specific Themes Source: https://github.com/webdiscus/ansilight/blob/master/tools/build-theme/README.md Convert a specific list of highlight.js themes. Provide theme names separated by spaces. ```sh npm run build-theme -- --name default github vs2015 ``` -------------------------------- ### Simplified Arithmetic Expression Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/regex.expect.txt Presents a simplified arithmetic expression. This example is a more concise version of basic arithmetic operations. ```javascript foo = / 2 + 2 /; ``` -------------------------------- ### Haml Lists with Attributes and Loops Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/haml/default.expect.txt Illustrates creating an unordered list with inline styles and iterating over items using Haml's loop syntax. ```Haml %ul{style: 'margin: 0'} -items.each do |i| %li= i ``` -------------------------------- ### Invalid String Literal with Unmatched Quotes Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/haskell/char.expect.txt This example shows an invalid string literal with unmatched single quotes. ```Haskell t10 = a'' ``` -------------------------------- ### Invalid Unclosed Character Literal Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/haskell/char.expect.txt An unclosed single-quoted literal is invalid. This example shows an unclosed character literal. ```Haskell t7 = 'a ``` -------------------------------- ### XML with Namespaces Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/xml.txt Demonstrates the use of namespaces in an XML document. ```xml Content ``` -------------------------------- ### Run Screenshot Themes Tool Source: https://github.com/webdiscus/ansilight/blob/master/tools/screenshot-themes/README.md Execute the screenshot themes tool using a specified configuration file. This command generates PNG screenshots and a markdown gallery. ```sh node tools/screenshot-themes/screenshot-themes.js --config tools/screenshot-themes/screenshot-themes.config.example.json ``` -------------------------------- ### TypeScript 'as' Keyword Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/satisfies-and-as.expect.txt Uses the 'as' keyword to assert that a string literal conforms to the 'ValidName' type. This is a type assertion. ```typescript const test3 = 'test3' as ValidName ``` -------------------------------- ### Build Theme with Config File Source: https://github.com/webdiscus/ansilight/blob/master/tools/build-theme/README.md Generate themes based on a JSON configuration file. This allows for more complex configurations including source and target directories. ```sh npm run build-theme -- --config tools/build-theme/theme.config.example.json ``` -------------------------------- ### TypeScript Code Block Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/inline-languages.txt A standard TypeScript code block to ensure the language context is correctly identified after inline language examples. ```typescript // Ensure that we're back in TypeScript mode. var foo = 10; ``` -------------------------------- ### ONBUILD Instruction Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/dockerfile.txt Adds a Dockerfile instruction to be executed as a Dockerfile instruction when the image is used as the base for another build. ```dockerfile ONBUILD ADD . /app/src ``` -------------------------------- ### Bash Arithmetic Assignment Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/bash/arithmetic.txt Assign the result of an arithmetic expression to a variable in Bash. This example shows multiplication and division within the assignment. ```bash fubar=42 (( x = 19 * fubar / 2 )) ``` -------------------------------- ### Creating a Date Object Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/built-in.expect.txt Instantiate a new Date object to get the current date and time. This is useful for tracking time-sensitive information. ```javascript let today = new Date() ``` -------------------------------- ### Basic Haml HTML Structure Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/haml.txt Demonstrates basic Haml syntax for creating HTML elements with attributes and content. ```haml %html %body %h1.jumbo{:id=>"a", :style=>'font-weight: normal', :title=>title} highlight.js ``` -------------------------------- ### Get Script Directory in Bash Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/bash/strings.txt Captures the absolute path of the currently executing script directory. Useful for locating related files. ```bash SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" TLS_DIR="$SCRIPT_DIR/../src/main/resources/tls" ROOT_DIR="$SCRIPT_DIR/.." ``` -------------------------------- ### CSS Media Queries Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/scss/css_consistency.txt Demonstrates complex media queries for responsive design. ```css @media (not(hover)) {} ``` ```css @media not all and (max-width: 600px) {} ``` ```css @media only screen and (min-width: 900px) and (color-gamut: p3) {} ``` ```css @media only screen and (min-width: 100px), not all and (min-width: 100px), not print and (min-height: 100px), (color), (min-height: 100px) and (max-height: 1000px), handheld and (orientation: landscape) {} ``` -------------------------------- ### Expressions with Numeric Literals in JavaScript Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/numbers.expect.txt Shows examples of expressions that correctly incorporate numeric literals, including those with decimal points and exponential notation. ```javascript // expressions containing numeric literals 0..toString, 1e1.toString, fn( .5) ``` -------------------------------- ### Bash Variable Assignment and Expansion Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/bash/variables.expect.txt Demonstrates basic variable assignment and expansion in Bash. Shows how to set a variable and then print its value. ```bash A=1 B=2 WURST=3 CARNE=4 ``` ```bash echo "$A" echo "$B" echo "${WURST:-${CARNE}}" ``` -------------------------------- ### Checkout Git Branch Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/shell.txt Demonstrates checking out a git branch and the expected output. ```shell $ git checkout main Switched to branch 'main' Your branch is up-to-date with 'origin/main'. ``` -------------------------------- ### String Aggregation Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/pgsql/window-functions.txt Concatenates all non-null input values into a string, separated by the specified delimiter. The order of concatenation is determined by the ORDER BY clause. ```sql SELECT string_agg(empno, ',' ORDER BY a) FROM empsalary; ``` -------------------------------- ### SCSS Variables and Mixins Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/scss.txt Demonstrates SCSS variable declaration and usage, along with basic and parameterized mixins. ```scss @import "compass/reset"; // variables $colorGreen: #008000; $colorGreenDark: darken($colorGreen, 10); @mixin container { max-width: 980px; } // mixins with parameters @mixin button($color:green) { @if ($color == green) { background-color: #008000; } @else if ($color == red) { background-color: #B22222; } } button { @include button(red); } ``` -------------------------------- ### Complex HTML Template Literal Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/inline-languages.txt An example of a more complex HTML structure generated using tagged template literals, including nested elements. ```javascript html`
Hello times ${10} world
`; ``` -------------------------------- ### Invalid Character Literal with Double Quotes Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/haskell/char.expect.txt A character literal must be enclosed in single quotes. This example uses double quotes for a character. ```Haskell t9 = a' ``` -------------------------------- ### Setting Single Environment Variables Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/dockerfile.txt Sets individual environment variables. Demonstrates how spaces are handled. ```dockerfile ENV myName John Doe ``` ```dockerfile ENV myDog Rex The Dog ``` ```dockerfile ENV myCat fluffy ``` -------------------------------- ### Invalid String Literal with Single Quotes Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/haskell/char.expect.txt A string literal must be enclosed in double quotes. This example uses single quotes for a string. ```Haskell t8 = ''a ``` -------------------------------- ### Rect Type Definition Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/functions.expect.txt Defines a 'Rect' type with 'x', 'y', 'w', and 'h' properties, all of type 'number'. This type is used in subsequent function examples. ```typescript type Rect = { x: number; y: number; w: number; h: number; }; ``` -------------------------------- ### Defining Working Directory Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/dockerfile.txt Sets the working directory for any RUN, CMD, ENTRYPOINT, COPY, and ADD instructions that follow it. ```dockerfile WORKDIR /path/to/workdir ``` -------------------------------- ### TypeScript Namespace as Identifier Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/namespace_as_identifier.txt This snippet shows a basic TypeScript namespace used as an identifier. It defines a message, a namespace, and a function within that namespace. ```typescript const message = 'foo'; const namespace = 'bar'; function baz() {} ``` -------------------------------- ### Display Environment Variable Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/shell.txt Shows how to display the value of an environment variable. ```shell $ echo $EDITOR vim ``` -------------------------------- ### Mixed Content Code Block Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/markdown/code.expect.txt A code block containing a mix of code and markdown-like syntax. This example shows flexibility in code block content. ```plaintext code here ``` -------------------------------- ### Array Initialization with Comments Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/method-call.txt Shows how to initialize an array with regular expressions for comment detection. ```javascript x = [ hljs.COMMENT(/\{%\s*comment\s*%}/, /\{%\s*endcomment\s*%}/), hljs.COMMENT(/\{#/, /#}/), ] ``` -------------------------------- ### Handlebars With Helper with Block Parameters Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/handlebars/block-parameters-as.expect.txt Illustrates using the 'with' helper with block parameters to introduce a new context and alias it for easier access. ```handlebars {{#with as |as|}} {{/with}} ``` -------------------------------- ### Importing Modules with Aliases Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/modules.expect.txt Imports default exports and named exports from a module, aliasing one of the named exports. The 'underscore' module is used as an example. ```javascript import _, { each, something as otherthing } from 'underscore'; ``` -------------------------------- ### Declare and Initialize a Variable in JavaScript Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/jsx.expect.txt Demonstrates the basic syntax for declaring a variable using 'var' and assigning it an integer value. This is a fundamental JavaScript operation. ```javascript var x = 5; ``` -------------------------------- ### JavaScript Object with Various Attributes Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/object-attr.txt Illustrates defining object attributes with different key formats and including comments. Use this for standard object initialization. ```javascript { key: value, // with comment key2: value, key2clone: value, 'key-3': value, key4: false ? undefined : true, key5: value, /* with a multiline comment */ key6: value, key7: value, /* with a multiline comment */ // another comment key8: value, key9: value, /* with a REAL multiline comment */ key10: value, } ``` -------------------------------- ### Quick Start: Highlight TypeScript Code Source: https://github.com/webdiscus/ansilight/blob/master/README.npm.md Use ansilight to highlight a TypeScript code string with the atom-one-dark theme. Language and theme can be omitted for auto-detection. ```js import ansilight from 'ansilight'; import theme from 'ansilight/themes/atom-one-dark'; const code = `class MyClass { public static myValue: string; constructor(init: string) { this.myValue = init; } } import fs = require("fs"); module MyModule { export interface MyInterface extends Other { myProperty: any; } } declare magicNumber number; myArray.forEach(() => { }); // fat arrow syntax`; const output = ansilight(code, { lang: 'typescript', // optional, auto-detected if omitted theme, // optional, uses 'default' theme if omitted }); console.log(output); ``` -------------------------------- ### JavaScript Class Constructor with Property Assignment Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/class.expect.txt Defines a class constructor that assigns a value to a 'cost' property. This is a basic setup for initializing class instances. ```javascript class Car { constructor(cost) { this[c] = cost; } } ``` -------------------------------- ### TypeScript 'satisfies' Keyword Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/satisfies-and-as.expect.txt Uses the 'satisfies' keyword to check if a string literal conforms to the 'ValidName' type without changing its type. This is a type-checking operation. ```typescript const test4 = 'test4' satisfies ValidName ``` -------------------------------- ### Display First Line of .travis.yml Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/shell/command-continuation.expect.txt This command displays the first line of the .travis.yml file. ```shell /bin/cat \.travis.yml \ -b | head -n1 ``` -------------------------------- ### Continue Method Call Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/method-call.txt Demonstrates a simple continue method call with an argument. ```javascript x.continue(0); ``` -------------------------------- ### Class Definition with Spaced Parameters Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/class.txt Illustrates a class definition where parameters in method signatures are separated from the function name by spaces. This is a stylistic variation of the previous example. ```javascript class Car extends Vehicle { constructor (speed, cost) { super(speed); var c = Symbol('cost'); this[c] = cost; this.intro = `This is a car runs at ${speed}.`; } join () { } other (a = ( ( 3 + 2 ) ) ) { console.log(a) } something (a = ( ( 3 + 2 ) ), b = 1 ) { console.log(a) } onemore (a=(3+2, b=(5*9))) {} } ``` -------------------------------- ### CSS Supports and Media Query Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/css/sample.txt Uses @supports to check for flex display and @media to apply styles based on screen width. ```css @supports (display: flex) { @media screen and (min-width: 900px) { article { display: flex; } } } ``` -------------------------------- ### CSS Media Queries Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/css/css_consistency.expect.txt Demonstrates complex media queries with multiple conditions including screen, min-width, color-gamut, not, min-height, max-height, and orientation. ```css @media only screen and (min-width: 900px) and (color-gamut: p3) {} @media only screen and (min-width: 100px), not all and (min-width: 100px), not print and (min-height: 100px), (color), (min-height: 100px) and (max-height: 1000px), handheld and (orientation: landscape) {} ``` -------------------------------- ### Create Table with Date Field Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/sql/combos.txt Illustrates creating a table that includes a DATE column to store date values. Note the specific syntax for date with timezone if applicable. ```sql CREATE TABLE events ( event_id INT PRIMARY KEY, event_name VARCHAR(100), event_date DATE ); ``` ```sql CREATE TABLE events ( event_id INT PRIMARY KEY, event_name VARCHAR(100), event_date DATE with timezone ); ``` -------------------------------- ### Print Media Query for Links Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/css.txt Use a @media print query to apply styles specifically when the page is being printed. This example adds the URL as content for external links. ```css @media print { a[href^=http]::after { content: attr(href) } } ``` -------------------------------- ### Simple Echo Command Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/shell/command-continuation.txt A basic `echo` command to demonstrate standard output. ```shell > echo 'hello' hello ``` -------------------------------- ### Serve Static Files with Nginx Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/nginx/default.expect.txt Configure Nginx to serve static image files from a specific directory. ```nginx location ~* \.(jpg|jpeg|gif)$ { root /spool/www; } ``` -------------------------------- ### Valid and Invalid Arrow Function Syntaxes Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/functions.txt Presents examples of valid and invalid arrow function syntaxes in TypeScript, highlighting common pitfalls with parameter destructuring and default values. ```typescript const good = () => 0; const good = (x) => 0; const bad = (a => [...a, b]); const bad = (_ => doSomething()); const bad = (() => 0); const bad = ((a, b) => [...a, b]); ``` -------------------------------- ### Push Git Changes Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/shell.txt Illustrates pushing git changes and the output when everything is up-to-date. ```shell $ git push Everything up-to-date ``` -------------------------------- ### Displaying File Content with Continuation Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/shell/command-continuation.txt Combine `cat` and `head` commands using a backslash for continuation to display the first line of a file. ```shell > /bin/cat \.travis.yml\ -b | head -n1 ``` -------------------------------- ### Basic HTML Structure in Haml Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/haml/default.expect.txt Demonstrates the basic structure of an HTML document using Haml syntax for elements like html, body, and h1. ```Haml %html %body %h1.jumbo{:id => "a", :style => 'font-weight: normal', :title => title} highlight.js ``` -------------------------------- ### JavaScript Class Method with Multiple Default Parameters Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/class.expect.txt An example of a class method 'something' with two default parameters, 'a' and 'b', both having calculated default values. This showcases more complex default parameter usage. ```javascript class Car { something (a = (3 + 2), b = 1) { console.log(a) } } ``` -------------------------------- ### Control Background with Ansilight Option `background` Source: https://github.com/webdiscus/ansilight/blob/master/README.md Demonstrates how to use the `background` option to either keep the theme's background, override it with a custom color, or disable it entirely. Ensure the theme is imported when using this option. ```javascript import ansilight from 'ansilight'; import theme from 'ansilight/themes/atom-one-dark'; const code = `function greet(name) { return "Hello, " + name + "!"; }`; console.log(ansilight(code, { lang: 'javascript', // use theme background theme, }), ' '); console.log(ansilight(code, { lang: 'javascript', background: '#143757', // override theme background theme, }), ' '); console.log(ansilight(code, { lang: 'javascript', background: false, // disable background theme, }), ' '); ``` -------------------------------- ### JavaScript Function Declaration and Control Flow Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/keywords.expect.txt Demonstrates a JavaScript function with try-catch blocks, conditional checks using 'if', and loop structures. It includes examples of returning values and handling exceptions. ```javascript function $initHighlight(block, cls) { try { if (cls.search(/no-highlight/) != -1) return process(block, true, 0x0F) + ' class=""'; } catch (e) { /* handle exception */ } for (var i = 0 / 2; i < classes.length; i++) { if ( checkCondition(classes[i]) === undefined) return / ``` -------------------------------- ### Import and Use Bundled Theme Source: https://github.com/webdiscus/ansilight/blob/master/README.md Import a bundled theme directly from the 'ansilight' npm package and use it to style code. ```js import ansilight from 'ansilight'; import theme from 'ansilight/themes/github-dark'; console.log(ansilight(code, { theme })); ``` -------------------------------- ### TypeScript Namespace as Identifier Example Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/typescript/namespace_as_identifier.expect.txt This snippet illustrates a common scenario where 'namespace' might be used as a variable or function name in TypeScript. It shows how to declare constants and functions, including one named 'baz'. ```typescript const message = 'foo'; const namespace = 'bar'; function baz() {} ``` -------------------------------- ### Dynamic Import Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/modules.expect.txt Demonstrates a dynamic import of a module from a URL. This is useful for loading modules on demand. ```javascript const file = import("https://file.io/file.js"); ``` -------------------------------- ### Valid Arrow Functions Returning a Value Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/arrow-function.expect.txt Examples of correctly defined arrow functions that return a value. The first returns 0, the second also returns 0, and the third returns the result of a function call. ```javascript const good = () => 0; ``` ```javascript const good = (x) => 0; ``` ```javascript const bad = () => doSomething(); ``` -------------------------------- ### Echo Multi-line String Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/shell.txt Shows how to echo a multi-line string in the shell. ```shell $ echo 'All > done!' All done! ``` -------------------------------- ### CSS Pseudo-elements (::before, ::after) Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/css/pseudo.txt Demonstrates the use of double-colon syntax for pseudo-elements. This syntax is the standard for pseudo-elements and is recommended for clarity. ```css .test::before, .test::after { color: pink; color: red; } ``` -------------------------------- ### Using Dollar Quoted Strings in SQL Expressions Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/pgsql/dollar_strings.txt This example demonstrates how to use dollar-quoted strings (`$sql$` and `$phrase$`) within a PostgreSQL `SELECT` statement. This allows for embedding strings containing apostrophes without needing to escape them. ```PostgreSQL SELECT sql_expression($sql$SELECT hello_world($phrase$Regina's elephant's dog$phrase$) || $phrase$ I made a cat's meow today.$phrase$ $sql$); ``` -------------------------------- ### Using Nested Dollar Quoted Strings in PostgreSQL Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/pgsql/dollar_strings.expect.txt This example shows how to use nested dollar-quoted strings within a PostgreSQL SQL expression. It highlights the use of custom delimiters like $phrase$ and $sql$ to differentiate between nested string levels. ```pgsql SELECT sql_expression($sql$ SELECT hello_world( $phrase$Regina's elephant's dog$phrase$ || $phrase$I made a cat's meow today.$phrase$ $sql$ ); ``` -------------------------------- ### Styling with ::before and ::after Pseudo-elements Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/css/pseudo.expect.txt Demonstrates the use of the standard ::before and ::after pseudo-elements for applying styles. These are typically used for decorative content or to add elements that are not present in the HTML. ```css .test::before, .test::after { color: pink; color: red; } ``` -------------------------------- ### Detect Terminal Color Scheme with `detectColorScheme()` Source: https://github.com/webdiscus/ansilight/blob/master/README.md Utilizes `detectColorScheme()` to dynamically select a light or dark theme based on the terminal's current color scheme. This example disables the theme background to ensure the chosen theme is rendered clearly over the terminal's background. ```javascript import ansilight, { detectColorScheme } from 'ansilight'; import light from 'ansilight/themes/github'; import dark from 'ansilight/themes/github-dark'; const code = `type User = { id: number; name: string; email?: string; }; `; // Resolve theme by terminal color scheme. const theme = await detectColorScheme() === 'light' ? light // light terminal background : dark; // dark terminal background or undetected const output = ansilight(code, { lang: 'typescript', background: false, // keep terminal background visible (theme background is off) theme, }); console.log(output); ``` -------------------------------- ### CSS Pseudo-class and Pseudo-element Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/scss/css_consistency.expect.txt Demonstrates styling for visited links and content added via ::after pseudo-element. ```css a:visited { color: blue; } div::after { content: "test"; } div:after { content: "test"; } div::before { content: open-quote; } div:before { content: open-quote; } ``` -------------------------------- ### Defining Volume and Working Directory Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/dockerfile/default.expect.txt This snippet sets up a volume for persistent data and defines the working directory within the container. ```dockerfile VOLUME [ "/var/www/html" ] WORKDIR /var/www/html ``` -------------------------------- ### Create Events Table with Date and Timezone Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/sql/combos.expect.txt Creates an 'events' table with an event ID, name, and a date with timezone information. ```sql CREATE TABLE events ( event_id INT PRIMARY KEY, event_name VARCHAR(100), event_date DATE with timezone ); ``` -------------------------------- ### PL/pgSQL Variable Declarations Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/pgsql/plpgsql.expect.txt Demonstrates various ways to declare variables, including basic types, aliases, records, cursors, and constants. ```plpgsql << outerblock >> DECLARE quantity integer := 30; subtotal ALIAS FOR $1; prior ALIAS FOR old; arow record; curs1 refcursor; curs2 CURSOR FOR SELECT * FROM tenk1; ``` ```plpgsql DECLARE quantity CONSTANT integer := 80; myrow tablename%ROWTYPE; myfield tablename.columnname%TYPE; ``` -------------------------------- ### PL/pgSQL Control Flow and Statements Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/pgsql/plpgsql.expect.txt Illustrates control flow structures like IF, LOOP, and statements such as PERFORM, RAISE, SELECT INTO, ASSERT, CONTINUE, and EXIT. ```plpgsql BEGIN DECLARE quantity CONSTANT integer := 80; myrow tablename%ROWTYPE; myfield tablename.columnname%TYPE; BEGIN PERFORM pg_sleep(1); RAISE NOTICE 'Quantity here is %', quantity; END; SELECT * INTO myrec FROM emp WHERE empname = myname; IF NOT FOUND THEN EXIT <>; ELSIF quantity < 0 THEN ASSERT a > b, 'Bad luck'; END IF; ``` ```plpgsql FOR r IN SELECT * FROM foo LOOP CONTINUE WHEN count < 50; END LOOP; ``` ```plpgsql FOR i IN REVERSE 10..1 LOOP FOREACH x IN ARRAY $1 LOOP s := s + x; END LOOP; ``` -------------------------------- ### Adding Files with ADD Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/dockerfile.txt Adds files from a build context to the container. Supports wildcards and compressed files. ```dockerfile ADD hom* /mydir/ # adds all files starting with "hom" ``` ```dockerfile ADD hom?.txt /mydir/ # ? is replaced with any single character ``` -------------------------------- ### Creating XML Processing Instructions Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/pgsql/xml.txt Generate an XML processing instruction with a target and optional content. ```sql SELECT xmlpi(name php, '...') ``` -------------------------------- ### Build Themes from Custom Source Source: https://github.com/webdiscus/ansilight/blob/master/tools/build-theme/README.md Convert themes from a custom source directory to a specified target directory. Useful for integrating themes from other libraries like Prism.js. ```sh npm run build-theme -- --source-dir vendor/prismjs/themes --target-dir themes/prismjs --name prism ``` -------------------------------- ### CSS Pseudo-classes (:before, :after) Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/css/pseudo.txt Demonstrates the use of single-colon syntax for pseudo-classes. This syntax is older and primarily used for pseudo-classes. ```css .test:before, .test:after { color: pink; color: red; } ``` -------------------------------- ### Default and Named Exports in Underscore.js Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/modules.txt Demonstrates how to export a default function and named functions from a module. Aliasing exports is also shown. ```javascript //------ underscore.js ------ export default function (obj) {}; export function each(obj, iterator, context) {}; export { each as forEach }; export function something() {}; ``` -------------------------------- ### Basic Template String Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/javascript/template-strings.expect.txt Demonstrates the basic syntax of a template string using backticks and embedding a variable. ```javascript const name = "World"; const greeting = `Hello, ${name}!`; console.log(greeting); // Output: Hello, World! ``` -------------------------------- ### Basic Nginx Configuration Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/nginx/default.expect.txt Essential directives for Nginx worker processes, PID file, and error logging levels. ```nginx user www www; worker_processes 2; pid /var/run/nginx.pid; error_log /var/log/nginx.error_log debug | info | notice | warn | error | crit; ``` -------------------------------- ### Copying Files with COPY Source: https://github.com/webdiscus/ansilight/blob/master/examples/snippets/dockerfile.txt Copies files from a build context to the container. Supports wildcards and multi-stage builds. ```dockerfile COPY hom* /mydir/ # adds all files starting with "hom" ``` ```dockerfile COPY hom?.txt /mydir/ # ? is replaced with any single character ``` ```dockerfile COPY --from=foo / . ``` -------------------------------- ### Nginx HTTP General Settings Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/nginx/default.expect.txt Sets timeouts, buffer sizes, and enables gzip compression with a minimum length. ```nginx send_timeout 3m; client_header_buffer_size 1k; gzip on; gzip_min_length 1100; #lingering_time 30; ``` -------------------------------- ### CSS Media Queries Source: https://github.com/webdiscus/ansilight/blob/master/test/markup/scss/css_consistency.expect.txt Demonstrates 'not' and 'and' logic within media queries. ```css @media (not(hover)) {} @media not all and (max-width: 600px) {} ```