847 lines · 19.6 KB · JSONRaw
{ "format_version": 1, "about": "Vectors for cotton-rules::writing. Positions are UTF-16 code units. In `format`, a text marks its cursor with ‸ or its selection with « and »; the marks are not part of the text. A span is written \"start-end style look\" with its glyph or heading level after.", "derive": [ { "name": "heading title", "text": "# Groceries\n\nMilk and **eggs**\nBread", "title": "Groceries", "preview": "Milk and eggs\nBread", "preview_lines": 2, "tags": [] }, { "name": "no title: a paragraph first", "text": "Call the plumber\nabout the tap\nand the boiler\nand the roof", "preview": "Call the plumber\nabout the tap\nand the boiler", "preview_lines": 3, "tags": [] }, { "name": "only a list", "text": "- milk\n- [ ] eggs\n- [x] bread\n1. jam", "preview": "milk\neggs\nbread", "preview_lines": 3, "tags": [] }, { "name": "only a link", "text": "[Cotton](https://cottondb.com)", "preview": "Cotton", "preview_lines": 3, "tags": [] }, { "name": "only a bare address", "text": "https://cottondb.com/notes.", "preview": "https://cottondb.com/notes.", "preview_lines": 3, "tags": [] }, { "name": "a heading lower down is no title", "text": "Some words\n\n## Later", "preview": "Some words\nLater", "preview_lines": 3, "tags": [] }, { "name": "a level-two heading first is the title", "text": "\n\n## Trip *plans* ##\n> pack light\n\n---\n```\ncode line\n```", "title": "Trip plans", "preview": "pack light\ncode line", "preview_lines": 2, "tags": [] }, { "name": "empty", "text": "", "preview": "", "preview_lines": 3, "tags": [] }, { "name": "title alone", "text": "# Just a title\n", "title": "Just a title", "preview": "", "preview_lines": 2, "tags": [] }, { "name": "tags", "text": "# Ideas #work\nsee #Work and #home/garden, #multi word tag# and #2024 and C# code\n`#notatag` [#linked](https://x.com/#frag) #emoji🌱", "title": "Ideas #work", "preview": "see Work and home/garden, multi word tag and #2024 and C# code\n#notatag linked emoji🌱", "preview_lines": 2, "tags": [ "work", "home/garden", "multi word tag", "linked", "emoji🌱" ] }, { "name": "a tag ends at punctuation", "text": "Done (#errands). Then #a/b/ and #trail- and #x.y", "preview": "Done (errands). Then a/b/ and trail- and x.y", "preview_lines": 3, "tags": [ "errands", "a/b", "trail", "x" ] }, { "name": "a tag inside a code block is no tag", "text": "```\n#include <stdio.h>\n```\n#real", "preview": "#include <stdio.h>\nreal", "preview_lines": 3, "tags": [ "real" ] }, { "name": "a table previews as its cells", "text": "| Day | Plan |\n| --- | :-: |\n| Mon | swim |", "preview": "Day · Plan\nMon · swim", "preview_lines": 3, "tags": [] }, { "name": "only a picture", "text": "\n", "preview": "", "preview_lines": 3, "tags": [], "picture": "media:abc" } ], "opened": [ { "name": "a note written as one text", "title": null, "body": "# Hello\n\nworld", "text": "# Hello\n\nworld" }, { "name": "an old note: stored title, plain body", "title": "Groceries", "body": "milk\neggs", "text": "# Groceries\n\nmilk\neggs" }, { "name": "an old note whose body starts with its title", "title": "Groceries", "body": "Groceries\nmilk", "text": "# Groceries\nmilk" }, { "name": "an old note with a title and no body", "title": "Only a title", "body": "", "text": "# Only a title\n" }, { "name": "an old note whose body already heads with its title", "title": "Plan", "body": "# Plan\nsteps", "text": "# Plan\nsteps" }, { "name": "an old note with no title", "title": "", "body": "first line\nsecond", "text": "first line\nsecond" } ], "style": [ { "name": "title, cursor away: marks hidden", "text": "# Title\nsome **bold** word", "cursor": 0, "blocks": [ "0-7 heading 0 level1 title", "8-26 paragraph 0" ], "spans": [ "0-2 mark dim", "2-7 title text 1", "13-15 mark hidden", "15-19 bold text", "19-21 mark hidden" ] }, { "name": "cursor inside bold: its marks dim", "text": "# Title\nsome **bold** word", "cursor": 16, "blocks": [ "0-7 heading 0 level1 title", "8-26 paragraph 0" ], "spans": [ "0-2 mark hidden", "2-7 title text 1", "13-15 mark dim", "15-19 bold text", "19-21 mark dim" ] }, { "name": "reading: every mark hidden", "text": "*it* ~u~ ~~s~~ ==h== `c`", "cursor": null, "blocks": [ "0-24 paragraph 0" ], "spans": [ "0-1 mark hidden", "1-3 italic text", "3-4 mark hidden", "5-6 mark hidden", "6-7 underline text", "7-8 mark hidden", "9-11 mark hidden", "11-12 strike text", "12-14 mark hidden", "15-17 mark hidden", "17-18 highlight text", "18-20 mark hidden", "21-22 mark hidden", "22-23 code text", "23-24 mark hidden" ] }, { "name": "lists, checks and a divider", "text": "- one\n - two\n- [ ] todo\n- [x] done\n3. three\n---", "cursor": null, "blocks": [ "0-5 bullet 0", "6-15 bullet 1", "16-26 check 0 open", "27-37 check 0 ticked", "38-46 numbered 0 n3", "47-50 divider 0" ], "spans": [ "0-2 mark glyph bullet", "6-10 indent hidden", "10-12 mark glyph bullet", "16-22 mark glyph box", "27-33 mark glyph ticked", "33-37 done text", "38-41 number text", "47-50 mark glyph rule" ] }, { "name": "a quote, a link, a tag and a code block", "text": "> said [here](https://a.b) #tag\n```\nlet **x** = 1;\n```", "cursor": 40, "blocks": [ "0-31 quote 0", "32-35 fence 0", "36-50 code 0", "51-54 fence 0" ], "spans": [ "0-2 mark hidden", "2-31 quote text", "7-8 mark hidden", "8-12 link text", "12-26 mark hidden", "27-31 tag text", "32-35 mark dim", "36-50 code_block text", "51-54 mark dim" ] }, { "name": "snake_case stays plain, *** is bold and italic", "text": "a_b_c ***both***", "cursor": null, "blocks": [ "0-16 paragraph 0" ], "spans": [ "6-8 mark hidden", "8-14 bold text", "8-9 mark hidden", "9-13 italic text", "13-14 mark hidden", "14-16 mark hidden" ] }, { "name": "UTF-16 offsets past an emoji", "text": "🌱 **x**", "cursor": null, "blocks": [ "0-8 paragraph 0" ], "spans": [ "3-5 mark hidden", "5-6 bold text", "6-8 mark hidden" ] }, { "name": "a table and a picture", "text": "| a | b |\n|---|--:|\n| 1 |\n", "cursor": null, "blocks": [ "0-9 table 0", "10-19 table_rule 0", "20-25 table 0", "26-41 picture 0 src=media:x" ], "spans": [ "0-2 mark hidden", "3-6 mark hidden", "7-9 mark hidden", "10-19 mark hidden", "20-22 mark hidden", "23-25 mark hidden", "26-28 mark hidden", "28-31 image text", "31-41 mark hidden" ], "tables": [ { "start": 0, "end": 25, "align": [ "none", "right" ], "rows": [ [ { "start": 2, "end": 3, "text": "a" }, { "start": 6, "end": 7, "text": "b" } ], [ { "start": 22, "end": 23, "text": "1" }, { "start": 25, "end": 25, "text": "" } ] ] } ] } ], "format": [ { "name": "bold a selection", "text": "say «hello» there", "action": { "action": "bold" }, "after": "say **«hello»** there" }, { "name": "bold off inside bold", "text": "say **he‸llo** there", "action": { "action": "bold" }, "after": "say he‸llo there" }, { "name": "bold a word at a cursor inside it", "text": "say he‸llo", "action": { "action": "bold" }, "after": "say **he‸llo**" }, { "name": "bold at a cursor after a word: an empty pair", "text": "say ‸", "action": { "action": "bold" }, "after": "say **‸**" }, { "name": "italic over two lines wraps each line", "text": "«one\ntwo» three", "action": { "action": "italic" }, "after": "*«one*\n*two»* three" }, { "name": "bold trims the selection's spaces", "text": "a« word »b", "action": { "action": "bold" }, "after": "a **«word»** b" }, { "name": "highlight", "text": "«mark»", "action": { "action": "highlight" }, "after": "==«mark»==" }, { "name": "strike", "text": "«gone»", "action": { "action": "strike" }, "after": "~~«gone»~~" }, { "name": "underline", "text": "«under»", "action": { "action": "underline" }, "after": "~«under»~" }, { "name": "inline code", "text": "run «ls»", "action": { "action": "code" }, "after": "run `«ls»`" }, { "name": "heading 1", "text": "Ti‸tle", "action": { "action": "heading", "level": 1 }, "after": "# Ti‸tle" }, { "name": "heading 2 over a heading 1", "text": "# Ti‸tle", "action": { "action": "heading", "level": 2 }, "after": "## Ti‸tle" }, { "name": "the same heading again goes back to a paragraph", "text": "## Ti‸tle", "action": { "action": "heading", "level": 2 }, "after": "Ti‸tle" }, { "name": "a bulleted list over lines", "text": "«one\ntwo»", "action": { "action": "bullet" }, "after": "- «one\n- two»" }, { "name": "bullets off when all are bullets", "text": "- «one\n- two»", "action": { "action": "bullet" }, "after": "«one\ntwo»" }, { "name": "numbered list", "text": "«a\nb\nc»", "action": { "action": "numbered" }, "after": "1. «a\n2. b\n3. c»" }, { "name": "a bullet becomes a check item", "text": "- milk‸", "action": { "action": "check" }, "after": "- [ ] milk‸" }, { "name": "quote", "text": "wise‸ words", "action": { "action": "quote" }, "after": "> wise‸ words" }, { "name": "tick", "text": "- [ ] eg‸gs", "action": { "action": "tick" }, "after": "- [x] eg‸gs" }, { "name": "untick", "text": "- [x] eg‸gs", "action": { "action": "tick" }, "after": "- [ ] eg‸gs" }, { "name": "return continues a bullet", "text": "- milk‸", "action": { "action": "return" }, "after": "- milk\n- ‸" }, { "name": "return continues a check item unticked", "text": "- [x] milk‸", "action": { "action": "return" }, "after": "- [x] milk\n- [ ] ‸" }, { "name": "return continues numbering and renumbers after", "text": "1. a‸\n2. b\n3. c", "action": { "action": "return" }, "after": "1. a\n2. ‸\n3. b\n4. c" }, { "name": "return splits an item", "text": "- milk ‸eggs", "action": { "action": "return" }, "after": "- milk \n- ‸eggs" }, { "name": "return on an empty item ends the list", "text": "- milk\n- ‸", "action": { "action": "return" }, "after": "- milk\n‸" }, { "name": "return on an empty indented item steps out", "text": "- milk\n - ‸", "action": { "action": "return" }, "after": "- milk\n- ‸" }, { "name": "return continues a quote", "text": "> one‸", "action": { "action": "return" }, "after": "> one\n> ‸" }, { "name": "return in code keeps the indent", "text": "```\n let x‸\n```", "action": { "action": "return" }, "after": "```\n let x\n ‸\n```" }, { "name": "return after a heading is a plain line", "text": "# Title‸", "action": { "action": "return" }, "after": "# Title\n‸" }, { "name": "return replaces a selection", "text": "ab«cd»ef", "action": { "action": "return" }, "after": "ab\n‸ef" }, { "name": "indent an item", "text": "- one\n- t‸wo", "action": { "action": "indent" }, "after": "- one\n - t‸wo" }, { "name": "outdent an item", "text": "- one\n - t‸wo", "action": { "action": "outdent" }, "after": "- one\n- t‸wo" }, { "name": "indent leaves a paragraph alone", "text": "pl‸ain", "action": { "action": "indent" }, "after": "pl‸ain" }, { "name": "move a line up", "text": "one\ntw‸o\nthree", "action": { "action": "move_up" }, "after": "tw‸o\none\nthree" }, { "name": "move a line down", "text": "one\ntw‸o\nthree", "action": { "action": "move_down" }, "after": "one\nthree\ntw‸o" }, { "name": "move the first line up: nothing", "text": "on‸e\ntwo", "action": { "action": "move_up" }, "after": "on‸e\ntwo" }, { "name": "move two lines down", "text": "«a\nb»\nc", "action": { "action": "move_down" }, "after": "c\n«a\nb»" }, { "name": "link with no address waits in the parentheses", "text": "see «here»", "action": { "action": "link" }, "after": "see [here](‸)" }, { "name": "link with an address", "text": "see «here»", "action": { "action": "link", "url": "https://a.b" }, "after": "see [here](https://a.b)‸" }, { "name": "link at a cursor selects the address as its words", "text": "see ‸", "action": { "action": "link", "url": "https://a.b" }, "after": "see [«https://a.b»](https://a.b)" }, { "name": "link off inside a link", "text": "see [he‸re](https://a.b) now", "action": { "action": "link" }, "after": "see he‸re now" }, { "name": "divider after a line", "text": "abo‸ve", "action": { "action": "divider" }, "after": "above\n\n---\n‸" }, { "name": "divider on a blank line", "text": "above\n\n‸", "action": { "action": "divider" }, "after": "above\n\n---\n‸" }, { "name": "code block around lines", "text": "«a\nb»", "action": { "action": "code_block" }, "after": "```\n«a\nb»\n```" }, { "name": "code block off inside one", "text": "x\n```\na‸\n```\ny", "action": { "action": "code_block" }, "after": "x\na‸\ny" }, { "name": "paragraph takes a list off", "text": "- [ ] it‸em", "action": { "action": "paragraph" }, "after": "it‸em" }, { "name": "bold past an emoji", "text": "🌱 «x»", "action": { "action": "bold" }, "after": "🌱 **«x»**" }, { "name": "a new table", "text": "above‸", "action": { "action": "table" }, "after": "above\n\n| ‸ | |\n| --- | --- |\n| | |\n" }, { "name": "a row under the cursor's row", "text": "| a | b |\n| - | - |\n| 1‸ | 2 |", "action": { "action": "table_row_add" }, "after": "| a | b |\n| --- | --- |\n| 1 | 2 |\n| ‸ | |" }, { "name": "return in a table adds a row", "text": "| a‸ | b |\n| - | - |", "action": { "action": "return" }, "after": "| a | b |\n| --- | --- |\n| ‸ | |" }, { "name": "a row goes", "text": "| a | b |\n| - | - |\n| 1‸ | 2 |\n| 3 | 4 |", "action": { "action": "table_row_remove" }, "after": "| a | b |\n| --- | --- |\n| 3‸ | 4 |" }, { "name": "the header row stays", "text": "| a‸ | b |\n| - | - |", "action": { "action": "table_row_remove" }, "after": "| a‸ | b |\n| - | - |" }, { "name": "a column after the cursor's", "text": "| a‸ | b |\n| - | :-: |\n| 1 | 2 |", "action": { "action": "table_column_add" }, "after": "| a | ‸ | b |\n| --- | --- | :-: |\n| 1 | | 2 |" }, { "name": "a column goes", "text": "| a | b‸ |\n| - | - |\n| 1 | 2 |", "action": { "action": "table_column_remove" }, "after": "| a‸ |\n| --- |\n| 1 |" }, { "name": "the last column takes the table", "text": "x\n| a‸ |\n| - |\ny", "action": { "action": "table_column_remove" }, "after": "x\n‸y" }, { "name": "a cell's words", "text": "| a | b |\n| - | - |\n| 1‸ | 2 |", "action": { "action": "table_cell", "row": 1, "column": 1, "text": "two | 2" }, "after": "| a | b |\n| - | - |\n| 1 | two \\| 2‸ |" }, { "name": "a picture after the line", "text": "see‸ this", "action": { "action": "picture", "src": "media:k", "alt": "cat" }, "after": "see this\n\n\n‸" } ], "pictures": [ { "name": "an old note's attachments draw after its text", "text": "# Trip\n\nwords\n", "attached": [ "media:a", "media:b" ], "after": "# Trip\n\nwords\n\n\n\n\n" }, { "name": "a picture already in the text is not added again", "text": "words\n\n\n", "attached": [ "media:a", "media:b" ], "after": "words\n\n\n\n\n" }, { "name": "an empty note with a picture", "text": "", "attached": [ "media:a" ], "after": "\n" } ]}