Feat: add new Markdown parser (#39800)

and change all the challenges to new `md` format.
This commit is contained in:
Oliver Eyton-Williams
2020-11-27 19:02:05 +01:00
committed by GitHub
parent a07f84c8ec
commit 0bd52f8bd1
2580 changed files with 113436 additions and 111979 deletions

View File

@ -1,66 +1,66 @@
---
title: Word wrap
id: 594810f028c0303b75339ad4
title: Word wrap
challengeType: 5
forumTopicId: 302344
---
## Description
<section id='description'>
# --description--
Even today, with proportional fonts and complex layouts, there are still cases where you need to wrap text at a specified column. The basic task is to wrap a paragraph of text in a simple way.
</section>
## Instructions
<section id='instructions'>
# --instructions--
Write a function that can wrap this text to any number of characters. As an example, the text wrapped to 80 characters should look like the following:
<pre>
Wrap text using a more sophisticated algorithm such as the Knuth and Plass TeX
algorithm. If your language provides this, you get easy extra credit, but you
must reference documentation indicating that the algorithm is something better
than a simple minimum length algorithm.
</pre>
</section>
## Tests
<section id='tests'>
# --hints--
```yml
tests:
- text: wrap should be a function.
testString: assert.equal(typeof wrap, 'function');
- text: wrap should return a string.
testString: assert.equal(typeof wrap('abc', 10), 'string');
- text: wrap(80) should return 4 lines.
testString: assert(wrapped80.split('\n').length === 4);
- text: Your <code>wrap</code> function should return our expected text.
testString: assert.equal(wrapped80.split('\n')[0], firstRow80);
- text: wrap(42) should return 7 lines.
testString: assert(wrapped42.split('\n').length === 7);
- text: Your <code>wrap</code> function should return our expected text.
testString: assert.equal(wrapped42.split('\n')[0], firstRow42);
```
</section>
## Challenge Seed
<section id='challengeSeed'>
<div id='js-seed'>
wrap should be a function.
```js
function wrap(text, limit) {
return text;
}
assert.equal(typeof wrap, 'function');
```
</div>
wrap should return a string.
```js
assert.equal(typeof wrap('abc', 10), 'string');
```
### After Test
<div id='js-teardown'>
wrap(80) should return 4 lines.
```js
assert(wrapped80.split('\n').length === 4);
```
Your `wrap` function should return our expected text.
```js
assert.equal(wrapped80.split('\n')[0], firstRow80);
```
wrap(42) should return 7 lines.
```js
assert(wrapped42.split('\n').length === 7);
```
Your `wrap` function should return our expected text.
```js
assert.equal(wrapped42.split('\n')[0], firstRow42);
```
# --seed--
## --after-user-code--
```js
const text =
@ -78,13 +78,15 @@ const firstRow80 =
const firstRow42 = 'Wrap text using a more sophisticated';
```
</div>
## --seed-contents--
</section>
## Solution
<section id='solution'>
```js
function wrap(text, limit) {
return text;
}
```
# --solutions--
```js
function wrap(text, limit) {
@ -100,7 +102,4 @@ function wrap(text, limit) {
}
return text;
}
```
</section>