anyproto / anyproto/anytype-api
`[Bug] Local API: Markdown Serialization is "Mention-Blind" and causes formatting shifts on UTF-8 characters`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 113
- Forks
- 20
- Avg merge
- 16m
- Merged PRs (30d)
- 1
Description
Have you read a contributing guide?
- I have read CONTRIBUTING.md
- I have searched the existing issues and didn't find any that were similar
- I have considered creating a pull request with fixes instead of a bug report and want to proceed
Current Behavior
The Local API (v1) markdown serialization/deserialization layer is currently lossy and destructive for native AnyType features. Through 18+ different trial-and-error experiments with markdown/HTML syntax, we have confirmed that it is impossible to create or preserve a native "Avatar Relation" (Mention) via the API's markdown body.
1. Mention-Blindness (Lossy Export/Import):
- When an object containing a native Relation Mention is exported via
GET ...?format=md, it is returned as a naked markdown link:[Name](anytype://object?...). Crucial metadata (the "Mention" flag and Avatar icon) is stripped. - When sending markdown back via
PATCHorPOST, any attempt to trigger a native mention (using[@Name],[[ID]],<@ID>, or even HTML span tags with data-attributes) fails. Every variation is rendered as a standard blue underlined web link, losing the native Relation UI.
2. Formatting Offset Shifts on UTF-8:
- When a text block contains multi-byte characters (e.g., Turkish
ğ, ş, ı, ö), inline formatting tags (**,*) physically shift to the right during aPATCHoperation. - Example:
**Görsel:**often becomesG**örsel:**or similar corrupted offsets after a round-trip, rendering the markdown layer unusable for automated text processing in non-English languages.
Expected Behavior
- The Markdown parser should recognize a specific syntax (e.g.,
[@Name](anytype://...)) to regenerate native Mentions during a PATCH. - Formatting offsets should be calculated based on character length/UTF-8 boundaries rather than raw byte offsets.
- Priority Request: Expose
format=blocks(JSON block array) to allow safe, non-lossy manipulation of object content without relying on the flawed markdown parser.
Steps To Reproduce
- Create a native mention in AnyType.
- Fetch markdown via API: Observe the stripped link.
- Patch the same markdown back: Observe the permanent downgrade to a standard link.
- Patch formatted text with Turkish characters: Observe the corrupted bold/italic positions.
Environment
- OS: Windows 10
- Version: 0.54.9
Anything else?
This "mention-blindness" effectively makes it impossible to build automation scripts for cross-linking objects (e.g., automatically mentioning characters in book chapters) while maintaining AnyType's premium UI look and feel.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the Local API (v1) markdown serialization/deserialization layer and reproduce the mention round trip and UTF-8 formatting-offset behavior described in the issue. Done would require preserving native mentions, keeping formatting positions correct for multi-byte characters, and determining whether a non-lossy blocks representation can be exposed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100