Skip to content

Markdown code blocks render as inline code instead of code blocks #145

@moltar

Description

@moltar

Problem

When posting messages with content_type: "text/markdown", multiline fenced code blocks are incorrectly rendered as separate inline code snippets instead of a single code block.

Example

Input markdown:

```
foo
bar
```

Expected: A single multiline code block in Slack

Actual: Two separate inline code snippets: foo bar

Root Cause

The upstream library github.com/takara2314/slack-go-util (v0.2.0) incorrectly converts fenced code blocks.

  • Current behavior: Uses RichTextSection with style: {code: true} which creates inline code formatting
  • Correct behavior: Should use RichTextPreformatted which creates proper preformatted code blocks

Location in this codebase

pkg/handler/conversations.go:174:

blocks, err := slackGoUtil.ConvertMarkdownTextToBlocks(params.text)

Fix

PR submitted to upstream: takara2314/slack-go-util#1

Workaround

Until the upstream fix is merged and a new version released, users can:

  1. Use content_type: "text/plain" and format code blocks manually using Slack's mrkdwn syntax
  2. Or pin to a fork with the fix applied

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions