### Minimal REPLy Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/reply/README.md This is a basic example demonstrating how to initialize and use the REPLy reader in a loop. It prints the evaluated expression back to the console. ```crystal require "reply" reader = Reply::Reader.new reader.read_loop do |expression| # Eval expression here puts " => #{expression}" end ``` -------------------------------- ### Markdown List Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example of equivalent list formatting in Markdown syntax. Demonstrates readability and structure. ```markdown 1. List item one. List item one continued with a second paragraph followed by an Indented block. $ ls *.sh $ mv *.sh ~\/tmp List item continued with a third paragraph. 2. List item two continued with an open block. This paragraph is part of the preceding list item. 1. This list is nested and does not require explicit item continuation. This paragraph is part of the preceding list item. 2. List item b. This paragraph belongs to item two of the outer list. ``` -------------------------------- ### Install Boehm GC from Source Source: https://github.com/crystal-lang/crystal/wiki/All-required-libraries Installs the Boehm Garbage Collector from its Git repository. Ensure you have build tools like autoconf, automake, and a C++ compiler. This method is useful if your distribution's package is outdated. ```shell git clone https://github.com/ivmai/bdwgc.git cd bdwgc ./autogen.sh ./configure --enable-static --disable-shared --enable-large-config make -j CFLAGS=-DNO_GETCONTEXT make check sudo make install ``` -------------------------------- ### AsciiDoc List Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example of list formatting in AsciiDoc syntax. This is provided for comparison with Markdown. ```asciidoc 1. List item one. + List item one continued with a second paragraph followed by an Indented block. + ................. $ ls *.sh $ mv *.sh ~\/tmp ................. + List item continued with a third paragraph. 2. List item two continued with an open block. + -- This paragraph is part of the preceding list item. a. This list is nested and does not require explicit item continuation. + This paragraph is part of the preceding list item. b. List item b. This paragraph belongs to item two of the outer list. -- ``` -------------------------------- ### Install C++ Build Tools for Visual Studio 2019 Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Installs the necessary C++ build tools and ATL component for LLVM. Keep the terminal open until the process completes. ```powershell .\vs_buildtools.exe --passive --norestart --wait --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.ATL --includeRecommended ``` -------------------------------- ### Valid ordered list start number (9 digits) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Ordered list start numbers must be nine digits or less. This example shows a valid start number. ```markdown 123456789. ok ``` -------------------------------- ### Install Debian/Ubuntu Build Dependencies Source: https://github.com/crystal-lang/crystal/wiki/All-required-libraries Installs necessary packages for building Crystal on Debian-based systems like Ubuntu. Includes build tools, development libraries for GMP, event, SSL, PCRE2, and XML/YAML. ```shell sudo apt-get install -y \ automake \ build-essential \ git \ libbsd-dev \ libevent-dev \ libgmp-dev \ libgmpxx4ldbl \ libpcre2-dev \ libssl-dev \ libtool \ libxml2-dev \ libyaml-dev \ lld \ llvm \ llvm-dev \ libz-dev ``` -------------------------------- ### Install Git Pre-commit Hook Source: https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md Install the pre-commit hook to ensure code is formatted correctly before each commit. This hook runs `crystal tool format`. ```sh ln -s scripts/git/pre-commit .git/hooks ``` -------------------------------- ### Build Example Program on Windows Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Builds a Crystal program ('hello.cr') on Windows using a locally compiled Crystal executable. Sets necessary environment variables. ```cmd set CRYSTAL_PATH=src set LIB=%LIB%;C:\crystal set TERM=dumb crystal.exe build hello.cr ``` -------------------------------- ### Running an HTTP Server with Crystal Source: https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/tools/playground/views/_about.html Demonstrates how to create and run a basic HTTP server using the `http/server` library. This example shows how to handle requests and send responses. ```crystal require "http/server" server = HTTP::Server.new do |context| context.request.path context.response.headers["Content-Type"] = "text/plain" context.response.print("Hello world!") end server.bind_tcp "0.0.0.0", 5678 puts "Listening on http://0.0.0.0:5678" server.listen ``` -------------------------------- ### Install Fedora Build Dependencies Source: https://github.com/crystal-lang/crystal/wiki/All-required-libraries Installs required packages for building Crystal on Fedora. Includes C/C++ compilers, development libraries for GMP, event, SSL, PCRE2, and XML/YAML, along with LLVM and make. ```shell sudo dnf -y install \ gcc \ gcc-c++ \ gmp-devel \ libbsd-devel \ libevent-devel \ libxml2-devel \ libyaml-devel \ llvm-devel \ llvm-static \ libstdc++-static \ make \ openssl-devel \ pcre2-devel \ redhat-rpm-config ``` -------------------------------- ### HTML Block Example with Nested Pre Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates how an HTML block, started by '', is terminated by a blank line, even if it contains a '
' tag. Regular Markdown parsing resumes afterward.

