Skip to main content

Reference Definitions

Reference-style links and images let you define URLs separately from the inline reference. Enable with referenceDefinition: true:

new Editor({
el: root,
referenceDefinition: true,
});
Visit [the ToastWrite repo][repo] for source code.

[repo]: https://github.com/toastwrite/editor "ToastWrite Editor"

Reference images

![Logo][logo]

[logo]: https://example.com/logo.png "ToastWrite logo"

Shortcut references

When the reference label matches the link text (case-insensitive, collapsed whitespace):

[ToastWrite][]

[ToastWrite]: https://github.com/toastwrite/editor

Implicit heading references

CommonMark also supports implicit references from headings when the link text matches a heading title. This follows standard CommonMark reference link rules.

Definition syntax

[label]: url "optional title"
[label]: url 'optional title'
[label]: url (optional title)
[label]: <url> "optional title"

Definitions can appear anywhere in the document. Conventionally they are grouped at the end:

# My Document

See [docs][docs] for more.

[docs]: https://toastwrite.github.io/docs/ "ToastWrite Docs"

Tips

  • Reference definitions are not visible in the rendered preview body.
  • Inline links ([text](url)) work without enabling this option; reference definitions add support for the [text][ref] / [ref]: url form.