
Research
Security News
The Landscape of Malicious Open Source Packages: 2025 Mid‑Year Threat Report
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
markdown-flex-message
Advanced tools
markdown-flex-message is a converter that transforms Markdown into Flex Message for the LINE Messaging API.
markdown-flex-message is a converter that transforms Markdown into Flex Message for the LINE Messaging API.
npm install markdown-flex-message --save
Convert the markdown to a Flex Message.
import { convertToFlexMessage } from 'markdown-flex-message'
import * as line from '@line/bot-sdk'
const markdownText = `
# Fruits
* apple
* banana
* cherry
`.trim()
convertToFlexMessage(markdownText)
.then(({ flexMessage }) => {
const client = new line.messagingApi.MessagingApiClient({
channelAccessToken: '{{YOUR_CHANNEL_ACCESS_TOKEN}}'
})
return client.pushMessage({
to: '{{YOUR_USER_ID}}',
messages: [flexMessage]
})
})
.then(() => {
console.log('sent.')
})
If an alternative text is not specified, it becomes the first 100 characters of the Markdown text
The default size of the Flex message bubble is giga
.
To set custom alternative text and set the bubble size to mega, use the following code.
import { convertToFlexMessage } from 'markdown-flex-message'
import * as line from '@line/bot-sdk'
const markdownText = `
# Fruits
* apple
* banana
* cherry
`.trim()
convertToFlexMessage(markdownText, { altText: 'Fruits', size: 'mega' })
.then(({ flexMessage }) => {
const client = new line.messagingApi.MessagingApiClient({
channelAccessToken: '{{YOUR_CHANNEL_ACCESS_TOKEN}}'
})
return client.pushMessage({
to: '{{YOUR_USER_ID}}',
messages: [flexMessage]
})
})
The alternative text is Fruits
.
The size of the Flex message bubble is set to mega
.
markdown-flex-message
also supports the display of code.
import { convertToFlexMessage } from 'markdown-flex-message'
import * as line from '@line/bot-sdk'
const markdownText =
[
'```typescript ',
'const add = (a:number, b:number): number => { ',
' return a + b ',
'} ',
'``` '
].join("\n")
convertToFlexMessage(markdownText, { altText: 'Typescript sample' })
.then(({ flexMessage, textType }) => {
console.log(textType) // => "code"
const client = new line.messagingApi.MessagingApiClient({
channelAccessToken: '{{YOUR_CHANNEL_ACCESS_TOKEN}}'
})
return client.pushMessage({
to: '{{YOUR_USER_ID}}',
messages: [flexMessage]
})
})
You can convert Markdown into a Flex Bubble, which allows you to use Markdown as part of a carousel.
import { convertToFlexBubble } from 'markdown-flex-message'
import * as line from '@line/bot-sdk'
const markdownText = `
# Fruits
* apple
* banana
* cherry
`.trim()
convertToFlexBubble(markdownText, { size: 'micro' })
.then(({ flexBubble }) => {
const message = {
type: "flex",
altText: 'Fruits',
contents: {
type: 'carousel',
contents: [
flexBubble,
{
type: "bubble",
size: "micro",
body: {
type: "box",
layout: "vertical",
justifyContent: "center",
contents: [
{
type: "button",
action: {
type: "uri",
label: "Show more",
uri: "http://linecorp.com/"
}
}
]
}
}
]
}
}
const client = new line.messagingApi.MessagingApiClient({
channelAccessToken: '{{YOUR_CHANNEL_ACCESS_TOKEN}}'
})
return client.pushMessage({
to: '{{YOUR_USER_ID}}',
messages: [message]
})
})
Markdown is applied as part of the carousel.
You can convert Markdown into a Flex Box. This allows you to use Markdown as part of a Flex Bubble.
import { convertToFlexBox } from 'markdown-flex-message'
import * as line from '@line/bot-sdk'
const markdownText = `
# Fruits
* apple
* banana
* cherry
`.trim()
convertToFlexBox(markdownText)
.then(({ flexBox }) => {
const message = {
type: "flex",
altText: markdownText.slice(0, 200),
contents: {
type: "bubble",
size: 'mega',
body: {
type: "box",
layout: "vertical",
contents: [
flexBox,
{
type: "button",
action: {
type: 'clipboard',
label: 'Copy',
clipboardText: markdownText.slice(0, 1000),
}
}
]
}
}
}
const client = new line.messagingApi.MessagingApiClient({
channelAccessToken: '{{YOUR_CHANNEL_ACCESS_TOKEN}}'
})
return client.pushMessage({
to: '{{YOUR_USER_ID}}',
messages: [message]
})
})
A button is positioned below the Markdown.
Convert the markdown to a Flex Message.
Parameters
nano
, micro
, deca
, hecto
, kilo
, mega
, giga
. The default value is giga
.Return Value
markdown
. If it contains only code, it returns code
, and for content without markdown elements, it returns plain
.convertToFlexMessage(
markdown: string,
options: ConvertOptions = {}
): Promise<{flexMessage: FlexMessage, textType: TextType}>
Convert the markdown to a Flex Message.
Parameters
nano
, micro
, deca
, hecto
, kilo
, mega
, giga
. The default value is giga
.Return Value
markdown
. If it contains only code, it returns code
, and for content without markdown elements, it returns plain
.convertToFlexBubble(markdown: string, options: ConvertOptions = {}):
Promise<{flexBubble: FlexBubble, textType: TextType}>
Convert the markdown to a Flex Message.
Parameters
Return Value
markdown
. If it contains only code, it returns code
, and for content without markdown elements, it returns plain
.convertToFlexBox(markdown: string): Promise<{ flexBox: FlexBox, textType: TextType }>
FAQs
markdown-flex-message is a converter that transforms Markdown into Flex Message for the LINE Messaging API.
The npm package markdown-flex-message receives a total of 165 weekly downloads. As such, markdown-flex-message popularity was classified as not popular.
We found that markdown-flex-message demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A look at the top trends in how threat actors are weaponizing open source packages to deliver malware and persist across the software supply chain.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.