marktip 0.5.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {marktip-0.5.0 → marktip-0.7.0}/CMakeLists.txt +1 -1
  2. {marktip-0.5.0 → marktip-0.7.0}/PKG-INFO +84 -28
  3. {marktip-0.5.0 → marktip-0.7.0}/README.md +83 -27
  4. {marktip-0.5.0 → marktip-0.7.0}/pyproject.toml +1 -1
  5. {marktip-0.5.0 → marktip-0.7.0}/src/ast.cpp +265 -100
  6. {marktip-0.5.0 → marktip-0.7.0}/src/ast.h +17 -4
  7. {marktip-0.5.0 → marktip-0.7.0}/src/marktip.cpp +17 -9
  8. marktip-0.7.0/tests/test_strict.py +628 -0
  9. {marktip-0.5.0 → marktip-0.7.0}/tests/test_uri_policy.py +12 -0
  10. {marktip-0.5.0 → marktip-0.7.0}/tests/test_validate.py +1 -1
  11. marktip-0.5.0/tests/test_strict.py +0 -311
  12. {marktip-0.5.0 → marktip-0.7.0}/.github/workflows/build-distributions.yml +0 -0
  13. {marktip-0.5.0 → marktip-0.7.0}/.gitignore +0 -0
  14. {marktip-0.5.0 → marktip-0.7.0}/LICENSE +0 -0
  15. {marktip-0.5.0 → marktip-0.7.0}/python/marktip/__init__.py +0 -0
  16. {marktip-0.5.0 → marktip-0.7.0}/scripts/benchmark.py +0 -0
  17. {marktip-0.5.0 → marktip-0.7.0}/src/errors.h +0 -0
  18. {marktip-0.5.0 → marktip-0.7.0}/src/parser.cpp +0 -0
  19. {marktip-0.5.0 → marktip-0.7.0}/src/parser.h +0 -0
  20. {marktip-0.5.0 → marktip-0.7.0}/src/serializer.cpp +0 -0
  21. {marktip-0.5.0 → marktip-0.7.0}/src/serializer.h +0 -0
  22. {marktip-0.5.0 → marktip-0.7.0}/tests/test_document.py +0 -0
  23. {marktip-0.5.0 → marktip-0.7.0}/tests/test_errors.py +0 -0
  24. {marktip-0.5.0 → marktip-0.7.0}/tests/test_parse.py +0 -0
  25. {marktip-0.5.0 → marktip-0.7.0}/tests/test_roundtrip.py +0 -0
  26. {marktip-0.5.0 → marktip-0.7.0}/tests/test_serialize.py +0 -0
  27. {marktip-0.5.0 → marktip-0.7.0}/third_party/md4c/LICENSE.md +0 -0
  28. {marktip-0.5.0 → marktip-0.7.0}/third_party/md4c/src/entity.c +0 -0
  29. {marktip-0.5.0 → marktip-0.7.0}/third_party/md4c/src/entity.h +0 -0
  30. {marktip-0.5.0 → marktip-0.7.0}/third_party/md4c/src/md4c.c +0 -0
  31. {marktip-0.5.0 → marktip-0.7.0}/third_party/md4c/src/md4c.h +0 -0
  32. {marktip-0.5.0 → marktip-0.7.0}/third_party/md4c/upstream_metadata/README.md +0 -0
@@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
7
7
  set(CMAKE_CXX_EXTENSIONS OFF)
8
8
 
9
9
  if(NOT DEFINED SKBUILD_PROJECT_VERSION)
10
- set(SKBUILD_PROJECT_VERSION "0.5.0")
10
+ set(SKBUILD_PROJECT_VERSION "0.7.0")
11
11
  endif()
12
12
 
13
13
  set(PYBIND11_FINDPYTHON ON)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: marktip
3
- Version: 0.5.0
3
+ Version: 0.7.0
4
4
  Summary: Fast C++/MD4C Markdown parser and canonical Markdown serializer for Tiptap-style JSON
