feat: parse rich smart chips (person, date, rich link) in Google Docs - #263
Conversation
Currently docs.getText skip over smart chip elements within Google docs. Leaving out information. This commit adds support to render smart chip elements in google docs to simple text
Adds smart chip parsing to the DocsService getText method, rendering: - Person chips as markdown mailto links with name fallback to email - Rich link chips as markdown links with title fallback to URI - Date chips as displayText with fallback to timestamp Based on PR #215 by @MrwanBaghdad. Fixes reviewed items: - Rich link title fallback bug (title || uri) - Missing rich link fallback test - Refactored fallback tests to it.each - Prettier formatting applied Co-authored-by: MrwanBaghdad <marwan.nabil@deliveryhero.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request enhances the getText method in DocsService to parse rich smart chips for persons, dates, and links. However, the current implementation is vulnerable to markdown injection due to direct concatenation of user-controlled strings into markdown link structures without proper escaping, which could be exploited for phishing attacks. Additionally, there are edge cases where missing email (for person chips) or uri (for rich link chips) properties can result in malformed markdown output.
- Person chips: guard against missing email, fall back to name only - Rich link chips: guard against missing uri, fall back to title only - Added 2 new it.each test cases for these edge cases Addresses review feedback from Gemini Code Assist on PR #263
abhipatel12
left a comment
There was a problem hiding this comment.
Approved. 2 nits on readability, but non-blocking!
- Extract _renderPersonChip, _renderRichLinkChip, _renderDateChip from _readStructuralElement for cleaner dispatch logic - Add mockDocWithElements test helper to reduce mock boilerplate Addresses readability nits from @abhipatel12 on PR #263
Adds smart chip parsing to the DocsService
getTextmethod, correctly rendering person, date, and rich link chips as readable text/markdown.Changes
DocsService.ts—_readStructuralElementnow handles:[Name](mailto:email)with fallback to email when name is missing[Title](uri)with fallback to URI when title is missingdisplayTextwith fallback to timestampDocsService.test.ts— Added tests for:it.each(person → email, rich link → URI, date → timestamp)Review Items Addressed (from PR #215)
title || urifallback bug fixedit.eachCloses #215
Co-authored-by: MrwanBaghdad marwan.nabil@deliveryhero.com