package main import "testing" // Emphasis follows CommonMark's flanking rules, so the loose asterisks and // underscores of OCR - footnote marks, flattened bullets, star pages, // form blanks - stay text, and real emphasis nests properly. func TestParseInlineEmphasis(t *testing.T) { for in, want := range map[string]string{ // Real emphasis. "*it* and **bold**": "it and bold", "***bold italic***": "bold italic", "**2** | **61**": "2 | 61", "An *n*-clique": "An n-clique", "*a **b** c*": "a b c", "**bold *nested* x**": "bold nested x", "*`code`*": "code", "_em_ and __init__.py": "em and init.py", `"On Language,"* a *New York Times*`: ""On Language,"* a New York Times", // A closer takes the nearest opener, not the first one on the line. "Inc.*, 321 F.3d; see also *North v. Ashcroft*, 308": "Inc.*, 321 F.3d; see also North v. Ashcroft, 308", // Not emphasis. "PINWALE (Sweet* and Sour* partitions)": "PINWALE (Sweet* and Sour* partitions)", "NRO*, CIA, SCEs* and field sites": "NRO*, CIA, SCEs* and field sites", "works with: * NCSC * TAO": "works with: * NCSC * TAO", "*** Currently Inactive ***": "*** Currently Inactive ***", "a Driving Force ******": "a Driving Force ******", "2013 WL 5741573, at *3-*9": "2013 WL 5741573, at *3-*9", "2 * 3 * 4": "2 * 3 * 4", "snake_case_name": "snake_case_name", "D/DIR____,IG_____,OGC___": "D/DIR____,IG_____,OGC___", "SO ORDERED, this _____ day of July": "SO ORDERED, this _____ day of July", "datastore
_ target user
_ time": "datastore
_ target user
_ time", `\*not em\*`: "*not em*", } { if got := parseInline(in); got != want { t.Errorf("parseInline(%q)\n got %q\nwant %q", in, got, want) } } } // A list never mixes bullets and numbers: a number kept in a