```markdown
**Hello**,

_world_.
. table>
**Hello**,

world.

``` -------------------------------- ### Markdown.pl Two-Space Indentation Example (HTML Output) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows the HTML output for the `Markdown.pl` two-space indentation example, where 'two' is parsed as a continuation paragraph of the list item. ```html ``` -------------------------------- ### Basic HTML Block Example (Type 6) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates a basic HTML block of type 6, starting with '' and ending at a blank line. The content within the block is treated as raw HTML. ```markdown
hi
okay. .
hi

okay.

``` -------------------------------- ### Install macOS Build Dependencies with Homebrew Source: https://github.com/crystal-lang/crystal/wiki/All-required-libraries Installs essential libraries for building Crystal on macOS using Homebrew. Includes Boehm GC, GMP, libevent, libxml2, libyaml, LLVM, OpenSSL, PCRE2, and pkg-config. ```shell xcode-select --install brew install \ bdw-gc \ gmp \ libevent \ libxml2 \ libyaml \ llvm \ openssl \ pcre2 \ pkg-config ``` -------------------------------- ### Install Markd Dependency Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/README.md Add the Markd gem to your application's shard.yml file for installation. ```yaml dependencies: markd: github: icyleaf/markd ``` -------------------------------- ### Customizing REPLy Interface Source: https://github.com/crystal-lang/crystal/blob/master/lib/reply/README.md This example shows how to extend the `Reply::Reader` class to customize the REPL interface. It includes methods for defining a custom prompt, syntax highlighting, multi-line input logic, auto-formatting, indentation, history saving, and auto-completion. ```crystal require "reply" class MyReader < Reply::Reader def prompt(io : IO, line_number : Int32, color : Bool) : Nil # Display a custom prompt end def highlight(expression : String) : String # Highlight the expression end def continue?(expression : String) : Bool # Return whether the interface should continue on multiline, depending of the expression end def format(expression : String) : String? # Reformat when expression is submitted end def indentation_level(expression_before_cursor : String) : Int32? # Compute the indentation from the expression end def save_in_history?(expression : String) : Bool # Return whether the expression is saved in history end def auto_complete(name_filter : String, expression : String) : {String, Array(String)} # Return the auto-completion result from expression end end ``` -------------------------------- ### URI Autolink Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a basic URI autolink. Ensure the URI is absolute and enclosed in angle brackets. ```markdown .

http://foo.bar.baz

``` -------------------------------- ### Download and Build LLVM Source for Windows Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Downloads LLVM source code and builds it using CMake for Windows. This requires Python and 7-Zip to be installed. ```powershell iwr https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/llvm-10.0.0.src.tar.xz -OutFile llvm.tar.xz & "C:\Program Files\7-Zip\7z.exe" x llvm.tar.xz & "C:\Program Files\7-Zip\7z.exe" x llvm.tar move llvm-* llvm ``` ```powershell cd llvm cmake . -DBUILD_SHARED_LIBS=OFF -Thost=x64 -DLLVM_TARGETS_TO_BUILD="X86" -DLLVM_USE_CRT_RELEASE=MT cmake --build . --config Release ``` -------------------------------- ### Flexible Indentation Example (Markdown) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example demonstrating a more flexible indentation rule where a continuation paragraph ('bar') is considered part of the list item even if not indented as far as the first paragraph ('foo'), as long as it's indented relative to the list marker. ```markdown 10. foo bar ``` -------------------------------- ### Markdown Emphasis and Strong Emphasis Examples Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates various ways to achieve strong emphasis and nested emphasis using asterisks and underscores in Markdown. ```markdown ***strong emph*** ***strong** in emph* ***emph* in strong** **in strong *emph*** *in emph **strong*** ``` ```markdown *emph *with emph* in it* **strong **with strong** in it** ``` ```markdown internal emphasis: foo*bar*baz no emphasis: foo_bar_baz ``` -------------------------------- ### HTML Block: Non-standard Tag Start Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows an HTML block where the initial tag starts like a tag but contains non-standard characters. ```html
``` -------------------------------- ### HTML Block: Pre Tag Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example of a `
` tag (type 1 block) which can contain blank lines and ends at the corresponding end tag.

```html

import Text.HTML.TagSoup

main :: IO ()
main = print $ parseTags tags
okay . ``` -------------------------------- ### HTML Block: Style Tag Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example of a ` okay . ``` -------------------------------- ### Non-entities Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Examples of strings that are not recognized as valid entity or numeric character references, including malformed ones. ```html   &x; &#; &#x; � &#abcdef0; &ThisIsNotDefined; &hi?; . ``` ```html

&nbsp &x; &#; &#x; &#987654321; &#abcdef0; &ThisIsNotDefined; &hi?;

``` -------------------------------- ### Basic HTML Block Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a simple HTML block within Markdown. The content inside the block is rendered as HTML. ```markdown
- foo .
  • foo
``` -------------------------------- ### Ordered List Item with Content Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates an ordered list item with a start number of 1, showing how its content is structured similarly to a basic list item. ```markdown 1. A paragraph with two lines. indented code > A block quote. . ``` -------------------------------- ### Empty Emphasis and Strong Emphasis Not Allowed Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows examples that are not considered empty emphasis or strong emphasis. ```markdown ** is not an empty emphasis ``` ```markdown **** is not an empty strong emphasis ``` ```markdown __ is not an empty emphasis ``` ```markdown ____ is not an empty strong emphasis ``` -------------------------------- ### Markdown Empty List Item at Start Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates an empty list item at the beginning of a list. This is valid and renders as an empty list element. ```markdown * ``` ```html
``` -------------------------------- ### Example of Nested Code Spans Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates the use of nested backticks within a code span. This is useful for showing code examples that themselves contain backticks. ```markdown `foo``bar` ``` -------------------------------- ### HTML Block: Script Tag Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example of a ` okay . ``` -------------------------------- ### Document Tree Structure Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates a possible document tree structure, showing nested blocks like block_quote, list, and list_item. Open blocks are indicated by arrows. ```tree -> document -> block_quote paragraph "Lorem ipsum dolor\nsit amet." -> list (type=bullet tight=true bullet_char=-) list_item paragraph "Qui *quodsi iracundia*" -> list_item -> paragraph "aliquando id" ``` -------------------------------- ### Empty List Item Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows an example of an empty list item, raising questions about its validity and rendering. ```markdown * a * * b ``` -------------------------------- ### Delimiter Run Examples in Markdown Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates different types of delimiter runs (left-flanking, right-flanking, or both) used in Markdown emphasis parsing. ```markdown ***abc _abc **"abc" _"abc" ``` ```markdown abc*** abc_ "abc"** "abc"_ ``` ```markdown abc***def "abc"_"def" ``` ```markdown abc *** def a _ b ``` -------------------------------- ### Format Code According to Style Guide Source: https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md Use 'crystal tool format' to automatically format your code, ensuring it adheres to the project's coding style guidelines. ```shell crystal tool format ``` -------------------------------- ### Setext Heading Level 1 and 2 Examples Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates the creation of level 1 and level 2 Setext headings using '=' and '-' underlines respectively. The content is parsed as CommonMark inline. ```markdown Foo *bar* ========= Foo *bar* --------- ``` -------------------------------- ### Basic Block Quote Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a standard block quote with a heading and paragraphs. Requires a '>' followed by a space at the beginning of each line. ```markdown > # Foo > bar > baz ``` ```html

Foo

bar baz

``` -------------------------------- ### Indented HTML Start Tag (Valid) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows that an HTML start tag can be indented with 1-3 spaces and still be recognized as an HTML block. Indentation of 4 spaces is not allowed. ```markdown .
<!-- foo -->
``` ```markdown
.
<div>
``` -------------------------------- ### HTML Table Structure Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a basic HTML table structure. This is an example of how HTML content might be represented. ```html
Hi
``` -------------------------------- ### Emphasis and Strong Emphasis Precedence Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows an example of ambiguous precedence rules between emphasis and strong emphasis markers. ```markdown *foo *bar* baz* ``` -------------------------------- ### Ruby Trailing While Example Source: https://github.com/crystal-lang/crystal/wiki/FAQ Demonstrates the syntax for a trailing 'while' loop in Ruby, which first checks the condition and then executes the code block. ```ruby # This one first checks and then executes while ``` -------------------------------- ### Email Autolink Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a valid email address enclosed in angle brackets, parsed as a 'mailto:' link. ```markdown .

foo@bar.example.com

``` -------------------------------- ### Invalid ordered list start number (negative) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Ordered list start numbers cannot be negative. This example shows an invalid negative start number. ```markdown -1. not ok ``` -------------------------------- ### Smart Quotes Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/smart_punct.txt Demonstrates matching of open and closed double quotes. Use this for standard text quotation. ```text "Hello," said the spider. "'Shelob' is my name." . ``` -------------------------------- ### Valid ordered list start number with leading zeros Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Ordered list start numbers can have leading zeros, which are interpreted correctly. This example shows a valid start number with leading zeros. ```markdown 0. ok ``` ```markdown 003. ok ``` -------------------------------- ### Generate Standard Library Documentation Source: https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md Execute 'make docs' to generate the standard library documentation. Ensure your code follows the documented conventions. ```shell make docs ``` -------------------------------- ### Invalid ordered list start number (10 digits) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Ordered list start numbers exceeding nine digits are not rendered as ordered lists. This example shows an invalid start number. ```markdown 1234567890. not ok ``` -------------------------------- ### Markdown Link Reference Definition Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a basic link reference definition and its usage. The definition `[bar]: /baz` is followed by a reference `[bar]` which is rendered as a link. ```markdown Foo [bar]: /baz [bar] ``` ```html

Foo [bar]: /baz

bar

``` -------------------------------- ### Code Span vs. HTML Tag Precedence Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Code spans and HTML tags share the same precedence. This example is treated as code because it starts with '<' followed by a backtick. ```markdown ```````````````````````````````` example ` . ``` -------------------------------- ### Image with Space Between Brackets Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An image syntax example demonstrating that whitespace is not allowed between the description brackets and the reference label brackets. ```markdown ![foo] [] [foo]: /url "title" ``` ```html

foo []

``` -------------------------------- ### HTML Block with Partial Tag Start Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates an HTML block where the opening tag is split across lines. The block is terminated by a blank line, and the content is treated as raw HTML. ```markdown
.
``` -------------------------------- ### List Available Make Targets Source: https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md Use 'make help' to view a comprehensive list of all available make targets for building, testing, and managing the Crystal project. ```shell make help ``` -------------------------------- ### Markdown List Interruption Rule Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows an example where a numeral in a hard-wrapped line does not trigger a list, contrasting with CommonMark's behavior for lists starting with '1'. ```markdown The number of windows in my house is 14. The number of doors is 6. ``` ```html

The number of windows in my house is 14. The number of doors is 6.

``` -------------------------------- ### Smart Single Quotes Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/smart_punct.txt Demonstrates matching of open and closed single quotes. Use this for nested quotations or specific stylistic choices. ```text 'A', 'B', and 'C' are letters. . ``` -------------------------------- ### Numbered List as First Block in List Item Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates a list item starting with a numbered list, showing how different list types can be nested. ```markdown 1. - 2. foo ``` ```html
      1. foo
``` -------------------------------- ### Four-Space Rule Example (HTML Output) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows the HTML output generated by adhering to the four-space rule, which parses the above Markdown as two separate lists with an intervening paragraph. ```html
  • foo

bar

  • baz
``` -------------------------------- ### Example of List Item Content Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates the content of a list item when parsed from Markdown, showing how paragraphs, code blocks, and block quotes are structured. ```markdown A paragraph with two lines. indented code > A block quote. . ``` -------------------------------- ### Link Hello World executable on Windows Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Links the compiled object file into an executable on Windows using the MSVC linker. Ensure you are in the C:\crystal directory and have the necessary libraries. ```cmd cd C:\crystal cl hello_world.obj "/Fehello_world" pcre.lib gc.lib advapi32.lib legacy_stdio_definitions.lib libcmt.lib .\hello_world.exe ``` -------------------------------- ### Build libyaml for Windows Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Builds the libyaml library using CMake for Windows. Ensure you are in the libyaml directory before running. ```bash cd libyaml cmake . -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF cmake --build . --config Release cd .. ``` -------------------------------- ### Markdown.pl Indented Blockquote Example (Markdown) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates `Markdown.pl`'s handling of list items within blockquotes, showing how indentation rules apply. ```markdown > - one > > two ``` -------------------------------- ### Set Up Appointment (JavaScript) Source: https://github.com/crystal-lang/crystal/blob/master/spec/std/data/large_single_line_string.txt This function is used to set up an appointment with specific parameters including an ID, coordinates, and a boolean flag. Ensure all parameters are correctly provided. ```javascript javascript:SetUpAppoint('67','3', '3-8687600', '27683', '15', 'false'); return false; ``` ```javascript javascript:SetUpAppoint('68','2', '2', '14451', 'false'); return false; ``` -------------------------------- ### Build the Crystal Compiler Source: https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md Run 'make crystal' to build the compiler. The executable will be located at '.build/compiler'. Use the 'bin/crystal' wrapper script to run it. ```shell make crystal ``` -------------------------------- ### Crystal Class Definition Example Source: https://github.com/crystal-lang/crystal/wiki/Compiler-internals Illustrates a nested class definition with a method, which the type inference stage processes to declare types and methods. ```crystal class Foo class Bar def baz 1 end end end ``` -------------------------------- ### Run Compiler Specifications Source: https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md Execute 'make compiler_spec' to run the compiler's specifications. Use 'make primitives_spec' for primitive method specs. ```shell make compiler_spec ``` ```shell make primitives_spec ``` -------------------------------- ### Cross-compile Hello World for Windows Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Compiles a simple 'Hello World' program for Windows using Crystal's cross-compilation feature. This generates an object file and a suggested linker command. ```bash echo 'puts "Hello world!"' > hello_world.cr bin/crystal build --cross-compile --target x86_64-pc-windows-msvc hello_world.cr ``` -------------------------------- ### Markdown.pl Two-Space Indentation Example (Markdown) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates the behavior of `Markdown.pl` where a paragraph following a list item can be indented with fewer spaces than the list marker, still being considered part of the list item. ```markdown - one two ``` -------------------------------- ### Hexadecimal Numeric Character References Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates hexadecimal numeric character references, parsed as their corresponding Unicode characters using hexadecimal notation. ```html " ആ ಫ . ``` ```html

