Quarto Documentation

repository·main·Indexed 20 days ago

https://github.com/quarto-dev/quarto

An open-source scientific and technical publishing system built on Pandoc that uses Markdown for document authoring. This documentation covers the Quarto CLI, the quarto-vscode extension for .qmd files, and supporting libraries including json-validator, @quarto/mapped-string, and the unofficial-observablehq-compiler for Observable notebooks.

Tokens
88.3K
Snippets
319
Records
422
Agent score
67%

What's inside Quarto

  1. Overview of @quarto/external-observablehq-stdlib

    main

    The @quarto/external-observablehq-stdlib package is a fork of @observablehq/stdlib specifically modified to ensure compatibility with the RStudio IDE. It addresses two primary constraints of the RStudio environment:

    1. Require Compatibility: The build process (producing dist/stdlib.js) utilizes a fork of d3-require. This enables a require() function that operates correctly both within the Observable runtime and inside IPython's HTMLwidgets.
    2. JS Stdlib Compatibility: To avoid errors caused by the older version of the JavaScript standard library used in the RStudio IDE, this fork avoids calling Object.fromEntries.
  2. Overview of json-validator

    main
    json-validator is a library designed for validating JSON objects with a primary focus on generating high-quality, helpful error messages. It is optimized for validating objects and documents that have been serialized to disk, such as YAML files (after they have been loaded as JSON objects).
  3. Understand ViewExpressions and Imports

    main

    The parser handles special OJS syntax like viewof and imports with injections:

    ViewExpressions

    When a cell uses the viewof syntax (e.g., viewof x = ...), the cell.id becomes a ViewExpression. A ViewExpression contains an id which is the underlying Identifier.

    ImportDeclarations

    • ImportSpecifier: Each specifier in an import has a view boolean indicating if it specifies a view (e.g., import {viewof foo} ...).
    • Injections: If an import uses a with clause (e.g., import {chart} with {sales as data} ...), the declaration.injections property will contain an array of ImportSpecifier nodes. In these nodes, imported and local are reversed relative to standard imports: they represent the perspective of the module being imported.
  4. Structure slide shows using headings

    main

    Slide show structure is determined by heading levels and horizontal rules:

    • Slide Level: The highest heading level followed immediately by content. This can be overridden with the --slide-level option.
    • Horizontal Rules: A --- always starts a new slide.
    • Headings at Slide Level: Starts a new slide.
    • Headings below Slide Level: Create content within a slide (e.g., in beamer, these create block, exampleblock, or alertblock environments).
    • Headings above Slide Level: Create "title slides" to break the show into sections.
    • Title Page: Automatically generated from the document's title metadata block.

    Note for reveal.js: If slide level is 2, it produces a 2D layout (level-1 is horizontal, level-2 is vertical). For a 1D layout, use --slide-level=0.

  5. Pandoc Template Syntax: Delimiters and Comments

    main

    Pandoc templates use specific delimiters to identify variables and control structures.

    • Comments: Use $-- at the start of a line to create a comment. Everything from $-- to the end of the line is omitted from the output.
    • Delimiters: You can use either $ ... $ or ${ ... } to mark variables and control structures. The opening and closing delimiters must match within a single expression. Spaces or tabs following the opening or preceding the closing delimiter are ignored.
    • Literal Dollar Signs: To include a literal $ in your document, use $$.
    $-- This is a comment
    $foo$
    ${bar}
    $$ (literal dollar sign)
  6. Create implicit heading references

    main

    With the implicit_header_references extension enabled, you can link to a heading by using its exact text as a reference link, rather than providing an explicit #identifier.

    Example: If you have a heading # Heading identifiers in HTML, you can link to it using [Heading identifiers in HTML] or [Heading identifiers in HTML][].

    Precedence: Explicit link reference definitions (e.g., [foo]: bar) always take priority over implicit heading references.

    # Heading identifiers in HTML
    
    [Heading identifiers in HTML]
  7. How MappedString preserves source locations

    main

    The core abstraction of this library is the MappedString interface. It wraps a standard string and provides a map function that translates character indices from the current (transformed) string back to their original positions in the source string.

    This allows you to perform complex text processing pipelines while maintaining perfect source location fidelity. When you perform operations like mappedSubstring, mappedReplace, mappedTrim, or skipRegexp, the library ensures that the mapping information is preserved through each step. This is essential for accurate error reporting, as it allows you to report the exact line and column in the original source even after the text has been heavily manipulated.

  8. Use the `smart` typography extension

    main

    The smart extension interprets straight quotes as curly quotes, --- as em-dashes, -- as en-dashes, and ... as ellipses. It also inserts nonbreaking spaces after certain abbreviations (e.g., "Mr.").

    Supported Formats:

    • Input: markdown, commonmark, latex, mediawiki, org, rst, twiki, html
    • Output: markdown, latex, context, rst (enabled by default in markdown, latex, and context)

    Note on Writing Markdown: When writing Markdown, the smart extension has the reverse effect: what would have been curly quotes in the source will be output as straight quotes.

  9. Add captions to tables

    main

    A caption can be added to any of the four table types (simple, multiline, grid, or pipe).

    A caption is a paragraph that begins with the string Table: (case-insensitive, e.g., table:) or just a colon :. The caption can appear either before or after the table and will be stripped from the table structure itself.

    | Header | Col |
    |-------|-----|
    | Val   | 1   |
    
    : This is a caption.
  10. Use For Loops in Pandoc Templates

    main

    For loops iterate over arrays or maps.

    • Arrays: The loop body is evaluated for each value in the array, and the results are concatenated.
    • Maps: The loop body is executed once, with the variable set to the map.
    • Single values: If the variable is not an array or map, a single iteration occurs.
    • The it keyword: Inside a loop, you can use the special anaphoric keyword it to refer to the current item instead of the variable name.
    • Separators:
      • Use the $sep$ directive inside a loop to specify a separator between consecutive values.
      • Alternatively, use square brackets immediately after the variable or partial name (e.g., ${months[, ]}$) for a literal separator.
    # Using sep directive
    $for(foo)$$foo$$sep$, $endfor$
    
    # Using the 'it' keyword
    ${ for(foo.bar) }
      - ${ it.last }, ${ it.first }
    ${ endfor }
    
    # Using literal separator in brackets
    ${months[, ]}$