5
5
  Keywords: markdown,tiptap,md4c,parser
6
6
  Author: Saneaven (Minjae Kyung)
@@ -111,36 +111,86 @@ An attr the serializer never reads is dropped without a word, so a `colspan: 2`
111
111
 
112
112
  ```python
113
113
  tm.from_dict(ast).to_markdown() # '| x |\n| --- |' — the colspan is gone
114
- tm.from_dict(ast, strict=True) # InvalidNodeError: attr 'colspan' cannot be
114
+ tm.from_dict(ast, strict="content") # InvalidNodeError: attr 'colspan' cannot be
115
115
  # expressed in markdown: GFM tables have no cell spanning
116
116
  ```
117
117
 
118
- `strict=True` refuses anything markdown would drop or alter, from the walk that is already happening, so a consumer does not have to re-traverse the tree in Python to find out whether the document survives intact.
119
- It is off by default and keyword-only, and it is a `from_dict` option only — the parser emits nothing but attrs it understands, with values in range, so there is nothing on the `from_markdown` path for it to catch.
118
+ `strict` names what the conversion may not lose, from the walk that is already happening, so a consumer does not have to re-traverse the tree in Python to find out whether the document survives intact.
119
+ It is keyword-only and a `from_dict` option only — the parser emits nothing but attrs it understands, with values in range, so there is nothing on the `from_markdown` path for it to catch.
120
120
 
121
- | Node | Accepted attrs |
121
+ | `strict` | Keeps |
122
122
  | --- | --- |
123
- | `heading` | `level`: 1–6 |
124
- | `codeBlock` | `language`, `info`: single-line `str` |
125
- | `bulletList`, `taskList` | `tight`: `bool` |
126
- | `orderedList` | `start`: 0–999999999, `tight`: `bool` |
127
- | `taskItem` | `checked`: `bool` |
128
- | `table` | `colCount`: non-negative `int` |
129
- | `tableHeader`, `tableCell` | `align`: `"left"`/`"center"`/`"right"`/`None`, `colspan`: `1`, `rowspan`: `1`, `colwidth`: `None` |
130
- | `image` | `src`, `alt`, `title`: `str` |
131
- | `htmlBlock`, `htmlInline` | `html`: `str` |
132
- | `link` mark | `href`, `title`: `str` |
123
+ | `"off"` (default) | nothing is checked |
124
+ | `"content"` | content and structure. Presentation an editor stamped on is type-checked and dropped |
125
+ | `"exact"` | every attr the JSON carries |
126
+
127
+ The two levels differ over one thing, and it is worth being precise about which:
128
+
129
+ ```python
130
+ # what a stock Tiptap Link extension submits for a link with only href set
131
+ mark = {"type": "link", "attrs": {"href": "https://a", "target": "_blank",
132
+ "rel": "noopener noreferrer nofollow",
133
+ "class": None, "title": None}}
134
+
135
+ tm.from_dict(ast, strict="content") # fine — target and rel are dropped
136
+ tm.from_dict(ast, strict="exact") # InvalidNodeError: attr 'target' cannot be expressed
137
+ # in markdown: a markdown link carries only a
138
+ # destination and a title
139
+ ```
140
+
141
+ Dropping that `target` costs the *author* nothing — the editor stamped it on and nobody wrote it.
142
+ Dropping a `colspan` moves every cell after it under a different header, so `"content"` refuses that one too.
143
+ Nothing in the JSON tells the two apart: ProseMirror serializes schema defaults onto every node, so a chosen `target` and a stamped one arrive identical.
144
+ That is why the caller picks, rather than the library guessing — store markdown as the record and `"content"` is the promise you want; keep the JSON and it is `"exact"`.
145
+
146
+ | Node | Accepted attrs | Dropped, no markdown form |
147
+ | --- | --- | --- |
148
+ | `heading` | `level`: 1–6 | |
149
+ | `codeBlock` | `language`, `info`: single-line `str` | |
150
+ | `bulletList`, `taskList` | `tight`: `bool` | |
151
+ | `orderedList` | `start`: 0–999999999, `tight`: `bool` | `type`: `str` |
152
+ | `taskItem` | `checked`: `bool` | |
153
+ | `table` | `colCount`: non-negative `int` | |
154
+ | `tableHeader`, `tableCell` | `align`: `"left"`/`"center"`/`"right"`/`None`, `colspan`: `1`, `rowspan`: `1` | `colwidth`: list of `int` |
155
+ | `image` | `src` **(required)**, `alt`, `title`: `str` | `width`, `height`: `str` or `int` |
156
+ | `htmlBlock`, `htmlInline` | `html`: `str` | |
157
+ | `link` mark | `href` **(required)**, `title`: `str` | `target`, `rel`, `class`: `str` |
133
158
 
134
159
  Every other type takes no attrs at all.
135
- Under strict, `bool` and `int` stay distinct — `{"level": True}` is refused rather than read as `1`.
160
+ A name in neither column is an `unknown_attr` at both levels — that is the rule that stops an `onclick` from vanishing silently.
161
+ `bool` and `int` stay distinct: `{"level": True}` is refused rather than read as `1`.
162
+ Most of these also take `None`, meaning the attr was never set; the paragraph below says which do not.
163
+
164
+ > **Changed in 0.7.0** — `strict` takes a level name instead of a bool, so `strict=True` now raises `TypeError`; `strict="exact"` is what it used to mean.
165
+ > Three things move with the new `"content"` level: the attrs in the right-hand column above are accepted and dropped rather than refused, `href`/`src` are required, and a refused presentation attr reports `unrepresentable` where it used to report `unknown_attr`.
136
166
 
137
- `colspan`/`rowspan`/`colwidth` are *known* attrs whose only accepted values are the no-ops Tiptap's table extension puts on every cell.
167
+ > **Changed in 0.6.0** — `None` on the optional attrs above now means the attr is unset, and the key is dropped on the way in rather than coerced to `""`.
168
+ > Two things move with it: an `image` whose `alt` is `None` *and* which carries content children now renders that child text, and `to_dict()` omits such a key instead of echoing `""`.
169
+
170
+ `None` reads as unset wherever Tiptap declares `default: null`, which is most of the schema.
171
+ ProseMirror serializes every attr including defaults, so `None` is what the editor submits for an attr nobody filled in, and an unset attr is accepted already; the markdown is the same either way.
172
+ The exceptions are the settings Tiptap gives a non-null default — `level`, `start`, `tight`, `checked`, `colspan`, `rowspan` — plus `html`, which is marktip's own attr with no Tiptap counterpart.
173
+ Tiptap never emits a `None` for those, so one means the dict was built wrong; the conversion would survive it, and strict reports it because it is a bug rather than a loss.
174
+ `align` is unchanged: `None` was already a *value* there ("no alignment"), not an unset marker.
175
+
176
+ `href` and `src` are the one place a `None` is not "unset" but "missing", and both levels refuse it:
177
+
178
+ ```python
179
+ tm.from_dict(link_without_href).to_markdown() # '[a]()' — reads back as a real link
180
+ tm.from_dict(link_without_href, strict="content") # InvalidNodeError: attr 'href' is required
181
+ # for mark type 'link'
182
+ ```
183
+
184
+ A link with no destination is not a link, so writing `[a]()` is not a lossy conversion but an invented one, and the empty destination survives into stored Markdown.
185
+ An `href` of `""` is a different case and is accepted: that is what `from_markdown` itself produces for `[a]()`, and it round-trips exactly.
186
+ Rejecting an empty destination is the URI policy's job (`link_relative="reject"`).
187
+
188
+ `colspan`/`rowspan` are *known* attrs whose only accepted values are the no-ops Tiptap's table extension puts on every cell.
138
189
  Refusing the names outright would leave strict unusable for the documents it exists to check.
