Skip to content

feat(docs): add --link and --no-link to docs format #684

@sebsnyk

Description

@sebsnyk

Motivation

gog docs format --match "X" --bold --italic works today; the missing --link <url> is the same shape (UpdateTextStyle with textStyle.link, fields=link). The brace DSL in gog docs sed ({u=https://...}) covers it, but users discovering format first reasonably expect a flag.

Verified against current source: DocsFormatFlags in internal/cmd/docs_format.go enumerates bold/italic/underline/strike/font-family/font-size/text-color/bg-color/alignment/line-spacing/heading-level/named-style — no link.

Repro

# Today, no --link on format:
gog docs format <DOC_ID> --match "click here" --link "https://example.com"
# error: unknown long flag '--link'

# Workaround:
gog docs sed <DOC_ID> 's/click here/{u=https:\/\/example.com}click here/'
# Works but requires escaping forward slashes; awkward for URLs.

Proposed surface

gog docs format <docId> --match <text> [--match-all] [--match-case]
  --link <url>     Wrap match in a hyperlink. Accepts http://, https://, mailto:, #bookmarkId, #headingId
  --no-link        Remove any existing hyperlink on the match range

Acceptance criteria

  • --link https://... emits one UpdateTextStyle request with textStyle.link.url and fields=link.
  • --link #heading-slug resolves the slug against doc headings (same code path as the existing [text](#slug) markdown anchor resolver, Drive markdown converter: resolve [text](#slug) to heading IDs instead of leaving raw fragment #633) and writes textStyle.link.headingId.
  • --link mailto:foo@bar.com writes a mailto link (separate from the Person-chip path).
  • --no-link clears the link by setting textStyle.link=null and fields=link.
  • --link and --no-link are mutually exclusive.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low-risk cleanup, docs, polish, ergonomics, or speculative feature.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:otherThis issue has meaningful maintainer-visible impact outside the owned taxonomy.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions