marktip 0.7.0__tar.gz → 0.7.2__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 (34) hide show
  1. {marktip-0.7.0 → marktip-0.7.2}/CMakeLists.txt +1 -1
  2. {marktip-0.7.0 → marktip-0.7.2}/PKG-INFO +71 -8
  3. {marktip-0.7.0 → marktip-0.7.2}/README.md +70 -7
  4. {marktip-0.7.0 → marktip-0.7.2}/pyproject.toml +1 -1
  5. {marktip-0.7.0 → marktip-0.7.2}/src/ast.cpp +301 -36
  6. {marktip-0.7.0 → marktip-0.7.2}/src/ast.h +18 -3
  7. {marktip-0.7.0 → marktip-0.7.2}/src/errors.h +4 -2
  8. {marktip-0.7.0 → marktip-0.7.2}/src/marktip.cpp +21 -10
  9. {marktip-0.7.0 → marktip-0.7.2}/src/parser.cpp +57 -10
  10. {marktip-0.7.0 → marktip-0.7.2}/src/parser.h +1 -1
  11. marktip-0.7.2/tests/test_content_model.py +159 -0
  12. {marktip-0.7.0 → marktip-0.7.2}/tests/test_errors.py +91 -0
  13. marktip-0.7.2/tests/test_node_type_policy.py +100 -0
  14. marktip-0.7.2/tests/test_nul_normalization.py +176 -0
  15. {marktip-0.7.0 → marktip-0.7.2}/tests/test_parse.py +21 -0
  16. {marktip-0.7.0 → marktip-0.7.2}/tests/test_strict.py +124 -4
  17. {marktip-0.7.0 → marktip-0.7.2}/.github/workflows/build-distributions.yml +0 -0
  18. {marktip-0.7.0 → marktip-0.7.2}/.gitignore +0 -0
  19. {marktip-0.7.0 → marktip-0.7.2}/LICENSE +0 -0
  20. {marktip-0.7.0 → marktip-0.7.2}/python/marktip/__init__.py +0 -0
  21. {marktip-0.7.0 → marktip-0.7.2}/scripts/benchmark.py +0 -0
  22. {marktip-0.7.0 → marktip-0.7.2}/src/serializer.cpp +0 -0
  23. {marktip-0.7.0 → marktip-0.7.2}/src/serializer.h +0 -0
  24. {marktip-0.7.0 → marktip-0.7.2}/tests/test_document.py +0 -0
  25. {marktip-0.7.0 → marktip-0.7.2}/tests/test_roundtrip.py +0 -0
  26. {marktip-0.7.0 → marktip-0.7.2}/tests/test_serialize.py +0 -0
  27. {marktip-0.7.0 → marktip-0.7.2}/tests/test_uri_policy.py +0 -0
  28. {marktip-0.7.0 → marktip-0.7.2}/tests/test_validate.py +0 -0
  29. {marktip-0.7.0 → marktip-0.7.2}/third_party/md4c/LICENSE.md +0 -0
  30. {marktip-0.7.0 → marktip-0.7.2}/third_party/md4c/src/entity.c +0 -0
  31. {marktip-0.7.0 → marktip-0.7.2}/third_party/md4c/src/entity.h +0 -0
  32. {marktip-0.7.0 → marktip-0.7.2}/third_party/md4c/src/md4c.c +0 -0
  33. {marktip-0.7.0 → marktip-0.7.2}/third_party/md4c/src/md4c.h +0 -0
  34. {marktip-0.7.0 → marktip-0.7.2}/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.7.0")