139
- Tiptap's Link extension is the other direction: its default `target` and `rel` have no markdown form, so they are refused, which is the same rule that stops an `onclick` from vanishing silently.
140
190
 
141
- Two attrs are accepted and then ignored, and they are the only two.
191
+ Two attrs are accepted and then ignored at every level.
142
192
  The serializer derives a table's column count from its rows, so `colCount` is never read, and it takes cell alignment from the header row only, so `align` on a body row is never read either.
143
- Both are refused nowhere because `from_markdown` emits both: rejecting them would break re-parsing stored canonical Markdown on the read path, where a write-time refusal is much harder to notice.
193
+ Neither is a loss — the structure they describe is what survives — and `from_markdown` emits both, so refusing them would break re-parsing stored canonical Markdown on the read path, where a write-time refusal is much harder to notice.
144
194
 
145
195
  ## Errors
146
196
 
@@ -177,18 +227,23 @@ For `from_markdown` it locates the node in the parsed document, since the input
177
227
  | `disallowed_scheme` | `InvalidNodeError` | a link `href` / image `src` scheme is outside the allowlist |
178
228
  | `disallowed_relative_url` | `InvalidNodeError` | a scheme-less `href`/`src` violates the relative policy |
179
229
  | `invalid_uri_char` | `InvalidNodeError` | an `href`/`src` contains an ASCII control character |
180
- | `unknown_attr` | `InvalidNodeError` | `strict`: the attr has no markdown form for that type |
230
+ | `unknown_attr` | `InvalidNodeError` | `strict`: the attr name is in neither dialect for that type |
181
231
  | `invalid_attr_value` | `InvalidNodeError` | `strict`: the attr's value has the wrong type or is out of range |
182
- | `unrepresentable` | `InvalidNodeError` | `strict`: the value is well-formed, but GFM cannot carry it |
232
+ | `unrepresentable` | `InvalidNodeError` | `strict`: the value is well-formed, but markdown cannot carry it |
233
+ | `missing_attr` | `InvalidNodeError` | `strict`: a required attr is absent or `None` — a `link` with no `href`, an `image` with no `src` |
183
234
  | `markdown_max_depth` | `ParseError` | markdown nesting exceeds 2048 |
184
235
  | `parse_failed` | `ParseError` | MD4C could not parse the input |
185
236
 
186
237
  `from_markdown` still raises a plain `TypeError` when the argument is not `str`/`bytes` — that is a caller bug, not a malformed document.
187
- So is a bad URI-policy option: a non-iterable `link_schemes` raises `TypeError`, and `link_schemes=("https://",)` or `link_relative="nope"` raises `ValueError`.
238
+ So is a bad option value: a non-iterable `link_schemes` raises `TypeError`, and `link_schemes=("https://",)`, `link_relative="nope"` or `strict="strict"` raises `ValueError`.
239
+ `strict` takes a level name, so `strict=True` raises `TypeError` rather than quietly meaning something.
188
240
 
189
241
  > **Changed in 0.4.0** — these were previously `ValueError` (`from_dict`) and `RuntimeError` (`from_markdown`).
190
242
  > `MarktipError` derives from `Exception` directly, so `except ValueError` no longer catches them.
191
243
 
244
+ > **Changed in 0.7.0** — `missing_attr` is new, and an attr with no markdown form now reports `unrepresentable` rather than `unknown_attr`, which is left meaning "no schema declares this name".
245
+ > `attrs` values that are not `str`/`int`/`bool` are dropped instead of stringified, so `to_dict()` no longer echoes a `"[1, 2]"` the caller never wrote.
246
+
192
247
  > **Changed in 0.5.0** — an ASCII control character in a link `href` or image `src` is now rejected outright, with or without the URI policy.
193
248
  > A URI cannot carry one unencoded (`%09` is the encoded form), and leaving it in would defeat the allowlist itself, because browsers strip tab/LF/CR before reading the scheme.
194
249
  > This also rejects `[x](<a\tb>)`, which CommonMark otherwise accepts.
