Version: dev

This is the documentation for the development version. For the latest release, see v0.13.0.

parse_markdown

Stable function · Other

Tier: stable · Kind: function · Topic: Other

JuliaTypeScriptPythonRustGo
parse_markdownparseMarkdownparse_markdownparse_markdownParseMarkdown

Julia

parse_markdown(text::AbstractString)
parse_markdown(text::AbstractString) -> OrderedDict{String, Any}

Read a Markdown ESM document (Lean Source.Md.parseMd). The result is a decoded JSON document in canonical form, as canonicalize_document returns it with every object’s keys sorted. A byte-order mark is dropped, and CRLF line endings are read as LF when the first line ends in CRLF.

Throws a ParseError whose code is "removed_op" when the document’s math writes an operator removed from the format (esm-spec §4.2) in the call or the escape form, and "parse_error" for any other text that is not a Markdown ESM document, and for one past a bound of the reader: more than 128 constructs (brackets, fractions, signs, flow collections, YAML levels, …) open at once, a value nested more than 127 arrays and objects deep, or a number beyond the binary64 range, and for a text that is not valid UTF-8. A name nothing declares is not a parse error: an undeclared reference is the validator’s finding.

Source

TypeScript

function parseMarkdown(text: string, options?: ParseDocumentOptions): Record<string, unknown>

Read a Markdown ESM document (Source.Md.parseMd). The result is in canonical form.

Throws

  • EsmDiagnosticError — with code removed_op when the document’s math uses an operator removed from the format (esm-spec §4.2), and parse_error for any other text that is not a Markdown ESM document, and for one past a bound of the reader (limits.ts): nested too deeply, or holding a number beyond the binary64 range.

Source

Python

parse_markdown(text: str) -> dict

Read a Markdown ESM document (Source.Md.parseMd). The result is the decoded JSON document, in canonical form (CONFORMANCE §5.5.3.1: an integral number in Int64 is an int, any other a float).

Raises ParseError whose code is removed_op when the text uses an operator removed from the format (spec §4.2), and parse_error for any other text that is not a Markdown ESM document.

Source

Rust

pub fn parse_markdown(text: &str) -> Result<Value, DiagnosticError>

Read a Markdown ESM document (Source.Md.parseMd). The result is in canonical form.

Errors

A DiagnosticError with code removed_op when the document’s math uses an operator removed from the format (spec §4.2), and parse_error for any other text that is not a Markdown ESM document, and for one past a bound of the Rust reader (limits): nested too deeply, or holding a number beyond the binary64 range.

Source · Rust docs

Go

func ParseMarkdown(text string) (any, error)

ParseMarkdown reads a Markdown ESM document (Lean Source.Md.parseMd). The result is in canonical form, the representation CanonicalizeDocument returns (map

\[string\]

any, []any, int64 for an integer, float64 for a decimal).

A text that is not a Markdown ESM document returns a *DocumentFormatError with code removed_op when the document’s math uses an operator removed from the format (esm-spec §4.2), and parse_error for any other text, and for one past a bound of the reader: nested too deeply (more than 128 reader constructs open at once, or more than 127 levels of arrays and objects), or holding a number beyond the binary64 range.

Source · Go docs