" ആ ಫ

``` -------------------------------- ### Using puts for Output in Crystal Source: https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/tools/playground/views/_about.html Shows how to use the `puts` method to print output, which appears in the bottom panel of the playground. Note that `puts` returns `nil`. ```crystal s = "Lorem ipsum" puts s ``` -------------------------------- ### Changing Bullet or Ordered List Delimiters Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates how changing the list marker (e.g., from '-' to '+') starts a new list. Shows the resulting HTML for both bullet and ordered lists. ```markdown - foo - bar + baz ``` ```html
  • foo
  • bar
  • baz
``` ```markdown 1. foo 2. bar 3) baz ``` ```html
  1. foo
  2. bar
  1. baz
``` -------------------------------- ### Build libz for Windows Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Builds the zlib library using CMake for Windows. Ensure you are in the zlib directory before running. ```bash cd zlib cmake . -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF cmake --build . --config Release cd .. ``` -------------------------------- ### Download and Build libgc Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Downloads and builds the libgc library, a garbage collector, for use with Crystal. Ensure the destination path is correctly set. ```powershell # Download libgc iwr https://github.com/ivmai/bdwgc/archive/2fd48a92b8bff3afb64b3528ad78b63f033f0436.zip -OutFile bdwgc.zip Expand-Archive bdwgc.zip -DestinationPath . mv bdwgc-* bdwgc # Download libatomic_ops iwr https://github.com/ivmai/libatomic_ops/archive/v7.6.10.zip -OutFile libatomic_ops.zip Expand-Archive libatomic_ops.zip -DestinationPath . mv libatomic_ops-* bdwgc\libatomic_ops # Build libgc cd bdwgc cmake . -DBUILD_SHARED_LIBS=OFF -Denable_large_config=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded cmake --build . --config Release cd .. ``` -------------------------------- ### Build an Executable Crystal Program Source: https://github.com/crystal-lang/crystal/blob/master/doc/man/crystal.adoc Use the 'build' command to compile a Crystal program into an executable file. By default, the executable will have the same name as the source file. ```shell crystal build some_program.cr ``` -------------------------------- ### Custom Markdown Renderer Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/README.md Extend the Markd::Renderer class to create a custom renderer. Override methods like 'strong' to modify how specific markdown elements are processed. This example shows how to parse markdown with custom options and then render it using the custom renderer. ```crystal class CustomRenderer < Markd::Renderer def strong(node, entering) end # more methods following in render. end options = Markd::Options.new(time: true) document = Markd.parse(markdown, options) renderer = CustomRenderer.new(options) html = renderer.render(document) ``` -------------------------------- ### Download and Build mpir Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Downloads and builds the MPIR library, a multi-precision integer library. This command uses MSBuild to compile the project. ```powershell # Download mpir iwr https://github.com/BrianGladman/mpir/archive/d9c9a842be6475bef74324f367ce2c5a78c55d06.zip -OutFile mpir.zip Expand-Archive mpir.zip -DestinationPath . mv mpir* mpir # Build mpir cd mpir MSBuild.exe /p:Platform=x64 /p:Configuration=Release /p:DefineConstants=MSC_BUILD_DLL ".\msvc\vs19\lib_mpir_gc\lib_mpir_gc.vcxproj" cd .. mv mpir\lib\x64\Release\mpir.lib . ``` -------------------------------- ### HTML Block: Closing Tag Only Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows an HTML block starting with only a closing tag. ```html *bar* . ``` -------------------------------- ### Made-up Scheme Autolink Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example of an autolink with a made-up scheme, which is still parsed as a link. ```markdown .

made-up-scheme://foo,bar

