### Install Bright npm package Source: https://github.com/code-hike/bright/blob/main/lib/readme.md This command installs the 'bright' package from the npm registry, making it available for use as a dependency in your project. ```bash npm install bright ``` -------------------------------- ### Install bright npm package Source: https://github.com/code-hike/bright/blob/main/readme.md This command installs the 'bright' package from npm, making it available for use as a dependency in your project. ```bash npm install bright ``` -------------------------------- ### Basic JavaScript Console Output Source: https://github.com/code-hike/bright/blob/main/web/app/test-mdx/mdx-demo.mdx A simple JavaScript snippet demonstrating variable declaration and logging a string to the console. This serves as a fundamental example of code that can be highlighted. ```js let hello = "hello brightness" console.log(hello, "my old friend") ``` -------------------------------- ### Plain Text Block with Leading/Trailing Spaces Source: https://github.com/code-hike/bright/blob/main/web/app/test-mdx/mdx-demo.mdx A direct representation of a text block containing leading and trailing spaces, demonstrating how such content is structured and preserved. This is a raw example without specific language highlighting. ```text here is some text with leading and trailing spaces that is working if the two lines are left-aligned. ``` -------------------------------- ### JavaScript Code with Bright Title and Mark Annotations Source: https://github.com/code-hike/bright/blob/main/web/app/test-mdx/mdx-demo.mdx An example of JavaScript code intended to be processed by 'bright', showcasing how a title can be applied to the code block and how specific lines or ranges can be marked for highlighting. This illustrates the output or result of applying 'bright' transformations. ```js // title foo.js console.log(1) // mark[3:10] red // mark const x = 20 ``` -------------------------------- ### Display Code with Bright in Next.js Server Component Source: https://github.com/code-hike/bright/blob/main/lib/readme.md This JavaScript snippet demonstrates how to import and use the 'Code' component from the 'bright' library within a Next.js server component (e.g., `app/page.js`). It shows a basic example of rendering a Python print statement with code highlighting. ```javascript import { Code } from "bright" export default function Page() { return print("hello brightness") } ``` -------------------------------- ### JavaScript Utility Functions (foo.js) Source: https://github.com/code-hike/bright/blob/main/web/app/recipes/tabs/usage.mdx This JavaScript snippet defines two utility functions: `lorem` which processes an input `ipsum` and `dolor`, and `consectetur` which handles an array of arguments, returning either the first element or an array containing it based on a condition. These functions appear to be part of a larger module for data manipulation. ```js // title foo.js function lorem(ipsum, dolor = 1) { const sit = ipsum == null ? 0 : ipsum.sit dolor = sit - amet(dolor) return dolor } function consectetur(...adipiscing) { const elit = adipiscing[0] return sed.eiusmod(elit) ? elit : [elit] } ``` -------------------------------- ### Markdown Encapsulated JavaScript with Bright Annotations Source: https://github.com/code-hike/bright/blob/main/web/app/test-mdx/mdx-demo.mdx Demonstrates how JavaScript code, along with 'bright' specific annotations (like 'mark' for highlighting and 'number' for line numbering), can be embedded and rendered within a Markdown block. This highlights the library's compatibility with Markdown-based content. ```md ```js /// mark[3:10] red console.log(1) /// number[11:12] const x = 20 ``` ``` -------------------------------- ### Render Python code with bright in Next.js server component Source: https://github.com/code-hike/bright/blob/main/readme.md This JavaScript snippet demonstrates how to import and use the 'Code' component from 'bright' within a Next.js server component (e.g., app/page.js). It shows rendering a simple Python print statement. ```javascript import { Code } from "bright" export default function Page() { return print("hello brightness") } ``` -------------------------------- ### Bright Code Component Custom Extensions in JSX Source: https://github.com/code-hike/bright/blob/main/web/app/test-mdx/mdx-demo.mdx This JSX snippet defines and applies custom extensions to the 'bright' Code component. It includes 'mark' for inline and multiline text highlighting, 'number' for interactive line numbering, and 'title' for adding a dynamic title to the code block. The component then renders a JavaScript string utilizing these defined extensions. ```jsx import { Code } from "bright" Code.extensions = { mark: { InlineAnnotation: ({ children, query }) => ( {children} ), MultilineAnnotation: ({ children, query }) => ( {children} ), }, number: ({ children, content }) => ( ), title: { beforeHighlight: (props, query) => ({ ...props, title: query, }), }, } const myCode = ` // mark[3:10] red console.log(1) // mark const x = 20 ` export default function Page() { return {myCode} } ``` -------------------------------- ### Markdown Encapsulated Text with Leading/Trailing Spaces Source: https://github.com/code-hike/bright/blob/main/web/app/test-mdx/mdx-demo.mdx This snippet demonstrates how a block of text, including leading and trailing spaces on lines, can be encapsulated within a Markdown code block. It highlights the preservation of whitespace when content is rendered. ```md ``` here is some text with leading and trailing spaces that is working if the two lines are left-aligned. ``` ``` -------------------------------- ### Comparing JavaScript Function `lorem` Implementations Source: https://github.com/code-hike/bright/blob/main/web/app/recipes/diff/usage.mdx This snippet presents two distinct versions of the `lorem` JavaScript function, showcasing a typical code change or refactoring. The first version dynamically determines the value of `sit` based on the `ipsum` parameter, while the second version simplifies `sit` to a constant value and introduces an additional multiplication step for the `dolor` variable. ```js function lorem(ipsum, dolor = 1) { const sit = ipsum == null ? 0 : ipsum.sit dolor = sit - amet(dolor) return dolor } ``` ```js function lorem(ipsum, dolor = 1) { const sit = 0 dolor = sit - amet(dolor) dolor *= 2 return dolor } ``` -------------------------------- ### Python Conditional Print Function (bar.py) Source: https://github.com/code-hike/bright/blob/main/web/app/recipes/tabs/usage.mdx This Python snippet defines a function `dolor_sit_amet` that takes two arguments and prints a different message based on the value of the first argument. It demonstrates a simple if-else conditional structure and a function call with multiple arguments. ```py # title bar.py def dolor_sit_amet(consectetur, adipiscing): if consectetur == "Lorem" print("Pellentesque habitant.") else: print("Suspendisse potenti.") dolor_sit_amet("Lorem", "ipsum", "dolor") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.