| 1 | package notionmd |
| 2 | |
| 3 | import "strings" |
| 4 | |
| 5 | // reviewFixtures are the cases Fable's first review found (M1, L1, L2): |
| 6 | // each once degraded or failed a whole block or page. |
| 7 | func reviewFixtures() []fixture { |
| 8 | return []fixture{ |
| 9 | // M1: Notion text with "\r\n" or "\r" failed the page. |
| 10 | page("review-carriage-returns", para(txt("one\r\ntwo\rthree")), |
| 11 | blk("heading_2", txt("a\r\nb")), |
| 12 | blk("code", txt("x := 1\r\ny := 2"))), |
| 13 | // L1: a bare address, then a marked run, fell back. |
| 14 | page("review-address-then-marks", |
| 15 | para(txt("see https://example.com/a "), bold("now")), |
| 16 | para(txt("https://example.com/b"), codeRun("code")), |
| 17 | para(txt("at https://example.com/c"), italic(" then"))), |
| 18 | // L1: list items whose text is a rule's shape fell back. |
| 19 | page("review-rule-shaped-items", blk("bulleted_list_item", |
| 20 | txt("---")), blk("bulleted_list_item", txt("- -")), |
| 21 | blk("numbered_list_item", txt("***"))), |
| 22 | // L2: the ! seam's U+200B ran into a bare address before it. |
| 23 | page("review-bang-after-address", para( |
| 24 | txt("look at https://example.com/wow!"), |
| 25 | mention("page", "seam-target", "Target"))). |
| 26 | live("seam-target", "Target"), |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // reviewTwoFixtures are round 2's (Low 1, Low 2): addresses that must |
| 31 | // not be rewritten, and line breaks in single-line names. |
| 32 | func reviewTwoFixtures() []fixture { |
| 33 | return []fixture{ |
| 34 | page("review-addresses-left-alone", |
| 35 | para(txt("see http://localhost:PORT/admin "), bold("now")), |
| 36 | para(txt("at https://example.com/50% "), |
| 37 | mention("page", "left-target", "Left")), |
| 38 | para(txt("(https://example.com/100%)"), italic(" then")), |
| 39 | // Linkable, but stopped by ")" before the bold: left alone. |
| 40 | para(txt("(https://example.com/a)"), bold("b"))). |
| 41 | live("left-target", "Left"), |
| 42 | page("review-names-on-one-line", |
| 43 | Block{ID: "db", Type: "child_database", Known: true, |
| 44 | Title: "Two\nlines"}, |
| 45 | Block{ID: "f", Type: "pdf", Known: true, File: &File{ |
| 46 | Type: "file", URL: "https://s.example/x.pdf", |
| 47 | Name: "report\r\nfinal.pdf"}}, |
| 48 | para(Run{Type: "mention", Text: "@Ana\rLee", Mention: &Mention{ |
| 49 | Type: "user", Name: "Ana\r\nLee"}}), |
| 50 | Block{ID: "c", Type: "callout", Known: true, Emoji: "đŸ’¡\n", |
| 51 | Text: []Run{txt("Note")}}), |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | // reviewThreeFixtures are round 3's M1: generated links either side of |
| 56 | // markup.MaxAddress, in bytes, and an external image's. |
| 57 | func reviewThreeFixtures() []fixture { |
| 58 | base := "https://example.com/" |
| 59 | return []fixture{ |
| 60 | page("review-link-at-the-bound", para(txt("see "), |
| 61 | linked("the doc", base+strings.Repeat("a", 2048-len(base))), |
| 62 | txt(" now"))), |
| 63 | page("review-link-past-the-bound", para(txt("see "), |
| 64 | linked("the doc", base+strings.Repeat("a", 2100)), |
| 65 | txt(" now")), |
| 66 | para(linked("accents", base+strings.Repeat("Ă©", 1120))), |
| 67 | Block{ID: "far-image", Type: "image", Known: true, |
| 68 | File: &File{Type: "external", |
| 69 | URL: base + strings.Repeat("b", 2100)}, |
| 70 | Caption: []Run{txt("A far image")}}), |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | // reviewFourFixtures are round 4's: a long link where blocks put one, |
| 75 | // and the label branches (Fable round 4, M1 and L2). |
| 76 | func reviewFourFixtures() []fixture { |
| 77 | base := "https://example.com/" |
| 78 | far := base + strings.Repeat("c", 2100) |
| 79 | cell := tableOf(false, []string{"a", "b"}) |
| 80 | cell.Children[0].Cells[1] = []Run{linked("in a cell", far+"|x")} |
| 81 | return []fixture{ |
| 82 | page("review-long-link-in-blocks", cell, |
| 83 | Block{ID: "code", Type: "code", Known: true, |
| 84 | Text: []Run{txt("x := 1")}, Caption: []Run{ |
| 85 | linked("the source", far)}}, |
| 86 | Block{ID: "uncaptioned", Type: "image", Known: true, |
| 87 | File: &File{Type: "external", URL: far}}, |
| 88 | para(linked(far, far)), |
| 89 | para(linked("write", "mailto:"+strings.Repeat("d", 2100)+ |
| 90 | "@example.com"))), |
| 91 | } |
| 92 | } |
| 93 | |