``` -------------------------------- ### HTML Block: Table Structure Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example of an HTML block containing a table structure. ```html
foo
. ``` -------------------------------- ### Emphasis with Literal Asterisks Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Examples of emphasis containing literal asterisks, including escaped ones. ```markdown foo *** ``` ```markdown foo *\** ``` ```markdown foo *_* ``` ```markdown foo ***** ``` ```markdown foo **\*** ``` ```markdown foo **_** ``` -------------------------------- ### Download and Build libxml2 Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Downloads and builds the libxml2 library, used for XML parsing. It's configured to disable HTTP/FTP support and tests, and uses a multi-threaded runtime. ```powershell # Download libxml2 iwr https://github.com/GNOME/libxml2/archive/a230b728f1289dd24c1666856ac4fb55579c6dfb.zip -OutFile libxml2.zip Expand-Archive libxml2.zip -DestinationPath . mv libxml2* libxml2 # Build libxml2 cd libxml2 cmake . -DBUILD_SHARED_LIBS=OFF -DLIBXML2_WITH_HTTP=OFF -DLIBXML2_WITH_FTP=OFF -DLIBXML2_WITH_TESTS=OFF -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded -DCMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH=OFF cmake --build . --config Release cd .. mv libxml2\Release\xml2.lib . ``` -------------------------------- ### Not an Autolink: Scheme with Colon Only Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt A string starting with a scheme and colon but lacking characters after the colon is not a valid autolink. ```markdown .

<m:abc>

``` -------------------------------- ### Escaped Characters as Regular Characters Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Provides examples of escaped characters that lose their special Markdown meaning. ```markdown \*not emphasized* \
not a tag \[not a link](/foo) \`not code` 1\. not a list \* not a list \# not a heading \[foo]: /url "not a reference" \ö not a character entity ``` -------------------------------- ### Run Standard Library Specifications Source: https://github.com/crystal-lang/crystal/blob/master/CONTRIBUTING.md Execute 'make std_spec' to run all specifications for the standard library. For a specific spec file, use 'bin/crystal spec '. ```shell make std_spec ``` ```shell bin/crystal spec spec/std/array_spec.cr ``` -------------------------------- ### HTML Block: Inline Tag with Attributes Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example of an HTML block using an inline tag with attributes. ```html *bar* . ``` -------------------------------- ### Compile and Run a Crystal Program with 'run' command Source: https://github.com/crystal-lang/crystal/blob/master/doc/man/crystal.adoc An alternative method to compile and run a Crystal program using the 'run' command. This is useful for quick execution without creating a separate executable. ```shell crystal run some_program.cr ``` -------------------------------- ### Download libyaml Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Downloads the libyaml library, a YAML parser and emitter. This snippet only downloads the library; building instructions are not included. ```powershell # Download libyaml iwr https://github.com/yaml/libyaml/archive/0.2.4.zip -OutFile libyaml.zip Expand-Archive libyaml.zip -DestinationPath . mv libyaml* libyaml ``` -------------------------------- ### Download and Extract libz Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Downloads and extracts the zlib library from a GitHub release using PowerShell. ```powershell iwr https://github.com/madler/zlib/archive/v1.2.11.zip -OutFile zlib.zip Expand-Archive zlib.zip -DestinationPath . mv zlib* zlib ``` -------------------------------- ### Uppercase URI Autolink Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates that URI schemes in autolinks are case-insensitive. This example uses an uppercase MAILTO scheme. ```markdown .

MAILTO:FOO@BAR.BAZ

``` -------------------------------- ### Basic Unordered List Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a simple unordered list structure. ```markdown - foo notcode - foo ``` -------------------------------- ### Strong Emphasis with Literal Underscores Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Examples of strong emphasis containing literal underscores, including escaped ones. ```markdown foo ___ ``` ```markdown foo _\__ ``` -------------------------------- ### Build an Optimized Executable Crystal Program Source: https://github.com/crystal-lang/crystal/blob/master/doc/man/crystal.adoc Compile a Crystal program into an executable with optimizations enabled using the '--release' flag. This is recommended for production-ready executables and benchmarks. ```shell crystal build --release some_program.cr ``` -------------------------------- ### Basic Emphasis and Strong Emphasis Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates basic usage of emphasis and strong emphasis. ```markdown foo***bar***baz ``` ```markdown foo******bar*********baz ``` -------------------------------- ### Incorrect Nested List Indentation Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows an example of incorrect indentation for nested lists, where sublists are not properly indented. ```markdown - foo - bar - baz - boo ``` ```html
  • foo
  • bar
  • baz
  • boo
