Finish initial implementation of smart punctuation

This commit is contained in:
Marcus Klaas de Vries 2020-08-27 18:47:00 +02:00
parent 96d691b925
commit 1d17fd0b1b
14 changed files with 815 additions and 881 deletions

View file

@ -152,21 +152,18 @@ impl<'a> Iterator for Spec<'a> {
fn next(&mut self) -> Option<TestCase> {
let spec = self.spec;
let prefix = "```````````````````````````````` example";
let (i_start, smart_punct) = self
.spec
.find("```````````````````````````````` example")
.and_then(|pos| {
let prefix_len = "```````````````````````````````` example".len();
let suffix = "_disable_smartpunct\n";
if spec[(pos + prefix_len)..].starts_with(suffix) {
Some((pos + prefix_len + suffix.len(), false))
} else if spec[(pos + prefix_len)..].starts_with('\n') {
Some((pos + prefix_len + 1, true))
} else {
None
}
})?;
let (i_start, smart_punct) = self.spec.find(prefix).and_then(|pos| {
let suffix = "_smartpunct\n";
if spec[(pos + prefix.len())..].starts_with(suffix) {
Some((pos + prefix.len() + suffix.len(), true))
} else if spec[(pos + prefix.len())..].starts_with('\n') {
Some((pos + prefix.len() + 1, false))
} else {
None
}
})?;
let i_end = self.spec[i_start..]
.find("\n.\n")

View file

@ -213,7 +213,7 @@ ISSUE #315
ISSUE #294
```````````````````````````````` example_disable_smartpunct
```````````````````````````````` example
1...
1.2.3.
@ -267,7 +267,7 @@ YOLO
ISSUE #293
```````````````````````````````` example_disable_smartpunct
```````````````````````````````` example
lorem ipsum
A | B
---|---

View file

@ -210,8 +210,9 @@ enum ItemBody {
// repeats, can_open, can_close
MaybeEmphasis(usize, bool, bool),
MaybeSmartQuote(SmartQuoteKind), // before_digit
MaybeCode(usize, bool), // number of backticks, preceeded by backslash
// quote byte, can_open, can_close
MaybeSmartQuote(u8, bool, bool),
MaybeCode(usize, bool), // number of backticks, preceeded by backslash
MaybeHtml,
MaybeLinkOpen,
MaybeLinkClose,
@ -280,64 +281,6 @@ enum TableParseMode {
Disabled,
}
#[derive(Debug, Copy, Clone, PartialEq)]
enum SmartQuoteKind {
Open,
Close,
Midword,
}
/// Determines what kind a smart quote should open at this point
fn quote_kind(
character: u8,
s: &str,
prefix: &str,
suffix: &str,
ix: usize,
) -> Option<SmartQuoteKind> {
let not_italic_ish = |c: &char| *c != '*' && *c != '~' && *c != '_' && *c != '\'' && *c != '"';
// Beginning and end of line == whitespace.
let next_char = suffix.chars().filter(not_italic_ish).nth(0).unwrap_or(' ');
let prev_char = prefix
.chars()
.rev()
.filter(not_italic_ish)
.nth(0)
.unwrap_or(' ');
let next_white = next_char.is_whitespace();
let prev_white = prev_char.is_whitespace();
// i.e. braces and the like
let not_term_punc = |c: char| is_punctuation(c) && c != '.' && c != ',';
let wordy = |c: char| !is_punctuation(c) && !c.is_whitespace() && !c.is_control();
if prev_white && next_white {
None
} else if prev_white && next_char.is_numeric() && character == b'\'' {
// '09 -- force a close quote
Some(SmartQuoteKind::Midword)
} else if !prev_white && next_white {
Some(SmartQuoteKind::Close)
} else if prev_white && !next_white {
Some(SmartQuoteKind::Open)
} else if next_white && (prev_char == '.' || prev_char == ',' || prev_char == '!') {
Some(SmartQuoteKind::Close)
} else if is_punctuation(prev_char) && not_term_punc(next_char) {
Some(SmartQuoteKind::Close)
} else if not_term_punc(prev_char) && is_punctuation(next_char) {
Some(SmartQuoteKind::Open)
} else if wordy(prev_char) && wordy(next_char) && character == b'\'' {
Some(SmartQuoteKind::Midword)
} else if is_punctuation(prev_char) && wordy(next_char) {
Some(SmartQuoteKind::Open)
} else if wordy(prev_char) && is_punctuation(next_char) {
Some(SmartQuoteKind::Close)
} else {
None
}
}
/// State for the first parsing pass.
///
/// The first pass resolves all block structure, generating an AST. Within a block, items
@ -991,20 +934,17 @@ impl<'a, 'b> FirstPass<'a, 'b> {
}
}
c @ b'\'' | c @ b'"' => {
let string_prefix = &self.text[..ix];
let string_suffix = &self.text[ix..];
let kind = quote_kind(c, &self.text, string_prefix, string_suffix, ix);
//let is_single = c == b'\'';
let can_open = delim_run_can_open(self.text, string_suffix, 1, ix);
let can_close = delim_run_can_close(self.text, string_suffix, 1, ix);
if let Some(kind) = kind {
self.tree.append_text(begin_text, ix);
self.tree.append(Item {
start: ix,
end: ix + 1,
body: ItemBody::MaybeSmartQuote(kind),
});
begin_text = ix + 1;
}
self.tree.append_text(begin_text, ix);
self.tree.append(Item {
start: ix,
end: ix + 1,
body: ItemBody::MaybeSmartQuote(c, can_open, can_close),
});
begin_text = ix + 1;
LoopInstruction::ContinueAndSkip(0)
}
@ -1599,7 +1539,8 @@ fn delim_run_can_open(s: &str, suffix: &str, run_len: usize, ix: usize) -> bool
let prev_char = s[..ix].chars().last().unwrap();
prev_char.is_whitespace() || is_punctuation(prev_char)
prev_char.is_whitespace()
|| is_punctuation(prev_char) && (delim != '\'' || ![']', ')'].contains(&prev_char))
}
/// Determines whether the delimiter run starting at given index is
@ -2450,6 +2391,9 @@ impl<'a> Parser<'a> {
let mut prev_ix: TreeIndex;
let mut cur = self.tree.cur();
let mut single_quote_open: Option<TreeIndex> = None;
let mut double_quote_open: bool = false;
while let Some(mut cur_ix) = cur {
match self.tree[cur_ix].item.body {
ItemBody::MaybeEmphasis(mut count, can_open, can_close) => {
@ -2527,41 +2471,28 @@ impl<'a> Parser<'a> {
cur = self.tree[prev_ix].next;
}
}
ItemBody::MaybeSmartQuote(kind) => {
let c = self.text.as_bytes()[self.tree[cur_ix].item.start];
let ty = |open: bool| match (open, c) {
(true, b'\'') =>
/*ItemBody::SmartQuoteSingleOpen,*/
{
ItemBody::Text
ItemBody::MaybeSmartQuote(c, can_open, can_close) => {
self.tree[cur_ix].item.body = match c {
b'\'' => {
if let (Some(open_ix), true) = (single_quote_open, can_close) {
self.tree[open_ix].item.body = ItemBody::SynthesizeText(self.allocs.allocate_cow(''.into()));
single_quote_open = None;
} else if can_open {
single_quote_open = Some(cur_ix);
}
ItemBody::SynthesizeText(self.allocs.allocate_cow(''.into()))
}
(true, b'"') =>
/*ItemBody::SmartQuoteDoubleOpen,*/
{
ItemBody::Text
_ /* double quote */ => {
if can_close && double_quote_open {
double_quote_open = false;
ItemBody::SynthesizeText(self.allocs.allocate_cow('”'.into()))
} else {
if can_open && !double_quote_open {
double_quote_open = true;
}
ItemBody::SynthesizeText(self.allocs.allocate_cow('“'.into()))
}
}
(false, b'\'') =>
/*ItemBody::SmartQuoteSingleClose,*/
{
ItemBody::Text
}
(false, b'"') =>
/*ItemBody::SmartQuoteDoubleClose,*/
{
ItemBody::Text
}
_ => unreachable!(
"only single and double quotes should be in MaybeSmartQuote"
),
};
self.tree[cur_ix].item.body = match kind {
SmartQuoteKind::Midword =>
/*ItemBody::SmartMidwordInvertedComma,*/
{
ItemBody::Text
}
SmartQuoteKind::Open => ty(true),
SmartQuoteKind::Close => ty(false),
};
prev = cur;
cur = self.tree[cur_ix].next;

View file

@ -186,7 +186,13 @@ mod simd_test {
use crate::Options;
fn check_expected_indices(bytes: &[u8], expected: &[usize], skip: usize) {
let lut = crate::parse::create_lut(&Options::empty());
let mut opts = Options::empty();
opts.insert(Options::ENABLE_TABLES);
opts.insert(Options::ENABLE_FOOTNOTES);
opts.insert(Options::ENABLE_STRIKETHROUGH);
opts.insert(Options::ENABLE_TASKLISTS);
let lut = crate::parse::create_lut(&opts);
let mut indices = vec![];
iterate_special_bytes::<_, i32>(&lut, bytes, 0, |ix, _byte_ty| {

View file

@ -15,7 +15,7 @@ fn footnotes_test_1() {
</div>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -34,7 +34,7 @@ Yes it goes on and on my friends.<sup class="footnote-reference"><a href="#lambc
</blockquote>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -56,7 +56,7 @@ fn footnotes_test_3() {
</div>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -71,7 +71,7 @@ I had largely given over my inquiries into what Professor Angell called the "Cth
<p>I had largely given over my inquiries into what Professor Angell called the &quot;Cthulhu Cult&quot;, and was visiting a learned friend in Paterson, New Jersey; the curator of a local museum and a mineralogist of note. Examining one day the reserve specimens roughly set on the storage shelves in a rear room of the museum, my eye was caught by an odd picture in one of the old papers spread beneath the stones. It was the Sydney Bulletin I have mentioned, for my friend had wide affiliations in all conceivable foreign parts; and the picture was a half-tone cut of a hideous stone image almost identical with that which Legrasse had found in the swamp.</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -90,7 +90,7 @@ If a woodchuck could chuck wood.
<h1>Forms of entertainment that aren't childish</h1>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -110,7 +110,7 @@ As such, we can guarantee that the non-childish forms of entertainment are proba
<p>As such, we can guarantee that the non-childish forms of entertainment are probably more entertaining to adults, since, having had a whole childhood doing the childish ones, the non-childish ones are merely the ones that haven't gotten boring yet.</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -144,7 +144,7 @@ fn footnotes_test_7() {
</div>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -161,5 +161,5 @@ fn footnotes_test_8() {
</div>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}

View file

@ -10,7 +10,7 @@ fn gfm_strikethrough_test_1() {
let expected = r##"<p><del>Hi</del> Hello, world!</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -23,5 +23,5 @@ new paragraph~~.
<p>new paragraph~~.</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}

View file

@ -25,7 +25,7 @@ fn gfm_table_test_1() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -50,7 +50,7 @@ bar | baz
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -77,7 +77,7 @@ fn gfm_table_test_3() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -106,7 +106,7 @@ fn gfm_table_test_4() {
</blockquote>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -139,7 +139,7 @@ bar
<p>bar</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -183,7 +183,7 @@ fn gfm_table_test_7() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -201,5 +201,5 @@ fn gfm_table_test_8() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}

View file

@ -14,7 +14,7 @@ fn gfm_tasklist_test_1() {
</ul>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -35,5 +35,5 @@ fn gfm_tasklist_test_2() {
</ul>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}

View file

@ -16,7 +16,7 @@ This is a test of the details element.
</details>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -36,7 +36,7 @@ fn regression_test_2() {
</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -53,7 +53,7 @@ fn regression_test_3() {
<a href="https://docs.rs/debug_stub_derive/0.3.0/"><img src="https://docs.rs/debug_stub_derive/badge.svg?version=0.3.0" alt="debug-stub-derive on docs.rs" /></a></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -74,7 +74,7 @@ fn regression_test_4() {
</tbody></table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -84,7 +84,7 @@ fn regression_test_5() {
let expected = r##"<p>foo§<strong>(bar)</strong></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -95,7 +95,7 @@ fn regression_test_6() {
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -109,7 +109,7 @@ fn regression_test_7() {
<!-- foo -->
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -137,7 +137,7 @@ fn regression_test_8() {
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -151,7 +151,7 @@ i8
let expected = r##"<p><a href="../../../std/primitive.i8.html"><code>i8</code></a></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -163,7 +163,7 @@ fn regression_test_10() {
let expected = r##"<p><a href="/url" title="title\*">a</a></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -175,7 +175,7 @@ fn regression_test_11() {
let expected = r##"<p><a href="/url" title="title)">a</a></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -188,7 +188,7 @@ fn regression_test_12() {
<p>[a]: /url (title))</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -201,7 +201,7 @@ b <?php but this is ?>
<p>b <?php but this is ?></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -212,7 +212,7 @@ foo
let expected = r##"<p>foo</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -222,7 +222,7 @@ fn regression_test_15() {
let expected = r##"<p>`foo`</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -234,7 +234,7 @@ bar
bar</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -247,7 +247,7 @@ fn regression_test_17() {
<p>1) bar</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -279,7 +279,7 @@ fn regression_test_19() {
let expected = r##"<p>[](&lt;&lt;&gt;)</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -289,7 +289,7 @@ fn regression_test_20() {
let expected = r##"<p>`<code>foo``bar</code></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -299,7 +299,7 @@ fn regression_test_21() {
let expected = r##"<p>\<code>foo</code></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -311,7 +311,7 @@ YOLO
let expected = r##"<p>YOLO</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -341,7 +341,7 @@ foo|bar
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -355,7 +355,7 @@ foo|bar
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -365,7 +365,7 @@ fn regression_test_26() {
let expected = r##"<p><a href="url"><foo></a></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -375,7 +375,7 @@ fn regression_test_27() {
let expected = r##"<p><a href="url"><foo>bar</foo></a></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -385,7 +385,7 @@ fn regression_test_28() {
let expected = r##"<p><img alt="http://example.com" src="http://example.com/logo.png"></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -395,7 +395,7 @@ fn regression_test_29() {
let expected = r##"<p><a href="url"></a><a href="http://one">http://one</a> <a href="http://two">http://two</a></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -410,7 +410,7 @@ some text
<p>some text</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -431,7 +431,7 @@ fn regression_test_31() {
</ol>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -446,7 +446,7 @@ x</p>
<p>]: f</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -456,7 +456,7 @@ fn regression_test_33() {
let expected = r##"<p>[foo]:</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -471,7 +471,7 @@ yolo | swag
<p>yolo | swag</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -481,7 +481,7 @@ fn regression_test_35() {
let expected = r##"<foo bar>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -493,7 +493,7 @@ fn regression_test_36() {
"hi"> </p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -506,7 +506,7 @@ __a__
<p><strong>a</strong></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -519,7 +519,7 @@ fn regression_test_38() {
</blockquote>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -529,7 +529,7 @@ fn regression_test_39() {
let expected = r##"<p><code>\|</code></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -542,7 +542,7 @@ Paragraph 2
<p>Paragraph 2</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -552,7 +552,7 @@ fn regression_test_41() {
let expected = r##"<p>[<a href="https://www.google.com/">link text</a>]</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -564,7 +564,7 @@ fn regression_test_42() {
let expected = r##"<table><thead><tr><th>foo</th><th>bar</th></tr></thead><tbody><tr><td>[a](&lt;</td><td>url&gt;)</td></tr></tbody></table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -578,7 +578,7 @@ fn regression_test_43() {
<p>")</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -591,7 +591,7 @@ fn regression_test_44() {
<p>)</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -604,7 +604,7 @@ fn regression_test_45() {
<p>&quot;)</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -614,7 +614,7 @@ fn regression_test_46() {
let expected = r##"<p>&lt;http:// &gt;</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -624,7 +624,7 @@ fn regression_test_47() {
let expected = r##"<p>&lt;http://&gt;</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -643,7 +643,7 @@ fn regression_test_48() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -662,7 +662,7 @@ fn regression_test_49() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -672,7 +672,7 @@ fn regression_test_50() {
let expected = r##"<p><sup>*hi</sup>_</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -682,7 +682,7 @@ fn regression_test_51() {
let expected = r##"<p>email: <a href="mailto:john@example.com">john@example.com</a>_</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -696,7 +696,7 @@ bar">link</a></p>
</blockquote>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -711,7 +711,7 @@ fn regression_test_53() {
</blockquote>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -727,7 +727,7 @@ bar</a></p>
</blockquote>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -745,7 +745,7 @@ fn regression_test_55() {
<p><a href="/foo">a b c</a></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -762,7 +762,7 @@ fn regression_test_56() {
<p>[a b] [a > b]</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -775,7 +775,7 @@ package`]
let expected = r##"<p><a href="https://example.com"><code>cargo package</code></a></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -790,7 +790,7 @@ fn regression_test_58() {
</blockquote>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -802,7 +802,7 @@ fn regression_test_59() {
<p><code>cargo package</code></p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -826,7 +826,7 @@ An unordered list before the footnotes:
</div>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -845,7 +845,7 @@ fn regression_test_61() {
<h1>assimp-rs <a href="https://crates.io/crates/assimp"><img alt="" src="http://meritbadge.herokuapp.com/assimp"></a></h1>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -890,7 +890,7 @@ fn regression_test_62() {
</ul>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -900,5 +900,5 @@ fn regression_test_63() {
let expected = r##"<p>&lt;foo</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}

File diff suppressed because it is too large Load diff

View file

@ -11,7 +11,7 @@ fn table_test_1() {
let expected = r##"<h2>Test header</h2>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -23,7 +23,7 @@ fn table_test_2() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -44,7 +44,7 @@ fn table_test_3() {
</blockquote>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -71,7 +71,7 @@ fn table_test_4() {
</ol>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -87,7 +87,7 @@ fn table_test_5() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -103,7 +103,7 @@ fn table_test_6() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -119,7 +119,7 @@ fn table_test_7() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -135,7 +135,7 @@ fn table_test_8() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -161,7 +161,7 @@ fn table_test_9() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -173,7 +173,7 @@ fn table_test_10() {
|||</p>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -187,7 +187,7 @@ fn table_test_11() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}
#[test]
@ -201,5 +201,5 @@ fn table_test_12() {
</table>
"##;
test_markdown_html(original, expected, true);
test_markdown_html(original, expected, false);
}

View file

@ -4,7 +4,7 @@ Open quotes are matched with closed quotes.
The same method is used for matching openers and closers
as is used in emphasis parsing:
```````````````````````````````` example
```````````````````````````````` example_smartpunct
"Hello," said the spider.
"'Shelob' is my name."
.
@ -12,13 +12,13 @@ as is used in emphasis parsing:
Shelob is my name.”</p>
````````````````````````````````
```````````````````````````````` example
```````````````````````````````` example_smartpunct
'A', 'B', and 'C' are letters.
.
<p>A, B, and C are letters.</p>
````````````````````````````````
```````````````````````````````` example
```````````````````````````````` example_smartpunct
'Oak,' 'elm,' and 'beech' are names of trees.
So is 'pine.'
.
@ -26,7 +26,7 @@ So is 'pine.'
So is pine.</p>
````````````````````````````````
```````````````````````````````` example
```````````````````````````````` example_smartpunct
'He said, "I want to go."'
.
<p>He said, “I want to go.”’</p>
@ -36,13 +36,13 @@ A single quote that isn't an open quote matched
with a close quote will be treated as an
apostrophe:
```````````````````````````````` example
```````````````````````````````` example_smartpunct
Were you alive in the 70's?
.
<p>Were you alive in the 70s?</p>
````````````````````````````````
```````````````````````````````` example
```````````````````````````````` example_smartpunct
Here is some quoted '`code`' and a "[quoted link](url)".
.
<p>Here is some quoted <code>code</code> and a “<a href="url">quoted link</a>”.</p>
@ -52,7 +52,7 @@ Here the first `'` is treated as an apostrophe, not
an open quote, because the final single quote is matched
by the single quote before `jolly`:
```````````````````````````````` example
```````````````````````````````` example_smartpunct
'tis the season to be 'jolly'
.
<p>tis the season to be jolly</p>
@ -60,7 +60,7 @@ by the single quote before `jolly`:
Multiple apostrophes should not be marked as open/closing quotes.
```````````````````````````````` example
```````````````````````````````` example_smartpunct
'We'll use Jane's boat and John's truck,' Jenna said.
.
<p>Well use Janes boat and Johns truck, Jenna said.</p>
@ -69,7 +69,7 @@ Multiple apostrophes should not be marked as open/closing quotes.
An unmatched double quote will be interpreted as a
left double quote, to facilitate this style:
```````````````````````````````` example
```````````````````````````````` example_smartpunct
"A paragraph with no closing quote.
"Second paragraph by same speaker, in fiction."
@ -81,7 +81,7 @@ left double quote, to facilitate this style:
A quote following a `]` or `)` character cannot
be an open quote:
```````````````````````````````` example
```````````````````````````````` example_smartpunct
[a]'s b'
.
<p>[a]s b</p>
@ -90,7 +90,7 @@ be an open quote:
Quotes that are escaped come out as literal straight
quotes:
```````````````````````````````` example
```````````````````````````````` example_smartpunct
\"This is not smart.\"
This isn\'t either.
5\'8\"
@ -102,7 +102,7 @@ This isn't either.
Two hyphens form an en-dash, three an em-dash.
```````````````````````````````` example
```````````````````````````````` example_smartpunct
Some dashes: em---em
en--en
em --- em
@ -127,7 +127,7 @@ dashes, and as few en dashes as possible are
used (so, 7 hyphens = 2 em dashes an 1 en
dash).
```````````````````````````````` example
```````````````````````````````` example_smartpunct
one-
two--
three---
@ -153,7 +153,7 @@ thirteen———.</p>
Hyphens can be escaped:
```````````````````````````````` example
```````````````````````````````` example_smartpunct
Escaped hyphens: \-- \-\-\-.
.
<p>Escaped hyphens: -- ---.</p>
@ -161,7 +161,7 @@ Escaped hyphens: \-- \-\-\-.
Three periods form an ellipsis:
```````````````````````````````` example
```````````````````````````````` example_smartpunct
Ellipses...and...and....
.
<p>Ellipses…and…and….</p>
@ -170,7 +170,7 @@ Ellipses...and...and....
Periods can be escaped if ellipsis-formation
is not wanted:
```````````````````````````````` example
```````````````````````````````` example_smartpunct
No ellipses\.\.\.
.
<p>No ellipses...</p>

View file

@ -561,7 +561,7 @@ Wrong characters:
Not enough characters:
```````````````````````````````` example_disable_smartpunct
```````````````````````````````` example
--
**
__
@ -647,7 +647,7 @@ Spaces are allowed at the end:
However, no other characters may occur in the line:
```````````````````````````````` example_disable_smartpunct
```````````````````````````````` example
_ _ _ _ a
a------
@ -1105,7 +1105,7 @@ Foo
Four spaces is too much:
```````````````````````````````` example_disable_smartpunct
```````````````````````````````` example
Foo
---
.
@ -1377,7 +1377,7 @@ bar</p>
Authors who want interpretation 3 can use backslash escapes:
```````````````````````````````` example_disable_smartpunct
```````````````````````````````` example
Foo
bar
\---
@ -9084,7 +9084,7 @@ comment - with hyphen --></p>
````````````````````````````````
```````````````````````````````` example_disable_smartpunct
```````````````````````````````` example
foo <!-- not a comment -- two hyphens -->
.
<p>foo &lt;!-- not a comment -- two hyphens --&gt;</p>
@ -9093,7 +9093,7 @@ foo <!-- not a comment -- two hyphens -->
Not comments:
```````````````````````````````` example_disable_smartpunct
```````````````````````````````` example
foo <!--> foo -->
foo <!-- foo--->

View file

@ -152,7 +152,7 @@ bar
The header row must match the [delimiter row] in the number of cells. If not,
a table will not be recognized:
```````````````````````````````` example_disable_smartpunct
```````````````````````````````` example
| abc | def |
| --- |
| bar |