### Full CMake Project Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/cmake.txt A comprehensive CMakeLists.txt file demonstrating project setup, library creation, subdirectory inclusion, and executable definition. ```cmake cmake_minimum_required(VERSION 3.13) project(crypto) add_library(base INTERFACE) target_compile_features(base INTERFACE cxx_std_17 ) add_subdirectory(helpers) add_subdirectory(msg) add_library(analyzers-obj OBJECT CryptoAnalyzer.cpp ) target_include_directories(analyzers-obj PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) find_package(predi REQUIRED) target_link_libraries(analyzers-obj PUBLIC base predi::predi crypto::helpers ) set_target_properties(analyzers-obj PROPERTIES POSITION_INDEPENDENT_CODE ON ) add_library(analyzers SHARED $ ) target_link_libraries(analyzers PUBLIC analyzers-obj) add_executable(crypto main.cpp ) target_link_libraries(crypto PUBLIC analyzers PRIVATE base messages ) enable_testing() add_subdirectory(tests) ``` -------------------------------- ### Kotlin Annotations for Testing Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/kotlin.txt Provides an example of using annotations like `@SetUp` and `@Test` in Kotlin, commonly used in testing frameworks to mark methods for specific execution phases. ```kotlin // Annotations public class MyTest { lateinit var subject: TestSubject @SetUp fun setup() { subject = TestSubject() } @Test fun test() { subject.method() // dereference directly } } ``` -------------------------------- ### Xeora XML Control Setup Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/xeora.txt Provides an example of XML configuration for a control in Controls.xml. ```xml [ControlType] [ThemeID|AddonID]?[ControlClass].[FunctionName],SomeOperatorTags(seperated with |) [BlockID] [BlockID] [BlockID] [ControlID] [TextBox, Password value or Button Text] [Textarea Content] [Image URL] [Link URL] [AttributeValue] ``` -------------------------------- ### Vue Script Setup with Ref Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/vue.txt Demonstrates the use of ` ``` -------------------------------- ### Full Arduino Melody Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/arduino.txt A complete Arduino sketch that sets up a piezo speaker and plays a simple melody. It includes setup, loop, and a custom function for melody playback. ```arduino #include // pin of the piezo speaker int piezo = 8; /** * setups * runs once before everyhing else */ void setup() { pinMode(piezo, OUTPUT); } /** * loop * this will run forever and do what we want */ void loop() { playMelody(1); delay(1000); } /** * playMelody * will play a simple melody on piezo speaker */ void playMelody(int times) { int melody[] = { 4699, 4699, 3520, 4699 }; int duration = 6; for (int t = 0; t < times; t++ ) { for( int i = 0; i < 4; i++ ) { // pass tone to selected pin tone(piezoPin, melody[i], 1000/duration); // get a bit of time between the tones delay(1000 / duration * 1.30 + 80); // and don't forget to switch of the tone afterwards noTone(piezoPin); } } } ``` -------------------------------- ### Basic Nginx Dockerfile Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/docker.txt This snippet shows a minimal Dockerfile to set up an Nginx server. It starts from an Ubuntu base image, installs necessary packages, and sets up metadata labels. ```dockerfile FROM ubuntu MAINTAINER Victor Vieux LABEL Description="This image is used to start the foobar executable" Vendor="ACME Products" Version="1.0" RUN apt-get update && apt-get install -y inotify-tools nginx apache2 openssh-server ``` -------------------------------- ### Install Targets Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/makefile.txt Installs the 'tar' and 'rmt' executables, and documentation files. The installation of 'rmt' is conditional. ```makefile .PHONY: install install: all $(INSTALL) tar $(bindir)/$(binprefix)tar -test ! -f rmt || $(INSTALL) rmt /etc/rmt $(INSTALLDATA) $(srcdir)/tar.info* $(infodir) ``` -------------------------------- ### Basic Editor Setup Source: https://github.com/jonpyt/prism-code-editor/blob/main/readme.md Import and initialize a basic editor setup. This setup includes necessary styles, extensions, and language-specific behavior. Ensure the container has `display: grid` for proper rendering. ```javascript import { minimalEditor, basicEditor, readonlyEditor } from "prism-code-editor/setups" // Importing Prism grammars import "prism-code-editor/prism/languages/markup" const editor = basicEditor( "#editor", { language: "html", theme: "github-dark", }, () => console.log("ready"), ) ``` -------------------------------- ### Full G-code Example: Print Initialization Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/gcode.txt A comprehensive G-code example for initializing a 3D print job, including heating the bed and hotend, homing axes, and starting extrusion. ```gcode M190 S60 ; Heat bed to 60°C G21 ; Set units to millimeters G28 ; Move to Origin (Homing) G29 ; Auto Bed Leveling G28 X0 Y0 ; Home X and Y to min endstops M107 ; Fan off M109 S200 ; Heat hotend to 200°C G92 E0 ; Set current extruder position as zero G1 F200 E15 ; Extrude 15mm filament with 200mm/min G92 E0 ; Set current extruder position as zero G1 F500 ``` -------------------------------- ### Install Dependencies Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/README.md Run this command to install project dependencies locally. ```bash pnpm install ``` -------------------------------- ### Basic Editor Setup Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/guides/getting-started.mdx Demonstrates how to create a basic editor instance using the `basicEditor` setup. Ensure Prism grammars for desired languages are imported. ```javascript import { basicEditor } from "prism-code-editor/setups" // Importing Prism grammars import "prism-code-editor/prism/languages/markup" const editor = basicEditor( "#editor", { language: "html", theme: "github-dark", }, () => console.log("mounted"), ) ``` -------------------------------- ### Hello World Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/false.txt A basic 'Hello, world!' output. ```Unknown { Hello, world! } "Hello, world!" ``` -------------------------------- ### Install marked-prism-code-editor Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/markdown-plugins/getting-started.mdx Install the prism-code-editor and marked-prism-code-editor packages for marked integration. ```bash npm i prism-code-editor npm i marked-prism-code-editor ``` -------------------------------- ### Print Hello World in Wren Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/wren.txt A basic example of printing a string to the console. This is the standard entry point for many programming language examples. ```wren System.print("Hello, world!") ``` -------------------------------- ### TypoScript Setup and Imports Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/typoscript.txt This snippet shows a typical TypoScript setup file, including importing other TypoScript files for modular configuration. Ensure imported files exist and are correctly referenced. ```typoscript // Typical TypoScript Setup File # import other files @import 'EXT:fluid_styled_content/Configuration/TypoScript/setup.typoscript' @import 'EXT:sitepackage/Configuration/TypoScript/Helper/DynamicContent.typoscript' ``` -------------------------------- ### Visual Studio Solution File Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/solution-file.txt This is a complete example of a Visual Studio solution file (.sln). It defines the format version, Visual Studio version, and lists projects along with their configurations. ```plaintext Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.29709.97 MinimumVisualStudioVersion = 10.0.40219.1 Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Project1", "Project1.vbproj", "{8CDD8387-B905-44A8-B5D5-07BB50E05BEA}" EndProject Global GlobalSection(SolutionNotes) = postSolution EndGlobalSection GlobalSection(SolutionConfiguration) = preSolution ConfigName.0 = Debug ConfigName.1 = Release EndGlobalSection GlobalSection(ProjectDependencies) = postSolution EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {8CDD8387-B905-44A8-B5D5-07BB50E05BEA}.Debug.ActiveCfg = Debug|x86 {8CDD8387-B905-44A8-B5D5-07BB50E05BEA}.Debug.Build.0 = Debug|x86 {8CDD8387-B905-44A8-B5D5-07BB50E05BEA}.Release.ActiveCfg = Release|x86 {8CDD8387-B905-44A8-B5D5-07BB50E05BEA}.Release.Build.0 = Release|x86 EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal ``` -------------------------------- ### MEL Commands Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/mel.txt Shows examples of common MEL commands for selection and attribute manipulation. ```mel pickWalk -d down; string $mySelection[] = `ls -selection`; setAttr ($mySelection[0]+".particleRenderType") 5; addAttr -is true -ln "spriteTwist" -at "float" -min -180 -max 180 -dv 0.0 blue_nParticleShape; ``` -------------------------------- ### Vimscript Mapping Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/vim.txt Shows how to create a mapping in Vimscript. This example maps a key sequence to open a new tab. ```vimscript map tn :tabnew ``` -------------------------------- ### Install Prism Code Editor Source: https://github.com/jonpyt/prism-code-editor/blob/main/readme.md Install the library using npm. For projects not using NPM, a bundle builder is available to create a customized minified bundle. ```bash npm i prism-code-editor ``` -------------------------------- ### Install prism-code-editor with yarn Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/guides/getting-started.mdx Install the prism-code-editor package using yarn. ```bash yarn add prism-code-editor ``` -------------------------------- ### Install prism-code-editor with npm Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/guides/getting-started.mdx Install the prism-code-editor package using npm. ```bash npm install prism-code-editor ``` -------------------------------- ### PureScript Sum of Fractions Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/purescript.txt A full PureScript example demonstrating how to sum fractions, including reducing fractions to their simplest form and handling potential edge cases. ```purescript module Codewars.Kata.SumFracts (sumFracts) where import Prelude import Data.Foldable (foldl) import Data.BigInt (BigInt, fromInt, toString) import Data.List (List, length) import Data.Tuple (Tuple(..)) import Data.Maybe (Maybe(..)) import Data.Ord (abs, signum) reduce :: Tuple BigInt BigInt -> Tuple BigInt BigInt reduce (Tuple num den) = let gcd' = gcd num den den' = den / gcd' in Tuple (num / gcd' * (signum den')) (abs den') sumFracts :: List (Tuple Int Int) -> Maybe String sumFracts fracts = let fracts' = fracts <#> (\(Tuple n d) -> Tuple (fromInt n) (fromInt d)) >>> reduce den = foldl (\acc (Tuple _ d) -> lcm acc d) one fracts' num = foldl (\acc (Tuple n d) -> acc + n * (den / d)) zero fracts' Tuple n d = reduce $ Tuple num den in if length fracts == 0 then Nothing else if d == one then Just $ toString n else Just $ (toString n) >< " " >< (toString d) ``` -------------------------------- ### Complete GNU Tar Makefile Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/makefile.txt A comprehensive example of a Makefile for the GNU tar program, showcasing various configurations and build settings. ```makefile #!/usr/bin/make -f # Generated automatically from Makefile.in by configure. # Un*x Makefile for GNU tar program. # Copyright (C) 1991 Free Software Foundation, Inc. # This program is free software; you can redistribute # it and/or modify it under the terms of the GNU # General Public License … … … SHELL = /bin/sh #### Start of system configuration section. #### srcdir = . # If you use gcc, you should either run the # fixincludes script that comes with it or else use # gcc with the -traditional option. Otherwise ioctl # calls will be compiled incorrectly on some systems. CC = gcc -O YACC = bison -y INSTALL = /usr/local/bin/install -c INSTALLDATA = /usr/local/bin/install -c -m 644 # Things you might add to DEFS: # -DSTDC_HEADERS If you have ANSI C headers and # libraries. # -DPOSIX If you have POSIX.1 headers and # libraries. # -DBSD42 If you have sys/dir.h (unless # you use -DPOSIX), sys/file.h, # and st_blocks in `struct stat'. # -DUSG If you have System V/ANSI C # string and memory functions # and headers, sys/sysmacros.h, # fcntl.h, getcwd, no valloc, # and ndir.h (unless # you use -DDIRENT). # -DNO_MEMORY_H If USG or STDC_HEADERS but do not # include memory.h. # -DDIRENT If USG and you have dirent.h # instead of ndir.h. # -DSIGTYPE=int If your signal handlers # return int, not void. # -DNO_MTIO If you lack sys/mtio.h # (magtape ioctls). # -DNO_REMOTE If you do not have a remote shell # or rexec. # -DUSE_REXEC To use rexec for remote tape # operations instead of # forking rsh or remsh. # -DVPRINTF_MISSING If you lack vprintf function # (but have _doprnt). # -DDOPRNT_MISSING If you lack _doprnt function. # Also need to define # -DVPRINTF_MISSING. # -DFTIME_MISSING If you lack ftime system call. # -DSTRSTR_MISSING If you lack strstr function. # -DVALLOC_MISSING If you lack valloc function. # -DMKDIR_MISSING If you lack mkdir and # rmdir system calls. # -DRENAME_MISSING If you lack rename system call. # -DFTRUNCATE_MISSING If you lack ftruncate # system call. # -DV7 On Version 7 Unix (not # tested in a long time). # -DEMUL_OPEN3 If you lack a 3-argument version # of open, and want to emulate it # with system calls you do have. # -DNO_OPEN3 If you lack the 3-argument open # and want to disable the tar -k # option instead of emulating open. # -DXENIX If you have sys/inode.h # and need it 94 to be included. DEFS = -DSIGTYPE=int -DDIRENT -DSTRSTR_MISSING \ -DVPRINTF_MISSING -DBSD42 # Set this to rtapelib.o unless you defined NO_REMOTE, # in which case make it empty. RTAPELIB = rtapelib.o LIBS = DEF_AR_FILE = /dev/rmt8 DEFBLOCKING = 20 CDEBUG = -g CFLAGS = $(CDEBUG) -I. -I$(srcdir) $(DEFS) \ -DDEF_AR_FILE=\"$(DEF_AR_FILE)\" \ -DDEFBLOCKING=$(DEFBLOCKING) LDFLAGS = -g prefix = /usr/local # Prefix for each installed program, # normally empty or `g'. binprefix = # The directory to install tar in. bindir = $(prefix)/bin # The directory to install the info files in. infodir = $(prefix)/info ``` -------------------------------- ### Install prism-code-editor with pnpm Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/guides/getting-started.mdx Install the prism-code-editor package using pnpm. ```bash pnpm add prism-code-editor ``` -------------------------------- ### Io Comments Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/io.txt Demonstrates single-line and multi-line comment syntax in Io. ```io // Comments // // Foobar #!/usr/bin/env io /* multiline comment */ ``` -------------------------------- ### Full YAML Example with Tags, Anchors, and Aliases Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/yaml.txt A comprehensive example showing YAML 1.2 syntax, including custom tags, anchors (&), and aliases (*), for complex data structures like invoices. ```yaml %YAML 1.2 --- ! invoice: 34843 date : 2001-01-23 bill-to: &id001 given : Chris family : Dumars address: lines: | 458 Walkman Dr. Suite #292 city : Royal Oak state : MI postal : 48046 ship-to: <<: *id001 product: - sku : BL394D quantity : 4 description : Basketball price : 450.00 - sku : BL4438H quantity : 1 description : Super Hoop price : 2392.00 tax : 251.42 total: 4443.52 comments: Late afternoon is best. Backup contact is Nancy ``` -------------------------------- ### Full XQuery Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/xquery.txt A complete XQuery example that constructs an XML report by iterating over product data. It declares namespaces and uses a FLWOR expression. ```xquery { for $product in doc("prod_ns.xml")/prod:product return {$product/prod:number} {$product/prod:name} } ``` -------------------------------- ### Common Bash Commands: Package Installation Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/bash.txt Installs a Debian package using dpkg. ```bash sudo dpkg -i vagrant_1.7.2_x86_64.deb ``` -------------------------------- ### Basic JSX Editor Setup Source: https://github.com/jonpyt/prism-code-editor/blob/main/react-package/README.md Demonstrates how to set up a basic JSX code editor using prism-react-editor. Includes necessary imports for language support, basic setup, and styling. ```jsx import { Editor } from "prism-react-editor" import { BasicSetup } from "prism-react-editor/setups" // Adding the JSX grammar import "prism-react-editor/prism/languages/jsx" // Adds comment toggling and auto-indenting for JSX import "prism-react-editor/languages/jsx" import "prism-react-editor/layout.css" import "prism-react-editor/themes/github-dark.css" // Required by the basic setup import "prism-react-editor/search.css" import "prism-react-editor/invisibles.css" function MyEditor() { return } ``` -------------------------------- ### React Example: Using Original Prism Code Editor Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/guides/usage-with-frameworks.mdx This example demonstrates how to use the original `prism-code-editor` package in a React application, which can be an alternative if framework-specific rewrites are not desired. ```tsx import { Editor } from "prism-code-editor"; function App() { return ( console.log(value)} /> ); } ``` -------------------------------- ### Install Prism React Editor Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/guides/usage-with-frameworks.mdx Use this command to install the Prism React editor package for React projects. ```bash npm i prism-react-editor ``` -------------------------------- ### Install Prism SolidJS Editor Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/guides/usage-with-frameworks.mdx Use this command to install the Prism SolidJS editor package for SolidJS projects. ```bash npm i solid-prism-editor ``` -------------------------------- ### Change Editor Theme with Setups Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/guides/styling.mdx Use the `setOptions` method to change the current theme when using the editor setups. The theme change is asynchronous. ```js editor.setOptions({ theme: "night-owl" }) ``` -------------------------------- ### SolidJS Example: Usage with SolidStart Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/guides/usage-with-frameworks.mdx This example shows how to use the Prism code editor with SolidStart, a framework for building SolidJS applications. It covers setting up the editor component within a SolidStart project. ```tsx import Editor from "solid-prism-editor"; function EditorComponent() { return ( console.log(value)} /> ); } export default EditorComponent; ``` -------------------------------- ### Full Java Program Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/java.txt A complete Java program demonstrating class structure, method definitions, loops, conditional statements, and basic input/output. This example simulates a simple grid-based system. ```java import java.util.Scanner; public class Life { @Override @Bind("One") public void show(boolean[][] grid) { String s = ""; for (boolean[] row : grid) { for (boolean val : row) if(val) s += "*"; else s += "."; s += "\n"; } System.out.println(s); } public static boolean[][] gen() { boolean[][] grid = new boolean[10][10]; for (int r = 0; r < 10; r++) for (int c = 0; c < 10; c++) if ( Math.random() > 0.7 ) grid[r][c] = true; return grid; } public static void main(String[] args) { boolean[][] world = gen(); show(world); System.out.println(); world = nextGen(world); show(world); Scanner s = new Scanner(System.in); while (s.nextLine().length() == 0) { System.out.println(); world = nextGen(world); show(world); } } // [...] ``` -------------------------------- ### Run Dev Server Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/README.md Navigate to the docs directory and start the development server. ```bash cd ../docs pnpm dev ``` -------------------------------- ### Fortran Comments Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/fortran.txt Demonstrates the syntax for single-line comments in Fortran, which start with an exclamation mark. ```fortran ! This is a comment ``` -------------------------------- ### Full Prism Code Editor Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/factor.txt A comprehensive example demonstrating the definition and usage of various functions within the Prism code editor, including syntax classification and printing. ```prism USING: accessors arrays assocs combinators combinators.short-circuit effects io kernel sequences sequences.deep splitting strings vocabs words ; IN: prism : make-prism-syntax ( syntax-vocab -- seq ) vocab-words [ dup name>> ">>" = [ drop t ] [ { [ "delimiter" word-prop ] [ name>> last { CHAR: : CHAR: { CHAR: [ CHAR: ( CHAR: ) CHAR: ? CHAR: " } member? ] [ name>> { "t" "f" } member? ] } 1|| not ] ] if ] filter ; : combinator? ( word -- ? ) [ "declared-effect" word-prop in>> flatten [ [ effect? ] [ { "quots" "quot" } member? ] bi or ] any? ] [ "help" word-prop ?first flatten [ dup word? [ name>> ] when "quot" swap subseq? ] any? ] bi or ; : classify ( vocab-spec -- seq ) vocab-words [ dup { { [ dup combinator? ] [ drop "combinator" ] } { [ dup "macro" word-prop ] [ drop "macro" ] } [ drop "ordinary" ] } cond 2array ] map ; : print-strings ( strs -- ) [ name>> "'" dup surround ] map ", " join print ; recursive ! WARN: not recursive : combinators. ( vocab-spec -- ) classify [ nip "combinator" = ] assoc-filter keys print-strings ; flushable : ordinaries. ( vocab-spec -- ) classify [ nip "ordinary" = ] assoc-filter keys print-strings ; foldable : macros. ( vocab-spec -- ) classify [ nip "macro" = ] assoc-filter keys print-strings ; inline ``` -------------------------------- ### Getting Array Slice Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/arturo.txt Extracts a portion of an array using the `slice` command with start and end indices. ```Prism print slice ["one" "two" "three" "four"] 0 1 ; one two ``` -------------------------------- ### Install Dependencies Source: https://github.com/jonpyt/prism-code-editor/blob/main/markdown-it-plugin/README.md Install the markdown-it-prism-code-editor plugin along with its peer dependency prism-code-editor and the recommended wrapperless fence rule. Ensure you are using version 4.0.0 or greater for prism-code-editor. ```bash npm i prism-code-editor npm i markdown-it-prism-code-editor npm i @olets/markdown-it-wrapperless-fence-rule ``` -------------------------------- ### Build Package Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/README.md Navigate to the package directory and run the build command. ```bash cd ../package pnpm install pnpm build ``` -------------------------------- ### OpenCL Host Code Snippet Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/cpp.txt An example of OpenCL host code in C++ for running a kernel on an image. It includes setup for kernel arguments and event handling. ```cpp // OpenCL host code // OpenCL functions, constants, etc. are also highlighted in OpenCL host code in the c or cpp language cl::Event KernelFilterImages::runSingle(const cl::Image2D& imgSrc, SPImage2D& imgDst) { const size_t rows = imgSrc.getImageInfo(); const size_t cols = imgSrc.getImageInfo(); ASSERT(rows > 0 && cols > 0, "The image object seems to be invalid, no rows/cols set"); ASSERT(imgSrc.getImageInfo().image_channel_data_type == CL_FLOAT, "Only float type images are supported"); ASSERT(imgSrc.getInfo() == CL_MEM_READ_ONLY || imgSrc.getInfo() == CL_MEM_READ_WRITE, "Can't read the input image"); imgDst = std::make_shared(*context, CL_MEM_READ_WRITE, cl::ImageFormat(CL_R, CL_FLOAT), cols, rows); cl::Kernel kernel(*program, "filter_single"); kernel.setArg(0, imgSrc); kernel.setArg(1, *imgDst); kernel.setArg(2, bufferKernel1); kernel.setArg(3, kernel1.rows); kernel.setArg(4, kernel1.rows / 2); kernel.setArg(5, kernel1.cols); kernel.setArg(6, kernel1.cols / 2); kernel.setArg(7, border); cl::Event eventFilter; const cl::NDRange global(cols, rows); queue->enqueueNDRangeKernel(kernel, cl::NullRange, global, cl::NullRange, &events, &eventFilter); } ``` -------------------------------- ### Run Development Server Source: https://github.com/jonpyt/prism-code-editor/blob/main/react-package/README.md Navigate to the react-package directory and start the development server to test changes. ```bash cd ../react-package pnpm dev ``` -------------------------------- ### Nevod Full Example: URL Parsing Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/nevod.txt This comprehensive example demonstrates defining a complex pattern for URL parsing within a namespace, including methods, domains, ports, paths, queries, and anchors. ```nevod @namespace Common { @search @pattern Url(Domain, Path, Query, Anchor) = Method + Domain:Url.Domain + ?Port + ?Path:Url.Path + ?Query:Url.Query + ?Anchor:Url.Anchor @where { Method = {'http', 'https' , 'ftp', 'mailto', 'file', 'data', 'irc'} + '://'; Domain = Word + [1+ '.' + Word + [0+ {Word, '_', '-'}]]; Port = ':' + Num; Path = ?'/' + [0+ {Word, '/', '_', '+', '-', '%', '.'}]; Query = '?' + ?(Param + [0+ '&' + Param]) @where { Param = Identifier + '=' + Identifier @where { Identifier = {Alpha, AlphaNum, '_'} + [0+ {Word, '_'}]; }; }; Anchor(Value) = '#' + Value:{Word}; }; } ``` -------------------------------- ### HTTP Request Header Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/http.txt Demonstrates a typical HTTP GET request header, including the request line and various header fields like Accept-Language and Accept-Encoding. ```http GET http://localhost:9999/foo.html HTTP/1.1 Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate ``` -------------------------------- ### Build Documentation Site Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/README.md Run the build command to create a production build of the documentation site. ```bash pnpm build ``` -------------------------------- ### Run Development Server Source: https://github.com/jonpyt/prism-code-editor/blob/main/marked-extension/README.md Navigate to the marked-extension directory and run the development server. ```bash cd ../marked-extension pnpm dev ``` -------------------------------- ### Basic Markdown-it Setup with Prism Code Editor Source: https://github.com/jonpyt/prism-code-editor/blob/main/markdown-it-plugin/README.md Import necessary libraries and configure Markdown-it to use the prism-code-editor plugin and the wrapperless fence rule. This setup is essential for rendering code blocks as interactive editors. ```javascript import MarkdownIt from "markdown-it" import prismCodeEditor from "markdown-it-prism-code-editor" import markdownItWrapperlessFenceRule from "@olets/markdown-it-wrapperless-fence-rule" const md = MarkdownIt() md.renderer.rules.fence = markdownItWrapperlessFenceRule md.use(prismCodeEditor, { // More on configuration later }) md.render(/* some markdown */) ``` -------------------------------- ### Square Numbers Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/false.txt Shows how to square a number using a specific syntax. ```Unknown { Square numbers } [$*] s: 7s;! . {Outputs 49.} ``` -------------------------------- ### Full Example: Module, Functions, and Calls in Prism Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/v.txt A complete program demonstrating module import, function definitions (including named and anonymous), and function calls. Shows how functions can be passed as arguments. ```prism module mymodule import external_module fn sqr(n int) int { return n * n } fn run(value int, op fn (int) int) int { return op(value) } fn main() { println(run(5, sqr)) // "25" // Anonymous functions can be declared inside other functions: double_fn := fn (n int) int { return n + n } println(run(5, double_fn)) // "10" // Functions can be passed around without assigning them to variables: res := run(5, fn (n int) int { return n + n }) external_module.say_hi() } ``` -------------------------------- ### Run Development Server Source: https://github.com/jonpyt/prism-code-editor/blob/main/solid-package/README.md Navigate to the solid-package directory and run the development server to test changes. ```bash cd ../solid-package pnpm dev ``` -------------------------------- ### Lua Bottles of Beer Song Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/lua.txt A full Lua program implementing the 'bottles of beer' song using metatables and functions for dynamic string generation. Requires no external setup. ```lua function To_Functable(t, fn) return setmetatable(t, { __index = function(t, k) return fn(k) end, __call = function(t, k) return t[k] end }) end -- Functable bottles of beer implementation spell_out = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", [0] = "No more", [-1] = "Lots more" } spell_out = To_Functable(spell_out, function(i) return i end) bottles = To_Functable({"Just one bottle of beer"}, function(i) return spell_out(i) .. " bottles of beer" end) function line1(i) return bottles(i) .. " on the wall, " .. bottles(i) .. "\n" end line2 = To_Functable({[0] = "Go to the store, Buy some more,\n"}, function(i) return "Take one down and pass it around,\n" end) function line3(i) return bottles(i) .. " on the wall.\n" end function song(n) for i = n, 0, -1 do io.write(line1(i), line2(i), line3(i - 1), "\n") end end ``` -------------------------------- ### Game of Life Initialization and Setup Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/processing.txt Sets up the Processing canvas, initializes the cell grid with random states based on a probability, and defines colors and cell size. This code runs once at the start of the sketch. ```processing // Full example // Processing implementation of Game of Life by Joan Soler-Adillon // from https://processing.org/examples/gameoflife.html // Size of cells int cellSize = 5; // How likely for a cell to be alive at start (in percentage) float probabilityOfAliveAtStart = 15; // Variables for timer int interval = 100; int lastRecordedTime = 0; // Colors for active/inactive cells color alive = color(0, 200, 0); color dead = color(0); // Array of cells int[][] cells; // Buffer to record the state of the cells and use this while changing the others in the interations int[][] cellsBuffer; // Pause boolean pause = false; void setup() { size (640, 360); // Instantiate arrays cells = new int[width/cellSize][height/cellSize]; cellsBuffer = new int[width/cellSize][height/cellSize]; // This stroke will draw the background grid stroke(48); noSmooth(); // Initialization of cells for (int x=0; x probabilityOfAliveAtStart) { state = 0; } else { state = 1; } cells[x][y] = int(state); // Save state of each cell } } background(0); // Fill in black in case cells don't cover all the windows } ``` -------------------------------- ### DNS Zone File Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/dns-zone-file.txt This is a standard DNS zone file configuration. It includes the Start of Authority (SOA) record, Name Server (NS) records, and Address (A) and Canonical Name (CNAME) records for a domain. ```dns ; Full example $TTL 3d @ IN SOA root.localhost. root.sneaky.net. ( 2015050503 ; serial 12h ; refresh 15m ; retry 3w ; expire 3h ; negative response TTL ) IN NS root.localhost. IN NS localhost. ; secondary name server is preferably externally maintained www IN A 3.141.59.26 ww1 IN CNAME www ``` -------------------------------- ### Q Symbols Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/q.txt Shows examples of symbol literals in Q. ```q ` `q `zaphod `:198.162.0.2:5042 `:www.yourco.com:5042 `.new ``` -------------------------------- ### Define and Deploy a Passthrough Pipeline Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/tremor.txt This example demonstrates how to define a simple passthrough pipeline and then deploy it. It selects all events from the input and directs them to the output. ```prism define pipeline passthrough pipeline select event from in into out; end; deploy pipeline passthrough; ``` -------------------------------- ### LilyPond Full Score Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/lilypond.txt This snippet demonstrates a complete LilyPond score setup, including version, headers, global settings, and definitions for different musical voices (upper and bass). It also includes a markup for an exercise and the score structure with piano staff, upper staff, and lower staff containing the bass line and figured bass. ```lilypond \version "2.16.0" \include "example-header.ily" #(\ly:set-option 'point-and-click #f) #(\set-global-staff-size 24) global = { \time 4/4 \numericTimeSignature \key c \major } cf = \relative c { \clef bass \global c4 c' b a | g a f d | e f g g, | c1 } upper = \relative c'' { \global r4 s4 s2 | s1*2 | s2 s4 s \bar "||" } bassFigures = \figuremode { s1*2 | s4 <6> <6 4> <7> | s1 } \markup { "Exercise 3: Write 8th notes against the given bass line." } \score { \new PianoStaff << \new Staff { \context Voice = "added voice" \with { \consists "Balloon_engraver" } \upper } \new Staff = lower { << % \context Voice = "cantus firmus" \with { % \consists "Balloon_engraver" % } \context Staff = lower \cf \new FiguredBass \bassFigures >> } >> \layout {} %{\midi { \tempo 4 = 120 }%} } ``` -------------------------------- ### Arithmetic Increment Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/false.txt Demonstrates a simple arithmetic increment operation. ```Unknown { Increment } 5 [7+]! . {Outputs 12.} ``` -------------------------------- ### Install rehype-prism-code-editor Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/src/content/docs/markdown-plugins/getting-started.mdx Install the prism-code-editor and rehype-prism-code-editor packages for rehype integration. ```bash npm i prism-code-editor npm i rehype-prism-code-editor ``` -------------------------------- ### Sequence Syntax Examples Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/factor.txt Demonstrates the syntax for creating sequences, including nested and bracketed variations. ```prism { 1 2 3 4 } ``` ```prism { a b c d e t f } ``` ```prism { "a" "b" "c" } ``` ```prism { { a b } { c d } } ``` ```prism H{ { a b } { c d } } ``` ```prism H{ { "a" "b" } { "c" "d" } } ``` ```prism V{ 1 2 3 4 } ``` ```prism V{ "1" "2" "3" "4" } ``` ```prism BV{ 1 2 3 4 } ``` -------------------------------- ### Brainfuck 'Hello World!' Program Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/brainfuck.txt This Brainfuck program initializes several memory cells and uses nested loops to calculate the ASCII values for 'Hello World!' and prints them. It includes comments explaining each step. ```Brainfuck +++++ +++ Set Cell #0 to 8 [ >++++ Add 4 to Cell #1; this will always set Cell #1 to 4 [ >++ Add 2 to Cell #2 >+++ Add 3 to Cell #3 >+++ Add 3 to Cell #4 >+ Add 1 to Cell #5 <<<<- Decrement the loop counter in Cell #1 ] Loop till Cell #1 is zero; number of iterations is 4 >+ Add 1 to Cell #2 >+ Add 1 to Cell #3 >- Subtract 1 from Cell #4 >>+ Add 1 to Cell #6 [<] Move back to the first zero cell you find; this will
<- Decrement the loop Counter in Cell #0 ] ``` -------------------------------- ### Regular Expression Syntax Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/factor.txt Shows the syntax for defining regular expressions. ```prism USE: regexp R/ abcde?.*+\?\*\+\/\\\/idmsr-idmsr/idmsr-idmsr ``` -------------------------------- ### N4JS Express Web UI Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/n4js.txt A full example of a web user interface using N4JS with Express. It requires the full example project bundled with the N4JS IDE to run. ```n4js // Full example // A Web User Interface in HTML // NOTE: requires full example project bundled with N4JS IDE to run. import { TaskManager } from "TaskManager"; import { Application, Response } from "express"; import express from "express"; import { Todo } from "model"; export class WebUI { private app: Application; @Inject private manager: TaskManager; public start() { this.app = express(); this.app.get('/', async (req, res) => { let page = await this.renderHomePage(); res.send(page); }); this.app.get("/clear", async (req, res) => { await this.manager.clear(); redirect(res, '/'); }); this.app.get("/create", async (req, res) => { let values = req.query as ~Object with {type: string, label: string}; if (values && values.type === 'Todo' && values.label && values.label.length > 0) { await this.manager.createTodo(values.label); } redirect(res, '/'); }); this.app.listen(4000, '0.0.0.0', 511, function() { console.log("HTML server listening on http://localhost:4000/"); }); } protected async renderHomePage(): string { let tasks = await this.manager.getTasks(); let todos = tasks.filter((task) => task instanceof Todo); return ` Your to-do's:
    ${ todos.length === 0 ? '
  • none
  • \n' : todos.map((task) => '
  • ' + task.label + ' (id: ' + task.id + ')
  • ' ).join('\n') }

Label:

[Clear All] `; } } function redirect(res: Response, url: string) { res.header('Cache-Control', 'no-cache'); res.redirect(301, url); } ``` -------------------------------- ### Io Full Example: Factorial Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/io.txt A complete Io program demonstrating object creation, method definition, and a factorial calculation. ```io "Hello, world!" println A := Object clone // creates a new, empty object named "A" factorial := method(n, if(n == 0, return 1) res := 1 Range 1 to(n) foreach(i, res = res * i) ) ``` -------------------------------- ### Nix URLs and Paths Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/nix.txt Examples of common URL schemes and file path formats recognized in Nix. ```nix ftp://ftp.nluug.nl/pub/gnu/hello/hello-2.1.1.tar.gz http://example.org/foo.tar.bz2 /bin/sh ./builder.sh ~/foo.bar ``` -------------------------------- ### Install Marked Prism Code Editor Source: https://github.com/jonpyt/prism-code-editor/blob/main/marked-extension/README.md Install the marked-prism-code-editor package along with its peer dependency, prism-code-editor. ```bash npm i prism-code-editor marked-prism-code-editor ``` -------------------------------- ### Pug Markup Example Source: https://github.com/jonpyt/prism-code-editor/blob/main/docs/public/examples/pug.txt A simple example of including raw HTML markup within a Pug file. ```pug
``` -------------------------------- ### Run Development Server Source: https://github.com/jonpyt/prism-code-editor/blob/main/markdown-it-plugin/README.md After building the prism-code-editor package, navigate back to the markdown-it-plugin directory and start the development server. ```bash cd ../markdown-it-plugin pnpm dev ```