From ba56b6622288eabce6c953727f5497fb0d44b80c Mon Sep 17 00:00:00 2001 From: Morten Olsen Date: Sun, 18 May 2025 22:29:50 +0200 Subject: [PATCH] fix: yaml parsing --- docs/README.md | 11 +++++++++-- docs/examples/with-multiple-requests.md | 6 +++--- src/execution/handlers/handlers.http.ts | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/README.md b/docs/README.md index cd2fccb..7cdfda7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -89,7 +89,7 @@ _(Note: Actual headers and some response fields might vary.)_ HTTP requests are defined in fenced code blocks annotated with `http`. The syntax is similar to the raw HTTP format: -```http disable +``` : ... @@ -132,10 +132,17 @@ You can assign a unique ID to an `http` request block. This allows you to: 1. Reference its specific response in a `::response` directive. 2. Access its request and response data in [Templating](https://www.google.com/search?q=%23templating-with-handlebars) via the `requests` and `responses` dictionaries. -To add an ID, include `id=yourUniqueId` in the `http` block's info string: +To add an ID, include `#yourUniqueId` or `id=yourUniqueId` in the `http` block's info string: ::raw-md[./examples/with-multiple-requests.md] +
+ Output + +::raw-md[./examples/with-multiple-requests.md]{render} + +
+ ## Templating with Handlebars `http.md` uses [Handlebars](https://handlebarsjs.com/) for templating, allowing you to create dynamic content within your markdown files. You can inject data from request responses, input variables, and other requests into your HTTP blocks or general markdown text. diff --git a/docs/examples/with-multiple-requests.md b/docs/examples/with-multiple-requests.md index ea768a5..ccafc9f 100644 --- a/docs/examples/with-multiple-requests.md +++ b/docs/examples/with-multiple-requests.md @@ -2,16 +2,16 @@ First, create a resource: -```http id=createUser +```http #createUser,format=yaml POST https://httpbin.org/post Content-Type: application/json -{"username": "alpha"} +username: alpha ``` Then, fetch a different resource: -```http id=getItem +```http #getItem GET https://httpbin.org/get?item=123 ``` diff --git a/src/execution/handlers/handlers.http.ts b/src/execution/handlers/handlers.http.ts index ba41861..e0b08cb 100644 --- a/src/execution/handlers/handlers.http.ts +++ b/src/execution/handlers/handlers.http.ts @@ -69,7 +69,7 @@ const httpHandler: ExecutionHandler = ({ } } - node.value = content; + node.value = [head, parsedBody].filter(Boolean).join('\n\n'); node.meta = undefined; context.addRequest({