@@ -216,15 +271,16 @@ It guarantees, for the whole tree:
216
271
  A document that survives `from_dict` always serializes; callers do not need to re-check any of the above.
217
272
  `from_markdown` enforces the same two URI rules on what it parses.
218
273
 
219
- It deliberately does **not** validate, unless `strict=True` asks it to:
274
+ It deliberately does **not** validate, unless `strict` asks it to:
220
275
 
221
276
  - **`attrs` names and value types.**
222
277
  Keys are free-form.
223
- `str`, `int`, and `bool` round-trip unchanged; anything else is coerced to a string (`[1, 2]` → `"[1, 2]"`, `1.5` → `"1.5"`, `None` → `""`), so `to_dict()` will not always give back what you passed in.
278
+ `str`, `int`, and `bool` round-trip unchanged; every other value is dropped, `None` included, so `to_dict()` gives back what you passed in minus the keys markdown could not have carried anyway.
224
279
  An attr with no markdown form is dropped at serialization — see [Refusing lossy conversions](#refusing-lossy-conversions).
225
- - **Per-node required attrs**, `strict` included.
226
- A `heading` without `level`, an `image` without `src`, or a `link` mark without `href` is accepted; the serializer substitutes a default rather than failing.
227
- `strict` governs the attrs that are present, not which ones must be.
280
+ - **Per-node required attrs.**
281
+ A `heading` without `level` or a `codeBlock` without `language` is accepted; the serializer substitutes a default rather than failing.
282
+ `strict` adds exactly two: a `link` needs an `href` and an `image` needs a `src`, because the default there is an empty destination that reads back as a real link.
283
+ `{"src": None}` and no `src` key at all are the same thing to every part of the library, the URI policy included.
228
284
  - **Content models.**
229
285
  Which node may contain which is not checked — a `text` node directly under `doc` is accepted and serialized.
230
286
  - **Raw HTML.**
@@ -83,36 +83,86 @@ An attr the serializer never reads is dropped without a word, so a `colspan: 2`
83
83
 
84
84
  ```python
85
85
  tm.from_dict(ast).to_markdown() # '| x |\n| --- |' — the colspan is gone
86
- tm.from_dict(ast, strict=True) # InvalidNodeError: attr 'colspan' cannot be
86
+ tm.from_dict(ast, strict="content") # InvalidNodeError: attr 'colspan' cannot be
87
87
  # expressed in markdown: GFM tables have no cell spanning
88
88
  ```
89
89
 
90
- `strict=True` refuses anything markdown would drop or alter, from the walk that is already happening, so a consumer does not have to re-traverse the tree in Python to find out whether the document survives intact.
91
- It is off by default and keyword-only, and it is a `from_dict` option only — the parser emits nothing but attrs it understands, with values in range, so there is nothing on the `from_markdown` path for it to catch.
90
+ `strict` names what the conversion may not lose, from the walk that is already happening, so a consumer does not have to re-traverse the tree in Python to find out whether the document survives intact.
91
+ It is keyword-only and a `from_dict` option only — the parser emits nothing but attrs it understands, with values in range, so there is nothing on the `from_markdown` path for it to catch.
92
92
 
93
- | Node | Accepted attrs |
93
+ | `strict` | Keeps |
94
94
  | --- | --- |
95
- | `heading` | `level`: 1–6 |
96
- | `codeBlock` | `language`, `info`: single-line `str` |
97
- | `bulletList`, `taskList` | `tight`: `bool` |
98
- | `orderedList` | `start`: 0–999999999, `tight`: `bool` |
99
- | `taskItem` | `checked`: `bool` |
100
- | `table` | `colCount`: non-negative `int` |
101
- | `tableHeader`, `tableCell` | `align`: `"left"`/`"center"`/`"right"`/`None`, `colspan`: `1`, `rowspan`: `1`, `colwidth`: `None` |
102
- | `image` | `src`, `alt`, `title`: `str` |
103
- | `htmlBlock`, `htmlInline` | `html`: `str` |
104
- | `link` mark | `href`, `title`: `str` |
95
+ | `"off"` (default) | nothing is checked |
96
+ | `"content"` | content and structure. Presentation an editor stamped on is type-checked and dropped |
97
+ | `"exact"` | every attr the JSON carries |
98
+
99
+ The two levels differ over one thing, and it is worth being precise about which:
100
+
101
+ ```python
102
+ # what a stock Tiptap Link extension submits for a link with only href set
103
+ mark = {"type": "link", "attrs": {"href": "https://a", "target": "_blank",
104
+ "rel": "noopener noreferrer nofollow",
105
+ "class": None, "title": None}}
106
+
107
+ tm.from_dict(ast, strict="content") # fine — target and rel are dropped
108
+ tm.from_dict(ast, strict="exact") # InvalidNodeError: attr 'target' cannot be expressed
109
+ # in markdown: a markdown link carries only a
110
+ # destination and a title
111
+ ```
112
+
113
+ Dropping that `target` costs the *author* nothing — the editor stamped it on and nobody wrote it.
114
+ Dropping a `colspan` moves every cell after it under a different header, so `"content"` refuses that one too.
115
+ Nothing in the JSON tells the two apart: ProseMirror serializes schema defaults onto every node, so a chosen `target` and a stamped one arrive identical.
116
+ That is why the caller picks, rather than the library guessing — store markdown as the record and `"content"` is the promise you want; keep the JSON and it is `"exact"`.
117
+
118
+ | Node | Accepted attrs | Dropped, no markdown form |
119
+ | --- | --- | --- |
120
+ | `heading` | `level`: 1–6 | |
121
+ | `codeBlock` | `language`, `info`: single-line `str` | |
122
+ | `bulletList`, `taskList` | `tight`: `bool` | |
123
+ | `orderedList` | `start`: 0–999999999, `tight`: `bool` | `type`: `str` |
124
+ | `taskItem` | `checked`: `bool` | |
125
+ | `table` | `colCount`: non-negative `int` | |
126
+ | `tableHeader`, `tableCell` | `align`: `"left"`/`"center"`/`"right"`/`None`, `colspan`: `1`, `rowspan`: `1` | `colwidth`: list of `int` |
127
+ | `image` | `src` **(required)**, `alt`, `title`: `str` | `width`, `height`: `str` or `int` |
128
+ | `htmlBlock`, `htmlInline` | `html`: `str` | |
129
+ | `link` mark | `href` **(required)**, `title`: `str` | `target`, `rel`, `class`: `str` |
105
130
 
106
131
  Every other type takes no attrs at all.
107
- Under strict, `bool` and `int` stay distinct — `{"level": True}` is refused rather than read as `1`.
132
+ A name in neither column is an `unknown_attr` at both levels — that is the rule that stops an `onclick` from vanishing silently.
133
+ `bool` and `int` stay distinct: `{"level": True}` is refused rather than read as `1`.
134
+ Most of these also take `None`, meaning the attr was never set; the paragraph below says which do not.
135
+
136
+ > **Changed in 0.7.0** — `strict` takes a level name instead of a bool, so `strict=True` now raises `TypeError`; `strict="exact"` is what it used to mean.
137
+ > Three things move with the new `"content"` level: the attrs in the right-hand column above are accepted and dropped rather than refused, `href`/`src` are required, and a refused presentation attr reports `unrepresentable` where it used to report `unknown_attr`.
108
138
 
109
- `colspan`/`rowspan`/`colwidth` are *known* attrs whose only accepted values are the no-ops Tiptap's table extension puts on every cell.
139
+ > **Changed in 0.6.0** — `None` on the optional attrs above now means the attr is unset, and the key is dropped on the way in rather than coerced to `""`.
140
+ > Two things move with it: an `image` whose `alt` is `None` *and* which carries content children now renders that child text, and `to_dict()` omits such a key instead of echoing `""`.
141
+
142
+ `None` reads as unset wherever Tiptap declares `default: null`, which is most of the schema.
143
+ ProseMirror serializes every attr including defaults, so `None` is what the editor submits for an attr nobody filled in, and an unset attr is accepted already; the markdown is the same either way.
144
+ The exceptions are the settings Tiptap gives a non-null default — `level`, `start`, `tight`, `checked`, `colspan`, `rowspan` — plus `html`, which is marktip's own attr with no Tiptap counterpart.
145
+ Tiptap never emits a `None` for those, so one means the dict was built wrong; the conversion would survive it, and strict reports it because it is a bug rather than a loss.
146
+ `align` is unchanged: `None` was already a *value* there ("no alignment"), not an unset marker.
147
+
148
+ `href` and `src` are the one place a `None` is not "unset" but "missing", and both levels refuse it:
149
+
150
+ ```python
151
+ tm.from_dict(link_without_href).to_markdown() # '[a]()' — reads back as a real link
152
+ tm.from_dict(link_without_href, strict="content") # InvalidNodeError: attr 'href' is required
153
+ # for mark type 'link'
154
+ ```
155
+
156
+ A link with no destination is not a link, so writing `[a]()` is not a lossy conversion but an invented one, and the empty destination survives into stored Markdown.
157
+ An `href` of `""` is a different case and is accepted: that is what `from_markdown` itself produces for `[a]()`, and it round-trips exactly.
158
+ Rejecting an empty destination is the URI policy's job (`link_relative="reject"`).
159
+
160
+ `colspan`/`rowspan` are *known* attrs whose only accepted values are the no-ops Tiptap's table extension puts on every cell.
110
161
  Refusing the names outright would leave strict unusable for the documents it exists to check.
111
- Tiptap's Link extension is the other direction: its default `target` and `rel` have no markdown form, so they are refused, which is the same rule that stops an `onclick` from vanishing silently.
112
162
 
113
- Two attrs are accepted and then ignored, and they are the only two.
163
+ Two attrs are accepted and then ignored at every level.
114
164
  The serializer derives a table's column count from its rows, so `colCount` is never read, and it takes cell alignment from the header row only, so `align` on a body row is never read either.
115
- Both are refused nowhere because `from_markdown` emits both: rejecting them would break re-parsing stored canonical Markdown on the read path, where a write-time refusal is much harder to notice.
165
+ Neither is a loss — the structure they describe is what survives — and `from_markdown` emits both, so refusing them would break re-parsing stored canonical Markdown on the read path, where a write-time refusal is much harder to notice.
116
166
 
117
167
  ## Errors
118
168
 
@@ -149,18 +199,23 @@ For `from_markdown` it locates the node in the parsed document, since the input
149
199
  | `disallowed_scheme` | `InvalidNodeError` | a link `href` / image `src` scheme is outside the allowlist |
150
200
  | `disallowed_relative_url` | `InvalidNodeError` | a scheme-less `href`/`src` violates the relative policy |
151
201
  | `invalid_uri_char` | `InvalidNodeError` | an `href`/`src` contains an ASCII control character |
152
- | `unknown_attr` | `InvalidNodeError` | `strict`: the attr has no markdown form for that type |
202
+ | `unknown_attr` | `InvalidNodeError` | `strict`: the attr name is in neither dialect for that type |
153
203
  | `invalid_attr_value` | `InvalidNodeError` | `strict`: the attr's value has the wrong type or is out of range |
154
- | `unrepresentable` | `InvalidNodeError` | `strict`: the value is well-formed, but GFM cannot carry it |
204
+ | `unrepresentable` | `InvalidNodeError` | `strict`: the value is well-formed, but markdown cannot carry it |
205
+ | `missing_attr` | `InvalidNodeError` | `strict`: a required attr is absent or `None` — a `link` with no `href`, an `image` with no `src` |
155
206
  | `markdown_max_depth` | `ParseError` | markdown nesting exceeds 2048 |
156
207
  | `parse_failed` | `ParseError` | MD4C could not parse the input |
157
208
 
158
209
  `from_markdown` still raises a plain `TypeError` when the argument is not `str`/`bytes` — that is a caller bug, not a malformed document.
159
- So is a bad URI-policy option: a non-iterable `link_schemes` raises `TypeError`, and `link_schemes=("https://",)` or `link_relative="nope"` raises `ValueError`.
210
+ So is a bad option value: a non-iterable `link_schemes` raises `TypeError`, and `link_schemes=("https://",)`, `link_relative="nope"` or `strict="strict"` raises `ValueError`.
211
+ `strict` takes a level name, so `strict=True` raises `TypeError` rather than quietly meaning something.
160
212
 
161
213
  > **Changed in 0.4.0** — these were previously `ValueError` (`from_dict`) and `RuntimeError` (`from_markdown`).
162
214
  > `MarktipError` derives from `Exception` directly, so `except ValueError` no longer catches them.
163
215
 
216
+ > **Changed in 0.7.0** — `missing_attr` is new, and an attr with no markdown form now reports `unrepresentable` rather than `unknown_attr`, which is left meaning "no schema declares this name".
217
+ > `attrs` values that are not `str`/`int`/`bool` are dropped instead of stringified, so `to_dict()` no longer echoes a `"[1, 2]"` the caller never wrote.
218
+
164
219
  > **Changed in 0.5.0** — an ASCII control character in a link `href` or image `src` is now rejected outright, with or without the URI policy.
165
220
  > A URI cannot carry one unencoded (`%09` is the encoded form), and leaving it in would defeat the allowlist itself, because browsers strip tab/LF/CR before reading the scheme.
166
221
  > This also rejects `[x](<a\tb>)`, which CommonMark otherwise accepts.
@@ -188,15 +243,16 @@ It guarantees, for the whole tree:
188
243
  A document that survives `from_dict` always serializes; callers do not need to re-check any of the above.
189
244
  `from_markdown` enforces the same two URI rules on what it parses.
190
245
 
191
- It deliberately does **not** validate, unless `strict=True` asks it to:
246
+ It deliberately does **not** validate, unless `strict` asks it to:
192
247
 
193
248
  - **`attrs` names and value types.**
194
249
  Keys are free-form.
195
- `str`, `int`, and `bool` round-trip unchanged; anything else is coerced to a string (`[1, 2]` → `"[1, 2]"`, `1.5` → `"1.5"`, `None` → `""`), so `to_dict()` will not always give back what you passed in.
250
+ `str`, `int`, and `bool` round-trip unchanged; every other value is dropped, `None` included, so `to_dict()` gives back what you passed in minus the keys markdown could not have carried anyway.
196
251
  An attr with no markdown form is dropped at serialization — see [Refusing lossy conversions](#refusing-lossy-conversions).
197
- - **Per-node required attrs**, `strict` included.
198
- A `heading` without `level`, an `image` without `src`, or a `link` mark without `href` is accepted; the serializer substitutes a default rather than failing.
199
- `strict` governs the attrs that are present, not which ones must be.
252
+ - **Per-node required attrs.**
253
+ A `heading` without `level` or a `codeBlock` without `language` is accepted; the serializer substitutes a default rather than failing.
254
+ `strict` adds exactly two: a `link` needs an `href` and an `image` needs a `src`, because the default there is an empty destination that reads back as a real link.
255
+ `{"src": None}` and no `src` key at all are the same thing to every part of the library, the URI policy included.
200
256
  - **Content models.**
201
257
  Which node may contain which is not checked — a `text` node directly under `doc` is accepted and serialized.
202
258
  - **Raw HTML.**
@@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"
4
4
 
5
5
  [project]
6
6
  name = "marktip"
7
- version = "0.5.0"
7
+ version = "0.7.0"
8
8
  description = "Fast C++/MD4C Markdown parser and canonical Markdown serializer for Tiptap-style JSON"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"