Proposal: get_paragraph_metadata — expose a paragraph's style model (named style + direct overrides) #322
Replies: 2 comments 5 replies
-
|
Hello! Great to see your new idea! You found a significant problem and I appreciate your suggestion, and it's a good one to talk about. I thought about it for a bit and think it's cleaner and simpler to return good data to the LLMs, including the styles and stripping out the properties already set by the style. I'd do it by hand if we have to, but I discovered there's a far simpler way, we can get LO to do the work for us! Check out this document, strategy 1. https://github.com/KeithCu/writeragent/blob/master/docs/html_style_model_plan.md What do you think about it? If you like it, do you want to implement it and send me the PR? Regards, -Keith |
Beta Was this translation helpful? Give feedback.
-
|
okay this PR is in, I'll close this discussion. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Proposal:
get_paragraph_metadata— expose a paragraph's style model (named style + direct overrides)I've already implemented and tested this on a branch (UNO regression tests pass, gate clean). If you're happy with the approach, I'll open the PR.
What
A read-only tool,
get_paragraph_metadata, returning a paragraph's named style plus, per run, theChar*properties that differ from thatstyle's default (a heuristic for hand-set overrides):
{ "para_style_name": "Caption", "runs": [{ "text": "Figure 1", "char_properties_differing_from_style": { "CharColor": 16711680, "CharPosture": "ITALIC" } }] }Where
plugin/writer/content.py— the tool (tier="core", read-only).plugin/writer/format.py— shared helperchar_overrides_for_portion, extracted fromapply_paragraph_style_preserving_direct_charso the write pathand this read tool share one detection (no duplication).
tests/writer/test_get_paragraph_metadata_uno.py,docs/llm-styles.md.Problem it solves
get_document_contentflattens to HTML with computed inline styles — it hides the named style and the origin of each property. The agent seesfont-size:10pt; italicbut can't tell it's theCaptionstyle, nor whether the italic is hand-set. So it can't replicate formatting faithfully.Why it fits "the agent should use named styles"
It's what enables that: today the agent is blind to styles (HTML hides them), which pushes it to copy raw direct formatting. This surfaces the style name first (overrides as the residual), so the agent can read "it's
Caption" and reapply that style viaapply_style. It's the read-side complement to the styles-first approach.Beta Was this translation helpful? Give feedback.
All reactions