10
+ set(SKBUILD_PROJECT_VERSION "0.7.2")
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.7.0
3
+ Version: 0.7.2
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)
@@ -104,9 +104,30 @@ doc = tm.from_markdown(untrusted, link_schemes=("https",), image_relative="rejec
104
104
  Violations raise `InvalidNodeError` with `.field` set to `"href"` or `"src"`.
105
105
  The options are keyword-only.
106
106
 
107
+ ### Rejecting node types
108
+
109
+ marktip's schema includes every node it can serialize, but an application may use a smaller ProseMirror dialect.
110
+ Both write boundaries accept `reject_node_types`, so that dialect can be enforced after either Markdown parsing or dict conversion without a second application-side tree walk:
111
+
112
+ ```python
113
+ NO_RAW_HTML = ("htmlBlock", "htmlInline")
114
+
115
+ doc = tm.from_dict(editor_json, reject_node_types=NO_RAW_HTML)
116
+ doc = tm.from_markdown(imported_markdown, reject_node_types=NO_RAW_HTML)
117
+ ```
118
+
119
+ `None` (the default) rejects nothing; an empty iterable has the same effect.
120
+ Every entry must name a node type marktip knows, and matching is exact and case-sensitive.
121
+ A bare string or a non-string entry raises `TypeError`; an unknown node name raises `ValueError`.
122
+ A document containing a configured type raises `InvalidNodeError` with `.code == "disallowed_node_type"`, `.field == "type"`, and `.path` locating the node.
123
+ The option is keyword-only.
124
+
125
+ This differs from `html=False`: `html=False` preserves raw markup as escaped literal text on Markdown input, while rejecting `htmlBlock`/`htmlInline` refuses markup that parsed as a raw-HTML node.
126
+ `reject_node_types` also works for dict input, where there is no parser flag.
127
+
107
128
  ### Refusing lossy conversions
108
129
 
109
- Node and mark *types* are closed, but `attrs` are not.
130
+ Node and mark *types* are always closed, but fields, attrs and content models are only closed when `strict` is enabled.
110
131
  An attr the serializer never reads is dropped without a word, so a `colspan: 2` cell quietly becomes a plain one:
111
132
 
112
133
  ```python
@@ -121,9 +142,37 @@ It is keyword-only and a `from_dict` option only — the parser emits nothing bu
121
142
  | `strict` | Keeps |
122
143
  | --- | --- |
123
144
  | `"off"` (default) | nothing is checked |
124
- | `"content"` | content and structure. Presentation an editor stamped on is type-checked and dropped |
145
+ | `"content"` | content and structure, including closed node fields and content models. Presentation an editor stamped on is type-checked and dropped |
125
146
  | `"exact"` | every attr the JSON carries |
126
147
 
148
+ Both enabled levels also enforce the ProseMirror same-type self-exclusion rule on each node's marks.
149
+ The standard marks represented by marktip are self-exclusive, so a node cannot carry the same mark type twice — including two `link` marks with different destinations.
150
+ The conflicting mark is rejected with `InvalidNodeError` rather than being serialized into Markdown that reparses with different formatting or structure.
151
+ `strict="off"` skips this check because strict validation is disabled.
152
+
153
+ Both enabled levels reject a node or mark top-level key that its type does not declare (`unknown_field`), and enforce the following content models (`invalid_content`):
154
+
155
+ | Parent | Allowed children |
156
+ | --- | --- |
157
+ | `doc`, `blockquote`, `listItem`, `taskItem`, `tableCell`, `tableHeader` | block nodes |
158
+ | `paragraph`, `heading` | inline nodes (`text`, `hardBreak`, `image`, `htmlInline`) |
159
+ | `codeBlock` | unmarked `text` only |
160
+ | `bulletList` | `listItem` |
161
+ | `orderedList` | `listItem`, `taskItem` |
162
+ | `taskList` | `taskItem` |
163
+ | `table` | `tableRow` |
164
+ | `tableRow` | `tableHeader`, `tableCell` |
165
+ | `text`, `hardBreak`, `horizontalRule`, `image`, `htmlBlock`, `htmlInline` | none |
166
+
167
+ Block nodes are `paragraph`, `heading`, `blockquote`, `codeBlock`, `horizontalRule`, `bulletList`, `orderedList`, `taskList`, `table`, and `htmlBlock`.
168
+ A strict text node must carry a non-empty string `text` field.
169
+ This is marktip's canonical child grammar, not a verbatim copy of one editor's schema: in particular, ordered Markdown task items remain `orderedList` → `taskItem`, and empty parser-produced containers remain valid.
170
+ These rules prevent a nested block submitted inside a paragraph, content attached to a leaf, or an arbitrary child key from being silently flattened or omitted by the serializer.
171
+
172
+ > **Changed in 0.7.2** — `strict="content"` and `strict="exact"` now close node/mark top-level fields and per-node content models with `unknown_field` and `invalid_content`. `strict="off"` keeps the previous permissive converter behavior.
173
+
174
+ > **Changed in 0.7.1** — `strict="content"` and `strict="exact"` now reject duplicate same-type marks with `invalid_mark_set`. Markdown parsing collapses nested spans that map to the same self-exclusive mark, so parser output remains valid on the strict read path.
175
+
127
176
  The two levels differ over one thing, and it is worth being precise about which:
128
177
 
129
178
  ```python
@@ -227,15 +276,19 @@ For `from_markdown` it locates the node in the parsed document, since the input
227
276
  | `disallowed_scheme` | `InvalidNodeError` | a link `href` / image `src` scheme is outside the allowlist |
228
277
  | `disallowed_relative_url` | `InvalidNodeError` | a scheme-less `href`/`src` violates the relative policy |
229
278
  | `invalid_uri_char` | `InvalidNodeError` | an `href`/`src` contains an ASCII control character |
279
+ | `disallowed_node_type` | `InvalidNodeError` | a node type appears in `reject_node_types` |
280
+ | `unknown_field` | `InvalidNodeError` | `strict`: a node/mark top-level key is not defined for that type |
281
+ | `invalid_content` | `InvalidNodeError` | `strict`: a node violates its content model or text payload contract |
230
282
  | `unknown_attr` | `InvalidNodeError` | `strict`: the attr name is in neither dialect for that type |
231
283
  | `invalid_attr_value` | `InvalidNodeError` | `strict`: the attr's value has the wrong type or is out of range |
232
284
  | `unrepresentable` | `InvalidNodeError` | `strict`: the value is well-formed, but markdown cannot carry it |
233
285
  | `missing_attr` | `InvalidNodeError` | `strict`: a required attr is absent or `None` — a `link` with no `href`, an `image` with no `src` |
286
+ | `invalid_mark_set` | `InvalidNodeError` | `strict`: a node carries conflicting marks of the same type |
234
287
  | `markdown_max_depth` | `ParseError` | markdown nesting exceeds 2048 |
235
288
  | `parse_failed` | `ParseError` | MD4C could not parse the input |
236
289
 
237
290
  `from_markdown` still raises a plain `TypeError` when the argument is not `str`/`bytes` — that is a caller bug, not a malformed document.
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`.
291
+ So is a bad option value: a non-iterable `link_schemes` or `reject_node_types` raises `TypeError`, and `link_schemes=("https://",)`, `reject_node_types=("callout",)`, `link_relative="nope"` or `strict="strict"` raises `ValueError`.
239
292
  `strict` takes a level name, so `strict=True` raises `TypeError` rather than quietly meaning something.
240
293
 
241
294
  > **Changed in 0.4.0** — these were previously `ValueError` (`from_dict`) and `RuntimeError` (`from_markdown`).
@@ -267,9 +320,10 @@ It guarantees, for the whole tree:
267
320
  - **Depth** is at most 2048 levels.
268
321
  - **No ASCII control character** in a link `href` or image `src`, entity references included (`	`, `	`).
269
322
  - **The URI policy**, when `link_schemes`/`image_schemes`/`link_relative`/`image_relative` ask for it — see [Restricting link and image URIs](#restricting-link-and-image-uris).
323
+ - **The node-type policy**, when `reject_node_types` names a type — see [Rejecting node types](#rejecting-node-types).
270
324
 
271
325
  A document that survives `from_dict` always serializes; callers do not need to re-check any of the above.
272
- `from_markdown` enforces the same two URI rules on what it parses.
326
+ `from_markdown` enforces the same URI and rejected-node rules on what it parses.
273
327
 
274
328
  It deliberately does **not** validate, unless `strict` asks it to:
275
329
 
@@ -281,11 +335,18 @@ It deliberately does **not** validate, unless `strict` asks it to:
281
335
  A `heading` without `level` or a `codeBlock` without `language` is accepted; the serializer substitutes a default rather than failing.
282
336
  `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
337
  `{"src": None}` and no `src` key at all are the same thing to every part of the library, the URI policy included.
338
+ - **Mark sets.**
339
+ With strict validation disabled, two marks of the same type may appear on one node and are serialized independently.
340
+ `strict="content"` and `strict="exact"` reject the second mark because marktip's standard ProseMirror/Tiptap marks are self-exclusive.
341
+ - **Node and mark top-level fields.**
342
+ With strict validation disabled, a key the converter does not read is ignored.
343
+ Both enabled levels reject it with `unknown_field`, including `marks` on a block or `text` on a non-text node.
284
344
  - **Content models.**
285
- Which node may contain which is not checked — a `text` node directly under `doc` is accepted and serialized.
345
+ With strict validation disabled, which node may contain which is not checked — a `text` node directly under `doc` is accepted and serialized.
346
+ Both enabled levels enforce the content-model table above, the text payload shape, and the absence of marks inside a code block.
286
347
  - **Raw HTML.**
287
348
  The URI policy governs `link` marks and `image` nodes, not markup inside `htmlBlock`/`htmlInline`, so `<a href="javascript:...">` passes it.
288
- Pair the policy with `html=False` to close that.
349
+ Reject those node types with `reject_node_types=("htmlBlock", "htmlInline")`; on Markdown input, `html=False` is the alternative that retains the markup as literal text.
289
350
  - **URI syntax beyond the scheme.**
290
351
  Everything after the scheme is opaque, and the stored value is never rewritten — an `href` is checked in its entity-decoded form but stored exactly as given.
291
352
  Under `link_relative="allow"` a protocol-relative `//evil.com/x` also passes, since it carries no scheme; `"path_only"` is the setting that rejects it.
@@ -305,14 +366,16 @@ except tm.InvalidNodeError as e:
305
366
  ## Defined normalizations
306
367
 
307
368
  Markdown cannot represent every Tiptap document exactly.
308
- Rather than emitting markdown that reparses into a different structure, marktip applies these deterministic (and idempotent) normalizations at serialization time:
369
+ Rather than emitting or retaining a representation that changes on the next conversion, marktip applies these deterministic (and idempotent) normalizations during parsing and serialization:
309
370
 
371
+ - **NUL in content strings** — U+0000 in text or a non-URI string attr (`alt`, `title`, `language`, `html`, etc.) becomes U+FFFD. Markdown input is replaced once before tokenization, including inline/fenced/indented code and raw HTML, so reparsing cannot retain a NUL or accumulate replacement characters. On dict input, `link.href` and `image.src` are excluded and retain their unconditional `invalid_uri_char` rejection.
310
372
  - **Hard breaks in headings** — ATX headings are single-line, so a `hardBreak` (or a literal newline carried over from setext input) inside a heading serializes as a single space: `heading("a", hardBreak, "b")` → `# a b`.
311
373
  - **Multi-block table cells** — blocks inside a cell are joined with `<br>` and the cell is flattened to one line; two paragraphs in a cell reparse as one paragraph containing a `hardBreak`.
312
374
  - **Headerless tables** — GFM tables require a header row, so the first row is always emitted as the header; a leading `tableCell` row reparses as `tableHeader`.
313
375
  - **Heading levels** — clamped to 1–6 at serialization (`0` → `#`, `7` → `######`).
314
376
  - **Ordered list start** — clamped to CommonMark's 0–999999999 (`-5` → `0.`), and the running number stops at that ceiling rather than emitting a 10-digit marker. Only the first number is honoured on reparse, so a repeated ceiling changes nothing.
315
377
  - **Code fence info strings** — a `language` is truncated at the first newline, since an info string is a single line; one containing a backtick switches the fence to `~~~`, which carries it losslessly.
378
+ - **Nested same-type marks** — Markdown spans that map to the same self-exclusive mark are collapsed (`*outer _inner_ outer*` becomes one continuous `italic` mark) rather than producing an invalid ProseMirror mark set.
316
379
  - **Emphasis boundary whitespace** — whitespace touching an emphasis delimiter has no valid markdown form and is expelled outside the marks (`bold("굵게 ")` → `**굵게** `), cf. prosemirror-markdown's `expelEnclosingWhitespace`.
317
380
  - **Adjacent same-family lists** — consecutive lists of the same family alternate markers (`-`/`*`, `1.`/`1)`) so they stay separate lists on reparse instead of merging (which would renumber ordered items or spread task checkboxes).
318
381
 
@@ -76,9 +76,30 @@ doc = tm.from_markdown(untrusted, link_schemes=("https",), image_relative="rejec
76
76
  Violations raise `InvalidNodeError` with `.field` set to `"href"` or `"src"`.
77
77
  The options are keyword-only.
78
78
 
79
+ ### Rejecting node types
80
+
81
+ marktip's schema includes every node it can serialize, but an application may use a smaller ProseMirror dialect.
82
+ Both write boundaries accept `reject_node_types`, so that dialect can be enforced after either Markdown parsing or dict conversion without a second application-side tree walk:
83
+
84
+ ```python
85
+ NO_RAW_HTML = ("htmlBlock", "htmlInline")
86
+
87
+ doc = tm.from_dict(editor_json, reject_node_types=NO_RAW_HTML)
88
+ doc = tm.from_markdown(imported_markdown, reject_node_types=NO_RAW_HTML)
89
+ ```
90
+
91
+ `None` (the default) rejects nothing; an empty iterable has the same effect.
92
+ Every entry must name a node type marktip knows, and matching is exact and case-sensitive.
93
+ A bare string or a non-string entry raises `TypeError`; an unknown node name raises `ValueError`.
94
+ A document containing a configured type raises `InvalidNodeError` with `.code == "disallowed_node_type"`, `.field == "type"`, and `.path` locating the node.
95
+ The option is keyword-only.
96
+
97
+ This differs from `html=False`: `html=False` preserves raw markup as escaped literal text on Markdown input, while rejecting `htmlBlock`/`htmlInline` refuses markup that parsed as a raw-HTML node.
98
+ `reject_node_types` also works for dict input, where there is no parser flag.
99
+
79
100
  ### Refusing lossy conversions
80
101
 
81
- Node and mark *types* are closed, but `attrs` are not.
102
+ Node and mark *types* are always closed, but fields, attrs and content models are only closed when `strict` is enabled.
82
103
  An attr the serializer never reads is dropped without a word, so a `colspan: 2` cell quietly becomes a plain one:
83
104
 
84
105
  ```python
@@ -93,9 +114,37 @@ It is keyword-only and a `from_dict` option only — the parser emits nothing bu
93
114
  | `strict` | Keeps |
94
115
  | --- | --- |
95
116
  | `"off"` (default) | nothing is checked |
96
- | `"content"` | content and structure. Presentation an editor stamped on is type-checked and dropped |
117
+ | `"content"` | content and structure, including closed node fields and content models. Presentation an editor stamped on is type-checked and dropped |
97
118
  | `"exact"` | every attr the JSON carries |
98
119
 
120
+ Both enabled levels also enforce the ProseMirror same-type self-exclusion rule on each node's marks.
121
+ The standard marks represented by marktip are self-exclusive, so a node cannot carry the same mark type twice — including two `link` marks with different destinations.
122
+ The conflicting mark is rejected with `InvalidNodeError` rather than being serialized into Markdown that reparses with different formatting or structure.
123
+ `strict="off"` skips this check because strict validation is disabled.
124
+
125
+ Both enabled levels reject a node or mark top-level key that its type does not declare (`unknown_field`), and enforce the following content models (`invalid_content`):
126
+
127
+ | Parent | Allowed children |
128
+ | --- | --- |
129
+ | `doc`, `blockquote`, `listItem`, `taskItem`, `tableCell`, `tableHeader` | block nodes |
130
+ | `paragraph`, `heading` | inline nodes (`text`, `hardBreak`, `image`, `htmlInline`) |
131
+ | `codeBlock` | unmarked `text` only |
132
+ | `bulletList` | `listItem` |
133
+ | `orderedList` | `listItem`, `taskItem` |
134
+ | `taskList` | `taskItem` |
135
+ | `table` | `tableRow` |
136
+ | `tableRow` | `tableHeader`, `tableCell` |
137
+ | `text`, `hardBreak`, `horizontalRule`, `image`, `htmlBlock`, `htmlInline` | none |
138
+
139
+ Block nodes are `paragraph`, `heading`, `blockquote`, `codeBlock`, `horizontalRule`, `bulletList`, `orderedList`, `taskList`, `table`, and `htmlBlock`.
140
+ A strict text node must carry a non-empty string `text` field.
141
+ This is marktip's canonical child grammar, not a verbatim copy of one editor's schema: in particular, ordered Markdown task items remain `orderedList` → `taskItem`, and empty parser-produced containers remain valid.
142
+ These rules prevent a nested block submitted inside a paragraph, content attached to a leaf, or an arbitrary child key from being silently flattened or omitted by the serializer.
143
+
144
+ > **Changed in 0.7.2** — `strict="content"` and `strict="exact"` now close node/mark top-level fields and per-node content models with `unknown_field` and `invalid_content`. `strict="off"` keeps the previous permissive converter behavior.
145
+
146
+ > **Changed in 0.7.1** — `strict="content"` and `strict="exact"` now reject duplicate same-type marks with `invalid_mark_set`. Markdown parsing collapses nested spans that map to the same self-exclusive mark, so parser output remains valid on the strict read path.
147
+
99
148
  The two levels differ over one thing, and it is worth being precise about which:
100
149
 
101
150
  ```python
@@ -199,15 +248,19 @@ For `from_markdown` it locates the node in the parsed document, since the input
199
248
  | `disallowed_scheme` | `InvalidNodeError` | a link `href` / image `src` scheme is outside the allowlist |
200
249
  | `disallowed_relative_url` | `InvalidNodeError` | a scheme-less `href`/`src` violates the relative policy |
201
250
  | `invalid_uri_char` | `InvalidNodeError` | an `href`/`src` contains an ASCII control character |
251
+ | `disallowed_node_type` | `InvalidNodeError` | a node type appears in `reject_node_types` |
252
+ | `unknown_field` | `InvalidNodeError` | `strict`: a node/mark top-level key is not defined for that type |
253
+ | `invalid_content` | `InvalidNodeError` | `strict`: a node violates its content model or text payload contract |
202
254
  | `unknown_attr` | `InvalidNodeError` | `strict`: the attr name is in neither dialect for that type |
203
255
  | `invalid_attr_value` | `InvalidNodeError` | `strict`: the attr's value has the wrong type or is out of range |
204
256
  | `unrepresentable` | `InvalidNodeError` | `strict`: the value is well-formed, but markdown cannot carry it |
205
257
  | `missing_attr` | `InvalidNodeError` | `strict`: a required attr is absent or `None` — a `link` with no `href`, an `image` with no `src` |
258
+ | `invalid_mark_set` | `InvalidNodeError` | `strict`: a node carries conflicting marks of the same type |
206
259
  | `markdown_max_depth` | `ParseError` | markdown nesting exceeds 2048 |
207
260
  | `parse_failed` | `ParseError` | MD4C could not parse the input |
208
261
 
209
262
  `from_markdown` still raises a plain `TypeError` when the argument is not `str`/`bytes` — that is a caller bug, not a malformed document.
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`.
263
+ So is a bad option value: a non-iterable `link_schemes` or `reject_node_types` raises `TypeError`, and `link_schemes=("https://",)`, `reject_node_types=("callout",)`, `link_relative="nope"` or `strict="strict"` raises `ValueError`.
211
264
  `strict` takes a level name, so `strict=True` raises `TypeError` rather than quietly meaning something.
212
265
 
213
266
  > **Changed in 0.4.0** — these were previously `ValueError` (`from_dict`) and `RuntimeError` (`from_markdown`).
@@ -239,9 +292,10 @@ It guarantees, for the whole tree:
239
292
  - **Depth** is at most 2048 levels.
240
293
  - **No ASCII control character** in a link `href` or image `src`, entity references included (`&Tab;`, `&#09;`).
241
294
  - **The URI policy**, when `link_schemes`/`image_schemes`/`link_relative`/`image_relative` ask for it — see [Restricting link and image URIs](#restricting-link-and-image-uris).
295
+ - **The node-type policy**, when `reject_node_types` names a type — see [Rejecting node types](#rejecting-node-types).
242
296
 
243
297
  A document that survives `from_dict` always serializes; callers do not need to re-check any of the above.
244
- `from_markdown` enforces the same two URI rules on what it parses.
298
+ `from_markdown` enforces the same URI and rejected-node rules on what it parses.
245
299
 
246
300
  It deliberately does **not** validate, unless `strict` asks it to:
247
301
 
@@ -253,11 +307,18 @@ It deliberately does **not** validate, unless `strict` asks it to:
253
307
  A `heading` without `level` or a `codeBlock` without `language` is accepted; the serializer substitutes a default rather than failing.
254
308
  `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
309
  `{"src": None}` and no `src` key at all are the same thing to every part of the library, the URI policy included.
310
+ - **Mark sets.**
311
+ With strict validation disabled, two marks of the same type may appear on one node and are serialized independently.
312
+ `strict="content"` and `strict="exact"` reject the second mark because marktip's standard ProseMirror/Tiptap marks are self-exclusive.
313
+ - **Node and mark top-level fields.**
314
+ With strict validation disabled, a key the converter does not read is ignored.
315
+ Both enabled levels reject it with `unknown_field`, including `marks` on a block or `text` on a non-text node.
256
316
  - **Content models.**
257
- Which node may contain which is not checked — a `text` node directly under `doc` is accepted and serialized.
317
+ With strict validation disabled, which node may contain which is not checked — a `text` node directly under `doc` is accepted and serialized.
318
+ Both enabled levels enforce the content-model table above, the text payload shape, and the absence of marks inside a code block.
258
319
  - **Raw HTML.**
259
320
  The URI policy governs `link` marks and `image` nodes, not markup inside `htmlBlock`/`htmlInline`, so `<a href="javascript:...">` passes it.
260
- Pair the policy with `html=False` to close that.
321
+ Reject those node types with `reject_node_types=("htmlBlock", "htmlInline")`; on Markdown input, `html=False` is the alternative that retains the markup as literal text.
261
322
  - **URI syntax beyond the scheme.**
262
323
  Everything after the scheme is opaque, and the stored value is never rewritten — an `href` is checked in its entity-decoded form but stored exactly as given.
263
324
  Under `link_relative="allow"` a protocol-relative `//evil.com/x` also passes, since it carries no scheme; `"path_only"` is the setting that rejects it.
@@ -277,14 +338,16 @@ except tm.InvalidNodeError as e:
277
338
  ## Defined normalizations
278
339
 
279
340
  Markdown cannot represent every Tiptap document exactly.
280
- Rather than emitting markdown that reparses into a different structure, marktip applies these deterministic (and idempotent) normalizations at serialization time:
341
+ Rather than emitting or retaining a representation that changes on the next conversion, marktip applies these deterministic (and idempotent) normalizations during parsing and serialization:
281
342
 
343
+ - **NUL in content strings** — U+0000 in text or a non-URI string attr (`alt`, `title`, `language`, `html`, etc.) becomes U+FFFD. Markdown input is replaced once before tokenization, including inline/fenced/indented code and raw HTML, so reparsing cannot retain a NUL or accumulate replacement characters. On dict input, `link.href` and `image.src` are excluded and retain their unconditional `invalid_uri_char` rejection.
282
344
  - **Hard breaks in headings** — ATX headings are single-line, so a `hardBreak` (or a literal newline carried over from setext input) inside a heading serializes as a single space: `heading("a", hardBreak, "b")` → `# a b`.
283
345
  - **Multi-block table cells** — blocks inside a cell are joined with `<br>` and the cell is flattened to one line; two paragraphs in a cell reparse as one paragraph containing a `hardBreak`.
284
346
  - **Headerless tables** — GFM tables require a header row, so the first row is always emitted as the header; a leading `tableCell` row reparses as `tableHeader`.
285
347
  - **Heading levels** — clamped to 1–6 at serialization (`0` → `#`, `7` → `######`).
286
348
  - **Ordered list start** — clamped to CommonMark's 0–999999999 (`-5` → `0.`), and the running number stops at that ceiling rather than emitting a 10-digit marker. Only the first number is honoured on reparse, so a repeated ceiling changes nothing.
287
349
  - **Code fence info strings** — a `language` is truncated at the first newline, since an info string is a single line; one containing a backtick switches the fence to `~~~`, which carries it losslessly.
350
+ - **Nested same-type marks** — Markdown spans that map to the same self-exclusive mark are collapsed (`*outer _inner_ outer*` becomes one continuous `italic` mark) rather than producing an invalid ProseMirror mark set.
288
351
  - **Emphasis boundary whitespace** — whitespace touching an emphasis delimiter has no valid markdown form and is expelled outside the marks (`bold("굵게 ")` → `**굵게** `), cf. prosemirror-markdown's `expelEnclosingWhitespace`.
289
352
  - **Adjacent same-family lists** — consecutive lists of the same family alternate markers (`-`/`*`, `1.`/`1)`) so they stay separate lists on reparse instead of merging (which would renumber ordered items or spread task checkboxes).
290
353
 
@@ -4,7 +4,7 @@ build-backend = "scikit_build_core.build"
4
4
 
5
5
  [project]
6
6
  name = "marktip"
7
- version = "0.7.0"
7
+ version = "0.7.2"
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"