Skip to main content

normalize_description

Function normalize_description 

Source
pub fn normalize_description(v: &Value) -> Result<String, String>
Expand description

Accept a description written either way, and bound it — the write-time gate every card-writing path funnels through.

Two input shapes, one stored value. A description is now allowed to be Markdown, and Markdown needs line breaks, which a JSON string can only carry as \n escapes — miserable to hand-write and worse to review. So a card file may also give an array of lines, joined with \n:

"description": ["# What's inside", "", "- 4.4M classes", "- 5.1M edges"]

The array is input sugar only: the card always stores one string, so a card round-trips through rete card --json → --card-file unchanged, and no reader ever has to know the array shape existed.

On overflow the build is rejected loudly, never truncated — the same rule as extra, for the same reason: the text is authored, it folds into the content hash, and a silent cut would ship a card that no longer says what the publisher wrote.