Files
wehub-resource-sync dde272c4b8
i18n - Build Validation / Validate i18n Builds (24) (push) Has been cancelled
CI - Node.js / Lint (24) (push) Has been cancelled
CI - Node.js / Build (24) (push) Has been cancelled
CI - Node.js / Test (24) (push) Has been cancelled
CI - Node.js / Test - Upcoming Changes (24) (push) Has been cancelled
CI - Node.js / Test - i18n (italian, 24) (push) Has been cancelled
CI - Node.js / Test - i18n (portuguese, 24) (push) Has been cancelled
CD - Docker - GHCR Images / Build and Push Images (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 11:55:53 +08:00

66 lines
1.7 KiB
Markdown

---
id: 691b559495c5cb5a37b9b489
title: "Challenge 129: Markdown Blockquote Parser"
challengeType: 28
dashedName: challenge-129
---
# --description--
Given a string that includes a blockquote in Markdown, return the equivalent HTML string.
A blockquote in Markdown is any line that:
- Starts with zero or more spaces
- Followed by a greater-than sign (`>`)
- Then, one or more spaces
- And finally, the blockquote text.
Return the blockquote text surrounded by opening and closing HTML `blockquote` tags.
For example, given `"> This is a quote"`, return `<blockquote>This is a quote</blockquote>`.
Note: The console may not display HTML tags in strings when logging messages. Check the browser console to see logs with tags included.
# --hints--
`parseBlockquote("> This is a quote")` should return `"<blockquote>This is a quote</blockquote>"`.
```js
assert.equal(parseBlockquote("> This is a quote"), "<blockquote>This is a quote</blockquote>");
```
`parseBlockquote(" > This is also a quote")` should return `"<blockquote>This is also a quote</blockquote>"`.
```js
assert.equal(parseBlockquote(" > This is also a quote"), "<blockquote>This is also a quote</blockquote>");
```
`parseBlockquote(" > So Is This")` should return `"<blockquote>So Is This</blockquote>"`.
```js
assert.equal(parseBlockquote(" > So Is This"), "<blockquote>So Is This</blockquote>");
```
# --seed--
## --seed-contents--
```js
function parseBlockquote(markdown) {
return markdown;
}
```
# --solutions--
```js
function parseBlockquote(markdown) {
const blockquoteRegex = /^\s*>\s+(.+)$/;
const match = markdown.match(blockquoteRegex);
const text = match[1];
return `<blockquote>${text}</blockquote>`;
}
```