``` -------------------------------- ### Running Markdown Spec Tests Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Use this command to run conformance tests against a Markdown program using the spec.txt file. ```shell python test/spec_tests.py --spec spec.txt --program PROGRAM ``` -------------------------------- ### Download and Build libpcre Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Downloads and builds the PCRE library, used for regular expressions. Configures it for Unicode properties and JIT support. ```powershell # Download libpcre iwr https://cs.stanford.edu/pub/exim/pcre/pcre-8.43.zip -OutFile pcre.zip Expand-Archive pcre.zip -DestinationPath . mv pcre* pcre # Build libpcre cd pcre cmake . -DBUILD_SHARED_LIBS=OFF -DPCRE_SUPPORT_UNICODE_PROPERTIES=ON -DPCRE_SUPPORT_JIT=ON -DPCRE_STATIC_RUNTIME=ON cmake --build . --config Release cd .. mv pcre\Release\pcre.lib . ``` -------------------------------- ### Code Span vs. Autolink Precedence Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt This example is parsed as code because the URL contains a backtick, preventing it from being recognized as an autolink. ```markdown ```````````````````````````````` example `` . ``` -------------------------------- ### Clone Crystal and Build Natively on Windows Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows Clone the Crystal repository and build a native development compiler using the Windows-specific Makefile. Ensure core.autocrlf is set to false during cloning to prevent line ending issues. ```bash git clone -c core.autocrlf=false https://github.com/crystal-lang/crystal.git cd crystal make -fMakefile.win crystal format release=1 ``` -------------------------------- ### Undefined Entity Reference Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows that entity references not on the HTML5 named entities list are treated as literal text. ```html &MadeUpEntity; . ``` ```html

&MadeUpEntity;

``` -------------------------------- ### Link Reference Definition with Omitted Title Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Example of a link reference definition where the title is omitted, but the URL is still present. ```markdown [foo]: /url ``` -------------------------------- ### Basic Fenced Code Block with Tildes Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a simple fenced code block using tildes. The info string specifies the language. ```markdown ~~~ < > ~~~ ``` -------------------------------- ### HTML Comment Block (Type 2) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Example of an HTML comment block, including multi-line comments. These are treated as HTML. ```markdown okay.

okay

``` -------------------------------- ### HTML Block: Tag Not in Block-Level List Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows how to start an HTML block with a tag not in the standard block-level list by placing it on its own line. ```html *bar* . ``` -------------------------------- ### Build crystal.obj for Windows Cross-Compilation Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows Use this command to build the crystal.obj file on a non-Windows host for Windows cross-compilation. Ensure CRYSTAL_LIBRARY_PATH includes the 'lib' directory from a Windows Crystal package. ```bash CRYSTAL_LIBRARY_PATH=... make target=x86_64-windows-msvc FLAGS=-Dpreview_dll ``` -------------------------------- ### Crystal Equivalent to Ruby's pack/unpack using IO Source: https://github.com/crystal-lang/crystal/wiki/FAQ Shows how to serialize an array of numbers into a string using Crystal's IO module, similar to Ruby's `Array#pack`. ```crystal n = [65, 66, 67] # Ruby # n.pack("ccc") #=> "ABC" # Crystal String.build do |io| n.each do |number| io.write_byte number.to_u8 end end #=> "ABC" ``` -------------------------------- ### Build Crystal Compiler on Windows using Windows Crystal Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Builds the Crystal compiler on Windows using a previously compiled Windows Crystal executable. This is part of the bootstrapping process. ```cmd set LLVM_CONFIG=C:\crystal\llvm\Release\bin\llvm-config.exe crystal.exe build src/compiler/crystal.cr -Di_know_what_im_doing -Dwithout_playground --link-flags=/STACK:10000000 -ocrystal2 crystal2.exe build src/compiler/crystal.cr -Di_know_what_im_doing -Dwithout_playground --link-flags=/STACK:10000000 -ocrystal3 ``` -------------------------------- ### Basic Variable Assignment in Crystal Source: https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/tools/playground/views/_about.html Demonstrates simple variable assignment and how values are displayed in the playground's side panel. ```crystal a = 1 b = 3 ``` -------------------------------- ### List Item Paragraph Wrapping Ambiguity Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows examples of lists where the rules for wrapping list items in

tags are ambiguous. ```markdown 1. one 2. two 3. three ``` ```markdown 1. one - a - b 2. two ``` -------------------------------- ### Invalid Autolink: Space in URI Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows an example where spaces within angle brackets prevent autolink parsing. It is rendered as literal text. ```markdown .

<http://foo.bar/baz bim>

``` -------------------------------- ### Image with Unescaped Brackets in Label Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt An example showing that link labels in Markdown images cannot contain unescaped brackets. This results in literal rendering. ```markdown ![[foo]] [[foo]]: /url "title" ``` ```html

![[foo]]

[[foo]]: /url "title"

``` -------------------------------- ### Basic Emphasis with Underscores Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates simple emphasis using single underscores. Ensure delimiters do not match evenly to avoid unexpected behavior. ```markdown foo _*_ .

foo *

``` ```markdown foo _____ .

foo _____

``` ```markdown foo __\___ .

foo _

``` ```markdown foo __*__ .

foo *

``` ```markdown __foo_ .

_foo

