size: 3 KiB
| 1 | Open quotes are matched with closed quotes. |
| 2 | The same method is used for matching openers and closers |
| 3 | as is used in emphasis parsing: |
| 4 | |
| 5 | ``` |
| 6 | "Hello," said the spider. |
| 7 | "'Shelob' is my name." |
| 8 | . |
| 9 | <p>“Hello,” said the spider. |
| 10 | “‘Shelob’ is my name.”</p> |
| 11 | ``` |
| 12 | |
| 13 | ``` |
| 14 | 'A', 'B', and 'C' are letters. |
| 15 | . |
| 16 | <p>‘A’, ‘B’, and ‘C’ are letters.</p> |
| 17 | ``` |
| 18 | |
| 19 | ``` |
| 20 | 'Oak,' 'elm,' and 'beech' are names of trees. |
| 21 | So is 'pine.' |
| 22 | . |
| 23 | <p>‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. |
| 24 | So is ‘pine.’</p> |
| 25 | ``` |
| 26 | |
| 27 | ``` |
| 28 | 'He said, "I want to go."' |
| 29 | . |
| 30 | <p>‘He said, “I want to go.”’</p> |
| 31 | ``` |
| 32 | |
| 33 | A single quote that isn't an open quote matched |
| 34 | with a close quote will be treated as an |
| 35 | apostrophe: |
| 36 | |
| 37 | ``` |
| 38 | Were you alive in the '70s? |
| 39 | . |
| 40 | <p>Were you alive in the ’70s?</p> |
| 41 | ``` |
| 42 | |
| 43 | ``` |
| 44 | Here is some quoted '`code`' and a "[quoted link](url)". |
| 45 | . |
| 46 | <p>Here is some quoted ‘<code>code</code>’ and a “<a href="url">quoted link</a>”.</p> |
| 47 | ``` |
| 48 | |
| 49 | Here the first `'` is treated as an apostrophe, not |
| 50 | an open quote, because the final single quote is matched |
| 51 | by the single quote before `jolly`: |
| 52 | |
| 53 | ``` |
| 54 | 'tis the season to be 'jolly' |
| 55 | . |
| 56 | <p>’tis the season to be ‘jolly’</p> |
| 57 | ``` |
| 58 | |
| 59 | Multiple apostrophes should not be marked as open/closing quotes. |
| 60 | |
| 61 | ``` |
| 62 | 'We'll use Jane's boat and John's truck,' Jenna said. |
| 63 | . |
| 64 | <p>‘We’ll use Jane’s boat and John’s truck,’ Jenna said.</p> |
| 65 | ``` |
| 66 | |
| 67 | An unmatched double quote will be interpreted as a |
| 68 | left double quote, to facilitate this style: |
| 69 | |
| 70 | ``` |
| 71 | "A paragraph with no closing quote. |
| 72 | |
| 73 | "Second paragraph by same speaker, in fiction." |
| 74 | . |
| 75 | <p>“A paragraph with no closing quote.</p> |
| 76 | <p>“Second paragraph by same speaker, in fiction.”</p> |
| 77 | ``` |
| 78 | |
| 79 | A quote following a `]` or `)` character cannot |
| 80 | be an open quote: |
| 81 | |
| 82 | ``` |
| 83 | [a]'s b' |
| 84 | . |
| 85 | <p>[a]’s b’</p> |
| 86 | ``` |
| 87 | |
| 88 | Quotes that are escaped come out as literal straight |
| 89 | quotes: |
| 90 | |
| 91 | ``` |
| 92 | \"This is not smart.\" |
| 93 | This isn\'t either. |
| 94 | 5\'8\" |
| 95 | . |
| 96 | <p>"This is not smart." |
| 97 | This isn't either. |
| 98 | 5'8"</p> |
| 99 | ``` |
| 100 | |
| 101 | Doubled quotes are treated as nested: |
| 102 | |
| 103 | ``` |
| 104 | ''hi'' |
| 105 | . |
| 106 | <p>‘‘hi’’</p> |
| 107 | ``` |
| 108 | |
| 109 | Heuristics for determining openers and closers can |
| 110 | be overridden using `{` and `}`: |
| 111 | |
| 112 | ``` |
| 113 | {''}hi{''} |
| 114 | . |
| 115 | <p>‘’hi‘’</p> |
| 116 | ``` |
| 117 | |
| 118 | Two hyphens form an en-dash, three an em-dash. |
| 119 | |
| 120 | ``` |
| 121 | Some dashes: em---em |
| 122 | en--en |
| 123 | em --- em |
| 124 | en -- en |
| 125 | 2--3 |
| 126 | . |
| 127 | <p>Some dashes: em—em |
| 128 | en–en |
| 129 | em — em |
| 130 | en – en |
| 131 | 2–3</p> |
| 132 | ``` |
| 133 | |
| 134 | A sequence of more than three hyphens is |
| 135 | parsed as a sequence of em and/or en dashes, |
| 136 | with no hyphens. If possible, a homogeneous |
| 137 | sequence of dashes is used (so, 10 hyphens |
| 138 | = 5 en dashes, and 9 hyphens = 3 em dashes). |
| 139 | When a heterogeneous sequence must be used, |
| 140 | the em dashes come first, followed by the en |
| 141 | dashes, and as few en dashes as possible are |
| 142 | used (so, 7 hyphens = 2 em dashes an 1 en |
| 143 | dash). |
| 144 | |
| 145 | ``` |
| 146 | one- |
| 147 | two-- |
| 148 | three--- |
| 149 | four---- |
| 150 | five----- |
| 151 | six------ |
| 152 | seven------- |
| 153 | eight-------- |
| 154 | nine--------- |
| 155 | thirteen-------------. |
| 156 | . |
| 157 | <p>one- |
| 158 | two– |
| 159 | three— |
| 160 | four–– |
| 161 | five—– |
| 162 | six—— |
| 163 | seven—–– |
| 164 | eight–––– |
| 165 | nine——— |
| 166 | thirteen———––.</p> |
| 167 | ``` |
| 168 | |
| 169 | Hyphens can be escaped: |
| 170 | |
| 171 | ``` |
| 172 | Escaped hyphens: \-- \-\-\-. |
| 173 | . |
| 174 | <p>Escaped hyphens: -- ---.</p> |
| 175 | ``` |
| 176 | |
| 177 | Three periods form an ellipsis: |
| 178 | |
| 179 | ``` |
| 180 | Ellipses...and...and.... |
| 181 | . |
| 182 | <p>Ellipses…and…and….</p> |
| 183 | ``` |
| 184 | |
| 185 | Periods can be escaped if ellipsis-formation |
| 186 | is not wanted: |
| 187 | |
| 188 | ``` |
| 189 | No ellipses\.\.\. |
| 190 | . |
| 191 | <p>No ellipses...</p> |
| 192 | ``` |