Skip to content

Conversation

@EmmanuelBerkowicz
Copy link

feat: handle uniform and mixed text formatting in textFormatter

  • Add separate logic paths for uniform vs mixed formatting
  • Process uniform styling from base node style properties
  • Process mixed formatting using StyleOverrides + StyleTable
  • Fix fontWeight detection to check > 400 threshold
image

**New file: textFormatter.ts**
- Implements text formatting logic for Figma text nodes
- Handles varying font weight, font styles, and text decoration
- Processes StyleOverrideTable and CharacterStyleOverrides data
- Groups consecutive characters with identical styling into HTML spans

**Updated: simplify-node-response.ts**
- Integrated textFormatter.ts into text processing pipeline
- Added import and function call for buildSimplifiedText

**Current limitations:**
- Takes base style from first character of paragraph
- Mixed formatting within single lines not fully working
- Style comparison/grouping logic needs refinement

**Progress toward fixing issue GLips#140**
- Successfully parses Figma's character-level style override data
- Generates HTML spans with inline CSS styles
- Works for uniform styling (all bold, all italic, etc.)
- Foundation in place for complete mixed formatting support
**New file: textFormatter.ts**
- Implements text formatting logic for Figma text nodes
- Handles varying font weight, font styles, and text decoration
- Processes StyleOverrideTable and CharacterStyleOverrides data
- Groups consecutive characters with identical styling into HTML spans

**Updated: simplify-node-response.ts**
- Integrated textFormatter.ts into text processing pipeline
- Added import and function call for buildSimplifiedText

**Current limitations:**
- Takes base style from first character of paragraph
- Mixed formatting within single lines not fully working
- Style comparison/grouping logic needs refinement

**Progress toward fixing issue GLips#140**
- Successfully parses Figma's character-level style override data
- Generates HTML spans with inline CSS styles
- Works for uniform styling (all bold, all italic, etc.)
- Foundation in place for complete mixed formatting support
feat: handle uniform and mixed text formatting in textFormatter

- Add separate logic paths for uniform vs mixed formatting
- Process uniform styling from base node style properties
- Process mixed formatting using StyleOverrides + StyleTable
- Fix fontWeight detection to check > 400 threshold
@EmmanuelBerkowicz
Copy link
Author

Hi @GLips ,
I've created a pull request which I think is a descent start to the open issue.
When it comes to plane text it works well (ref attached image of output from the modified code).
Let me know if you have any feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant