# Formatting your text with Markdown

Mayhap formats text with Markdown: headings, bold, italic, code, links, lists, quotes and footnotes. The marks are hidden while you write, so the page reads formatted, and one key shows them whenever you'd like to see or edit them as typed.

## Showing the Markdown marks

A Mayhap document is Markdown underneath. A window starts with the marks hidden: headings show by their size and weight, each list item has its bullet or number, a quote has a bar beside it and a link shows only its text. While the marks are hidden, the caret moves over what you see, and typing goes on in the formatting on its left.

If you would like to see the marks, press `Ctrl+Alt+M / ⌥⌘M` or click the ¶ in the top bar, which is lit while they show. The marks appear muted, as typed, on the page and in Aside. Press the key again to hide them. Switching changes no text, and it applies to that window only.

![A page with Markdown's marks shown: a # before the heading, asterisks around Sunday and kettle, and a > before the quote](https://mayhap.app/build/assets/md-marks-Dp-hj6ey.webp)

## Formatting as you type

Markdown's marks format the moment they're complete. At the start of a line, type # and a space for a heading (## or ### for smaller ones), a hyphen and a space for a list, 1. and a space for a numbered list, or > and a space for a quote. Around a word, two asterisks on each side make it bold, an underscore on each side italic, and a backtick on each side code.

If you meant the characters themselves, press `Ctrl+Z / ⌘Z` right away. It gives back exactly what you typed, as plain characters: for example, # and a space followed by *Notes* and one undo leaves *# Notes* as text.

## Bold, italic and code

To make words bold, select them and press `Ctrl+B / ⌘B`. Likewise, `Ctrl+I / ⌘I` makes them italic and `Ctrl+Shift+E / ⇧⌘E` inline code. On text that already has the look, the same key makes it plain again. With the caret inside a word, the key works on the whole word.

With the caret between words, the key is for what you type next. For example, press `Ctrl+I / ⌘I` and type *still*, and the word comes out italic. At the end of bold text, `Ctrl+B / ⌘B` steps out of the bold, so what follows is plain.

## Headings, quotes and lists

The text styles work on every line the selection touches, or on the caret's line:

- `Ctrl+Alt+1 / ⌥⌘1`, `Ctrl+Alt+2 / ⌥⌘2` and `Ctrl+Alt+3 / ⌥⌘3` make a heading of the first, second or third level.
- `Ctrl+Alt+0 / ⌥⌘0` makes it regular text again, taking away its heading, quote or list.
- `Ctrl+Shift+Q / ⇧⌘'` puts the lines in a quote.
- `Ctrl+Shift+L / ⇧⌘L` makes a list, and `Ctrl+Shift+N / ⇧⌘N` a numbered list.

On lines that are already all in a quote or a list, the same key takes them out of it.

## Writing in a list

Inside a list, `Return` starts the next item, numbered on from the one before. `Return` on an empty item leaves the list: a nested item steps out a level, and one at the top becomes a line of text. `Tab` nests the item under the one before it, and `Shift+Tab` takes it out a level.

`Backspace` at the start of an item's text takes it out a level too. At the top level, it takes the bullet or number away.

## Links

To make a link, select the words and press `Ctrl+K / ⌘K`. A field opens over them, *Enter link address*; type or paste the address and press `Return`. If the clipboard already holds an address, the field starts with it. Mayhap adds what an address obviously lacks, so *harbour.org* becomes *https://harbour.org*.

With nothing selected, `Ctrl+Shift+K / ⇧⌘K` opens the same field and puts a new link at the caret, the address as its text. Click a link's text to open its field again: there you may change the address and press `Return` (*Set link*), or choose *Open link*, *Copy link* or *Remove link*, which keeps the text. To open a link in your browser straight away, hold `Ctrl / ⌘` and click it.

## Footnotes

Footnotes are Markdown's own: a reference in the text and its note at the end of the page. To add one, put the caret where the reference goes, or select the words it follows. Then right-click the text and choose *Format › Add a footnote*, or choose *Add a footnote* in the command palette. A small raised number appears, with a card under it for the note's text; press `Esc` or `Return` when you're done.

Mayhap numbers the notes in the order of their references and shows them at the end of the page, smaller, under a short rule. Click a number to open its note again. To delete a footnote, delete its number: `Backspace` after it removes the reference and, if nothing else refers to the note, the note as well. `Ctrl+Z / ⌘Z` brings both back.

*Add a footnote* has no key by default. You may give it one in *Settings › Shortcuts*.

## Smart punctuation

As you type, Mayhap turns straight quotes, double hyphens and three dots into their typeset forms:

- " gives “ and ”, or „ and “ in a line of Cyrillic text.
- ' gives ‘ and ’, and an apostrophe inside a word is ’.
- Two hyphens give an em dash, —. At the start of a line, two hyphens and a space give the dash that opens dialogue.
- Three dots give an ellipsis, ….

If you wanted the plain character, press `Ctrl+Z / ⌘Z` right after: it gives back what you typed. Code and link addresses are always left as typed. If you would rather type every character as it is, turn off *Smart punctuation* in *Settings › Writing*.

## The selection bar

When you select text, a small bar comes over it with the formatting at hand: *Text style* (regular text or a heading), *Bold*, *Italic*, *Link…*, *Inline code*, *Quote* and *List*. After them come *Alternatives*, *AI alternatives*, *Mark as maybe* and *Set it aside*. In Aside, the bar holds the formatting and *Back into the page*.

![The selection bar over a few selected words, with the formatting buttons first and Mayhap's own actions after them](https://mayhap.app/build/assets/sel-bar-DSRxxFpz.webp)

A button whose look the selection already has is lit, and resting the mouse on a button names it and its key. The bar goes as soon as you type, press `Esc` or click elsewhere. If you'd rather not see it, turn off *Show the bar over selected text* in *Settings › Writing*; `Ctrl+K / ⌘K` still opens the link field.

## The Format menu

Right-click text on the page and choose *Format* for every formatting command in one place: *Bold*, *Italic*, *Link…*, *Regular text*, *Heading 1* to *Heading 3*, *Inline code*, *Quote*, *List*, *Numbered list* and *Add a footnote*. Each row shows its key.

## Keys

| Command | Linux, Windows | macOS |
| --- | --- | --- |
| Markdown marks | Ctrl+Alt+M | ⌥⌘M |
| Bold | Ctrl+B | ⌘B |
| Italic | Ctrl+I | ⌘I |
| Inline code | Ctrl+Shift+E | ⇧⌘E |
| Regular text | Ctrl+Alt+0 | ⌥⌘0 |
| Heading 1 / 2 / 3 | Ctrl+Alt+1 / 2 / 3 | ⌥⌘1 / 2 / 3 |
| Quote | Ctrl+Shift+Q | ⇧⌘' |
| List | Ctrl+Shift+L | ⇧⌘L |
| Numbered list | Ctrl+Shift+N | ⇧⌘N |
| Link… on selected text | Ctrl+K | ⌘K |
| Link… | Ctrl+Shift+K | ⇧⌘K |
| Nest a list item / take it out | Tab / Shift+Tab | Tab / Shift+Tab |
