diff --git a/docs.json b/docs.json index f5c6e150..135712d8 100644 --- a/docs.json +++ b/docs.json @@ -252,7 +252,8 @@ { "group": "Basic", "pages": [ - "en/workshop/basic/build-ai-image-generation-app" + "en/workshop/basic/build-ai-image-generation-app", + "en/workshop/basic/the-right-way-of-markdown" ] }, { diff --git a/en/workshop/basic/the-right-way-of-markdown.mdx b/en/workshop/basic/the-right-way-of-markdown.mdx new file mode 100644 index 00000000..bbf55dca --- /dev/null +++ b/en/workshop/basic/the-right-way-of-markdown.mdx @@ -0,0 +1,170 @@ +--- +title: The Right Way of Markdown +--- + +> Author: Li Zheng, Dify DevRel + +In this article, we will introduce the right way of using markdown in Dify. Markdown is a lightweight markup language that allows you to format text using simple syntax. It is widely used for writing documentation, articles, and other text-based content. + +## Basic Markdown Syntax in Dify + +We support most of the usage of markdown syntax, for example: + +- Heading +- Bold and Italic text, strike-through text +- Lists +- Table +- Fenced Code Blocks + + +If you want to learn more about markdown syntax, you can refer to the [Markdown Guide](https://www.markdownguide.org/basic-syntax/), if you want to extend it's capabilities, you can also check out the [React Markdown](https://github.com/remarkjs/react-markdown). + + +## Advanced Markdown Features in Dify + +### Button & Links + +You might not be happy with the default follow-up questions generated by the LLM. In this case, you can use buttons and links to guide the conversation in a specific direction. + + + +You can use the following syntax to create buttons and links: + +``` + + +``` + +For buttons, we need to define two attributes `data-variant` and `data-message`. + +- `data-variant`: The style of the button, can be `primary`, `secondary`, `warning`, 'secondary-accent', 'ghost', 'ghost-accent', 'tertiary'. +- `data-message`: The message that will be sent when the button is clicked. + +For links, it's more straightforward: + +``` +Dify +``` + +Or you can use the `abbr` syntax to create an abbreviation link, this is useful for create interactive links that can be used in the conversation: + +``` +[Special Link](abbr:special-link) +``` + +### Form + +For forms, we need to define the `data-format` attribute, which can be `json` or `text`. If not specified, it defaults to `text`. The form will be submitted as a JSON object if `data-format="json"` is set. + + + +#### Supported Input Types + +Dify supports a variety of input types for forms, including: + +- text +- textarea +- password +- time +- date +- datetime +- select +- checkbox +- hidden + +If you want to render a form during the conversation, you can use the following syntax: + +``` +
// Default to text + + + + + + + + + + + + + + + + + + +
+``` + + +Hidden is not visible to users, you can set the value to pass data without user input. + + +### Chart + +We support rendering [echarts](https://dify.ai/docs/guides/tools/chart) in markdown. You can use the following syntax to render a chart: + + + +To render a chart, start a fenced code block with ```echarts and place your chart configuration inside. + + +```echarts +{ + "title": { + "text": "ECharts Entry Example" + }, + "tooltip": {}, + "legend": { + "data": ["Sales"] + }, + "xAxis": { + "data": ["Shirts", "Cardigans", "Chiffons", "Pants", "Heels", "Socks"] + }, + "yAxis": {}, + "series": [{ + "name": "Sales", + "type": "bar", + "data": [5, 20, 36, 10, 10, 20] + }] +} +``` + +### Music + +Not only can you render charts, but also music sheets in markdown. We support rendering [ABC notation](https://paulrosen.github.io/abcjs/) in markdown. You can use the following syntax to render a music sheet: + + + + +To render a music sheet, start a fenced code block with ```abc and place your ABC notation inside. + + +```abc +X: 1 +T: Cooley's +M: 4/4 +L: 1/8 +K: Emin +|:D2|EB{c}BA B2 EB|~B2 AB dBAG|FDAD BDAD|FDAD dAFD| +EBBA B2 EB|B2 AB defg|afe^c dBAF|DEFD E2:| +|:gf|eB B2 efge|eB B2 gedB|A2 FA DAFA|A2 FA defg| +eB B2 eBgB|eB B2 defg|afe^c dBAF|DEFD E2:| +``` + +## Best Practices + +If you want to predefine the markdown content, you can use the [template](/en/guides/workflow/node/template) feature in Dify. This allows you to use template content in downstream nodes. \ No newline at end of file diff --git a/images/screenshot-20250714-134035.png b/images/screenshot-20250714-134035.png new file mode 100644 index 00000000..91438c4a Binary files /dev/null and b/images/screenshot-20250714-134035.png differ diff --git a/images/screenshot-20250714-134150.png b/images/screenshot-20250714-134150.png new file mode 100644 index 00000000..f5b59ec2 Binary files /dev/null and b/images/screenshot-20250714-134150.png differ diff --git a/images/screenshot-20250714-134238.png b/images/screenshot-20250714-134238.png new file mode 100644 index 00000000..3a340913 Binary files /dev/null and b/images/screenshot-20250714-134238.png differ diff --git a/images/screenshot-20250714-134431.png b/images/screenshot-20250714-134431.png new file mode 100644 index 00000000..005f7f32 Binary files /dev/null and b/images/screenshot-20250714-134431.png differ