jxxcarlson/xmarkdown-compiler/2.2.5

NOTE: the latest version is 2.2.6

XMarkdown.Types

This module defines the core types used for configuring the Scripta compiler. The main type is CompilerParameters, which controls how XMarkdown source text is compiled and rendered.

Configuration

type alias CompilerParameters =
{ windowWidth : Int
, scale : Float
, docWidth : Int
, editCount : Int
, selectedId : String
, selectedSlug : Maybe String
, theme : Theme
, backgroundColor : String
, highlightColor : String
, paddingAboveHeadings : Float
, interBlockSpacing : Float
, lineHeight : Float
, fontSize : Int
, numberToLevel : Int
, data : Dict String String
}
defaultCompilerParameters : CompilerParameters

Key Parameters

  • docWidth: Width of the rendered document in pixels
  • editCount: Increment this after each edit for live editing contexts (use 0 for static documents)
  • selectedId: ID of the currently selected block for highlighting
  • theme: Visual theme (Light or Dark)

Usage

For simple use cases, start with defaultCompilerParameters and override the fields you need:

{ defaultCompilerParameters
    | docWidth = 600
    , editCount = model.editCount
}
type alias CompilerOutput =
{ body : List (Html MarkupMsg)
, banner : Maybe (Html MarkupMsg)
, toc : List (Html MarkupMsg)
, title : Html MarkupMsg
, interBlockSpacing : Float
}
= MHStandard
| MHAsCheatSheet

How to handle a MarkupMsg.

= SendMeta
{ begin : Int
, end : Int
, index : Int
, id : String
}
| SendLineNumber
{ begin : Int
, end : Int
}
| SelectId String
| HighlightId String
| JumpToTop
| MMNoOp

Messages from rendered markup for synchronization with the editor. Used for rendered-to-source syncing (e.g., clicking rendered text highlights source).

type alias SyncHighlight =
{ mode : String
, start : Int
, end : Int
, tick : Int
}

A source span to highlight in the editor.

  • mode = "chars": start/end are document character offsets (end exclusive). Used for inline (phrase) clicks.
  • mode = "lines": start/end are 1-indexed source lines, both inclusive. Used for block clicks.
  • tick is a monotonic counter so repeat clicks on the same span re-trigger the editor.
type Theme
= Light
| Dark

Represents the available themes.