package cmarkit
Install
Dune Dependency
Authors
Maintainers
Sources
sha512=42fa920e84f2b7d45f5cf1251d3308daa7becff2590f7ce84186cb22335415b02cc9bc44179095bf0d37624fb5a0e66d1c96fcc1b12f1106f567247a71c79039
doc/cmarkit/Cmarkit/Doc/index.html
Module Cmarkit.Doc
Documents (and parser).
Documents
val nl : t -> Layout.string
nl d
is the first newline found in the text during parsing or "\n"
if there was none.
val defs : t -> Label.defs
defs d
are the label definitions resulting from parsing d
. The result depends on the label definitions found in the source and the defs
and resolver
values specified on Doc.of_string
.
val make : ?nl:Layout.string -> ?defs:Label.defs -> Block.t -> t
make ~nl ~defs b
is a document for block b
with newline nl
(defaults to "\n"
), label definition defs
(defaults to Label.Map.empty
).
val empty : t
empty
is an empty document.
Parsing
val of_string :
?defs:Label.defs ->
?resolver:Label.resolver ->
?nested_links:bool ->
?heading_auto_ids:bool ->
?layout:bool ->
?locs:bool ->
?file:Textloc.fpath ->
?strict:bool ->
string ->
t
of_string md
is a document from the UTF-8 encoded CommonMark document md
.
- If
strict
istrue
(default) the CommonMark specification is followed. Iffalse
these extensions are enabled. file
is the file path from whichs
is assumed to have been read (defaults toTextloc.file_none
), used in theTextloc.t
values ifflocs
istrue
.- If
locs
istrue
locations are stored in nodes of the abstract syntax tree in individually identifiedMeta.t
values. Iffalse
(default) node meta values are allMeta.none
whose text location isTextloc.none
. - If
layout
isfalse
(default) layout values cannot be relied upon and do not in general represent source layout, some fields may be normalized. TheBlock.Blank_line
,Block.Link_reference_definition
,Block.Ext_footnote_definition
, layout block values are present in the result regardless of this parameter. - If
heading_auto_ids
istrue
(defaults tofalse
) then`Auto
heading identifiers are generated during parsing from the header text withInline.id
(at that point noext
argument is needed) and made accessible inBlock.Heading.id
. Note that the identifiers may not be unique, we leave it to the backends to handle this problem. - If
nested_links
istrue
(defaults tofalse
) there is no restriction on having links in link text, which is forbidden by CommonMark and HTML. This can be useful for embedding DSLs in link labels or destinations. Note that image links already allow link nesting as per CommonMark specification. - If
resolver
is provided this is used resolve label definitions and references. See here for details. Defaults toLabel.default_resolver
. - If
defs
adds these label definitions to the document (defaults toLabel.Map.empty
). Think of them as being prepended tomd
. Ifresolver
isLabel.default_resolver
, these take over the same labels defined inmd
(first definition takes over in CommonMark).
UTF-8 decoding errors and U+0000 are turned into Uchar.rep
characters. Inlines of the result should be Inline.normalize
d. Blocks of the result should be Block.normalize
d.
Note. For simple renders parsing with layout:false
and locs:false
is generally faster; having these to true
allocates quite a bit.
Versions
unicode_version
is the Unicode version known to of_string
.
commonmark_version
is the CommonMark version known to of_string
.