Quotation Marks and Apostrophes
This page describes how to insert curved quotation marks and apostrophes using the AsciiDoc syntax. It covers the shorthand syntax, the limitations of that syntax, and when it’s necessary to input these characters directly.
Single and double quotation mark syntax
AsciiDoc does not assign special meaning to single or double quotation marks when used as constrained formatting pairs (e.g., around a word or phrase). In this case, the ' and " characters are taken to be straight quotation marks (also known as dumb, vertical, or typewriter quotation marks). When an AsciiDoc processor encounters straight quotation marks in this context, it outputs them as entered.
In Ruby, '\n' represents a backslash followed by the letter n.
Single quotes prevent escape sequences from being interpreted.
In contrast, "\n" represents a newline.
The result of Example 1 is rendered below.
In Ruby, '\n' represents a backslash followed by the letter n. Single quotes prevent escape sequences from being interpreted. In contrast, "\n" represents a newline.
You can instruct the AsciiDoc processor to output curved quotation marks (also known as smart, curly, or typographic quotation marks) by adding a repurposed constrained monospace formatting pair (i.e., a pair of backticks, `
) directly inside the pair of quotation marks.
The combination of these two formatting pairs forms a new constrained formatting pair for producing single and double curved quotation marks.
"`What kind of charm?`" Lazarus asked.
"`An odoriferous one or a mineral one?`" (1)
Kizmet shrugged.
"`The note from Olaf's desk says '`wormwood and licorice,`'
but these could be normal groceries for werewolves.`" (2)
1 | To output double curved quotes, enclose a word or phrase in a pair of double quotes (" ) and a pair of backticks (` ). |
2 | To output single curved quotes, enclose a word or phrase in a pair of single quotes (' ) and a pair of backticks (` ).
In this example, the phrase wormwood and licorice should be enclosed in curved single quotes when the document is rendered. |
The result of Example 2 is rendered below.
“What kind of charm?” Lazarus asked. “An odoriferous one or a mineral one?”
Kizmet shrugged. “The note from Olaf’s desk says ‘wormwood and licorice,’ but these could be normal groceries for werewolves.”
There’s no unconstrained equivalent for producing double and single curved quotation marks. In that case, it’s necessary to input the curved quotation marks directly using the characters ‘, ’, “, and ”.
Apostrophe syntax
When entered using the ' key, the AsciiDoc processor translates a straight apostrophe directly preceded and followed by a word character, such as in contractions and possessive singular forms, as a curved apostrophe. This partial support for smart typography without any special syntax is a legacy inherited from AsciiDoc.py.
Olaf's desk was a mess.
The result of Example 3 is rendered below.
Olaf’s desk was a mess.
If you don’t want a straight apostrophe that’s bounded by two word characters to be rendered as a curved apostrophe, escape it by preceding it with a backslash (\
).
Olaf\'s desk ...
The result of Example 4 is rendered below.
Olaf's desk …
An apostrophe directly bounded by two word characters is processed during the replacements substitution phase, not the inline formatting (quotes) phase. To learn about additional ways to prevent the replacements substitution, see Escape and Prevent Substitutions and Inline Passthroughs.
An apostrophe directly followed by a space or punctuation, such as the possessive plural form, is not curved by default.
To render a curved apostrophe when not bounded by two word characters, mark it as you would the second half of single curved quote (i.e., `'
).
This syntax for a curved apostrophe is effectively unconstrained.
Olaf had been with the company since the `'00s.
His desk overflowed with heaps of paper, apple cores and squeaky toys.
We couldn't find Olaf's keyboard.
The state of his desk was replicated, in triplicate, across all of
the werewolves`' desks.
In the rendered output for Example 5 below, notice that the plural possessive apostrophe, seen trailing werewolves, is curved, as is the omission apostrophe before 00s.
Olaf had been with the company since the ’00s. His desk overflowed with heaps of paper, apple cores and squeaky toys. We couldn’t find Olaf’s keyboard. The state of his desk was replicated, in triplicate, across all of the werewolves’ desks.
Possessive monospace
In order to make a possessive, monospaced phrase, you need to switch to unconstrained formatting followed by an explicit typographic apostrophe.
``npm```'s job is to manage the dependencies for your application.
A ``std::vector```'s size is the number of items it contains.
The result of Example 6 is rendered below.
npm
’s job is to manage the dependencies for your application.
A std::vector
’s size is the number of items it contains.
You’ll need to use a similar syntax when the last (or only) word in the monospace phrase ends in an “s” (i.e., the plural possessive form).
This ``class```' static methods make it easy to operate on files and directories.
The result of Example 7 is below. The word class is rendered in monospace with a curved apostrophe at the end of it.
This class
’ static methods make it easy to operate on files and directories.
You can get the same result by inserting a typographic apostrophe immediately following a constrained formatting pair. In this case, you’re able to leverage the fact that a typographic apostrophe is a punctuation character to avoid the need to resort to unconstrained formatting.
The `class`’ static methods make it easy to operate on files and directories.
As you can see, it’s often simpler to input the curved apostrophe directly using the character ’. The shorthand syntax AsciiDoc provides is only meant as a convenience.