``` -------------------------------- ### Compile and Run a Crystal Program Source: https://github.com/crystal-lang/crystal/blob/master/doc/man/crystal.adoc Use this command to compile and immediately run a Crystal source file. The source file typically ends with the .cr extension. ```shell crystal some_program.cr ``` -------------------------------- ### Invalid Pointy Bracket Matching Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Examples showing incorrect matching of pointy brackets in link destinations, which results in the text not being rendered as a link. ```markdown [a]( ``` ```markdown [a](c) ``` ```html

[a](<b)c [a](<b)c> [a](<b>c)

``` -------------------------------- ### Code Span Precedence over Emphasis Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Code spans have higher precedence than emphasis. The second asterisk in this example is part of the code span, not emphasis. ```markdown ```````````````````````````````` example *foo`*` . ``` -------------------------------- ### Entity Reference Without Semicolon Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates that HTML entity references without a trailing semicolon (like ©) are not recognized in CommonMark. ```html © . ``` ```html

&copy

``` -------------------------------- ### Convert CMD to PowerShell Source: https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows-(old) Allows switching from a Command Prompt session to a PowerShell session after setting up the environment. ```powershell powershell ``` -------------------------------- ### Nested Tight List Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a nested tight list structure. ```markdown - a - b ``` -------------------------------- ### Precedence of Full and Compact References Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows that full and compact reference links take precedence over shortcut references. ```markdown [foo][bar] [foo]: /url1 [bar]: /url2 .

foo

``` ```markdown [foo][] [foo]: /url1 .

foo

``` -------------------------------- ### Shortcut Reference Link with Inline Formatting Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates a shortcut reference link where the link text contains inline formatting. ```markdown [*foo* bar] [*foo* bar]: /url "title" .

foo bar

``` -------------------------------- ### HTML Entity References Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates the use of various HTML entity references for special characters. These are recognized outside of code blocks and spans. ```html   & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸ . ``` ```html

  & © Æ Ď ¾ ℋ ⅆ ∲ ≧̸

``` -------------------------------- ### HTML Table with Inner Tags Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates an HTML table structure. This example highlights potential issues when inner tags are indented, which can affect parsing. ```markdown
Hi
.
Hi
``` -------------------------------- ### Markdown Link Reference Definitions Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates defining and using link references in Markdown. Ensure definitions precede their usage. ```markdown [foo]: /url bar === [foo] .

bar

foo

``` ```markdown [foo]: /url === [foo] .

=== foo

``` ```markdown [foo]: /foo-url "foo" [bar]: /bar-url "bar" [baz]: /baz-url [foo], [bar], [baz] .

foo, bar, baz

``` ```markdown [foo] > [foo]: /url .

foo

``` ```markdown [foo]: /url . ``` -------------------------------- ### Shortcut Reference Link Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Explains the shortcut reference link syntax, where the link text is enclosed in brackets and matches a reference definition. ```markdown [foo] [foo]: /url "title" .

foo

``` -------------------------------- ### HTML Block with Div and Markdown Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows an HTML block starting with '
' which contains Markdown content. The block is terminated by a blank line, and the Markdown is then parsed. ```markdown
*Markdown*
.

Markdown

``` -------------------------------- ### Four-Space Rule Example (Markdown) Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Illustrates the four-space rule where subsequent paragraphs and sublists under a list item are indented by four spaces. This is contrasted with expected parsing. ```markdown - foo bar - baz ``` -------------------------------- ### Basic Reference Link Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a basic reference link where the label is enclosed in square brackets and followed by a reference definition. ```markdown [ref\[]]: /uri .

foo

``` -------------------------------- ### Unintended List Capture Example Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Demonstrates a case where a numeral followed by a period might be unintentionally parsed as a list item, even though it's part of a paragraph. ```markdown The number of windows in my house is 1. The number of doors is 6. ``` ```html

The number of windows in my house is

  1. The number of doors is 6.
``` -------------------------------- ### Markdown Empty Bullet List Item Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Example of an empty bullet list item within a list. An empty list item is represented by a marker followed by a newline. ```markdown - foo - - bar ``` ```html
  • foo
  • bar
``` -------------------------------- ### Generating and Collecting Values in Loops (Crystal) Source: https://github.com/crystal-lang/crystal/blob/master/src/compiler/crystal/tools/playground/views/_about.html Illustrates how to collect values generated within a loop into an array. All produced values are aggregated and can be inspected in a table. ```crystal def sample(n) res = [] of Float64 n.times do res << rand end res end sample 5 ``` -------------------------------- ### List item with indented content after marker Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt This example shows a list item where content following the marker has an indent that is not a code block. The interpretation depends on subsequent lines. ```markdown - foo bar ``` -------------------------------- ### Nested Unordered List Source: https://github.com/crystal-lang/crystal/blob/master/lib/markd/spec/fixtures/spec.txt Shows how to create nested unordered lists with varying indentation levels. ```markdown - a - b - c - d - e - f - g ```