mirror of
https://github.com/storytold/pdfcraft.git
synced 2026-11-10 13:01:29 +00:00
form_fill turned a JSON number for a radio group into text with
Number::to_string, which spells a float with a fraction part: 1.0, 1e0
and 0.1e1 became "1.0", and serde_json parses -0 as the float -0.0
("-0.0"). None names the option "1". number_option now spells a whole
number below 2^53 as that integer (1.0 -> "1", -0 -> "0"); integers keep
their exact spelling; any other number keeps JSON's spelling (1.5,
1e300), so it names only an option exported as exactly that text, and is
otherwise refused with the options listed.
The precedence when an on-state name equals another button's export
value (export value first, then on-state names; ISO 32000-2 Table 230
lets state names be positions) is now stated in state_for_export, at the
call site and in form_fill's tool description, with the number rules.
Test (fails with Number::to_string restored): the ambiguous pair (the
first button exports "1", the second's state is /1) filled with 1, 1.0,
1e0, 0.1e1, "1", -0, 2e0, 2.000 and 3.0 selects the right button; "1.0",
1.5, -1, 1e300, u64::MAX and 9007199254740993.0 are refused with the
options listed and the selection kept.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Pq7HyCfwzyRXj4VfQAVVdv