Skip to content

Support embedding tests/tasks to Markdown files #5603

Closed

Description

@pekkaklarck

This would in practice mean that if you have a Markdown file example.md with the below content, you could execute it with robot example.md and the test would be run.

This is just some text, *not* Robot data.

``‍`robotframework
*** Test Cases ***
Example
    Log    This is Robot data!
``‍`

More free text here. There could be additional code block with more Robot data as well.

We support this with reStructuredText, but I'm not sure how widely used the support is. With reST this works so that our custom reST parser finds all Robot Framework code blocks and then feeds them to normal Robot parser. The same approach would likely work here as well, but I believe the Markdown parser would be really simple. If we limit this support only to code blocks starting with the ```robotframework header, the parser wouldn't even need to use any Markdown module. It could just go through lines one-by-one, search for the header, and store content between these headers and closing triple backticks.

When executing a directory like robot example, possible *.md files in it shouldn't be parsed by default, but it should be possible to use --extension or --parse-include options to change that. We also should automatically parse possible *.robot.md files. These are the same semantics we use with reStructuredText files.

Implementing this using the existing reStructuredText parser as an example would be pretty simple, but getting everything done, tested and documented is a relatively large task. Because this doesn't need deep knowledge about Robot's internals, this would be a very good issue for someone interested to contribute. I'll assign this tentatively to RF 7.5 scope that already has other Markdown related enhancements (#5304, #5602).

Notice that we already have #2610 about this topic. That issue has also proposed other Markdown related enhancement and its description is not that clear, though, so I decided to submit a new one and close the earlier as a duplicate.

Activity

  1. added this to the v7.5 milestone on Jan 21, 2026
  2. seto commented on Mar 23, 2026

    @seto
    Contributor

    Hello, I have implemented native support for Markdown (.md, .markdown, and .robot.md) for both test suites and resources. The implementation follows the same architectural pattern as the existing RST support, including a dependency-free reader to extract fenced code blocks.

    You can find the implementation and the relative acceptance/unit tests in PR #5633.

    Feedback and reviews are more than welcome!

  3. pekkaklarck commented on Mar 24, 2026

    @pekkaklarck
    MemberAuthor

    Thanks for the PR! I commented it briefly.

  4. pekkaklarck commented on Mar 26, 2026

    @pekkaklarck
    MemberAuthor

    I took a bit more detailed look at the code changes in the PR and they look pretty good. I especially like how little new code is needed.

    While reviewing the changes, I remembered that I've seen different ways to start fenced code blocks. I studied that a bit and you can see what the CommonMark spec says about them here. I don't think we need to support absolutely everything that spec says, but at least these are something we should consider:

    1. In addition to using backticks, it's possible to use tildes like ~~~robotframework in the code fence. They cannot be mixed within a single fence, though, and the closing fence must use same character as the opening fence.
    2. You can have more than three backticks or tildes in the opening fence. Then the closing fence must have at least that many backticks/tildes.
    3. The text on the same line as the opening fence, a.k.a. the info string, should be stripped. For example, ~~~ robotframework is allowed.
    4. The info string may contain multiple parts separated by spaces and the first part is the language. For example, ~~~ robot start=3 is allowed. We probably can ignore all other parts than the first one.

    Supporting the above makes the implementation a bit more complicated, but it shouldn't be too bad. Most likely using a regex would be easiest. It's probably easiest to test this using unit tests and in acceptance tests just use some of the variants.

  5. 25 remaining items

  6. seto commented on Apr 23, 2026

    @seto
    Contributor

    I’ve just pushed the documentation for this feature.

    I updated all the related files I found and followed the same structure as the reST support to maintain consistency, and I also updated RobotFrameworkUserGuide.rst to include references to Markdown and the CommonMark spec.

    Let me know how it looks. I'm happy to refine it further or add more examples regarding code fences if you think it's necessary.

  7. added a commit that references this issue on Apr 28, 2026
    823d34d
  8. pekkaklarck commented on Apr 28, 2026

    @pekkaklarck
    MemberAuthor

    Thanks for the docs @seto!

  9. seto commented on Apr 28, 2026

    @seto
    Contributor

    My pleasure! Glad to help.

  10. changed the title [-]Support embeddding tests/tasks to Markdown files[/-] [+]Support embedding tests/tasks to Markdown files[/+] on Jul 17, 2026
  11. pekkaklarck commented on Aug 10, 2026

    @pekkaklarck
    MemberAuthor

    Thanks @JFoederer for PR #5735 that enhanced the docs related to this functionality by adding a section about living documentation. I especially like the tip to use Markdown comments to hide technical details from HTML.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgebeta 1effort: mediumpriority: high

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions