Oliver Eyton-Williams ee1e8abd87
feat(curriculum): restore seed + solution to Chinese (#40683)
* feat(tools): add seed/solution restore script

* chore(curriculum): remove empty sections' markers

* chore(curriculum): add seed + solution to Chinese

* chore: remove old formatter

* fix: update getChallenges

parse translated challenges separately, without reference to the source

* chore(curriculum): add dashedName to English

* chore(curriculum): add dashedName to Chinese

* refactor: remove unused challenge property 'name'

* fix: relax dashedName requirement

* fix: stray tag

Remove stray `pre` tag from challenge file.

Signed-off-by: nhcarrigan <nhcarrigan@gmail.com>

Co-authored-by: nhcarrigan <nhcarrigan@gmail.com>
2021-01-12 19:31:00 -07:00

3.9 KiB
Raw Blame History

id, title, challengeType, videoUrl, forumTopicId, dashedName
id title challengeType videoUrl forumTopicId dashedName
bad87fee1348bd9aede08817 将 a 嵌套在段落中 0 https://scrimba.com/p/pVMPUv/cb6k8Cb 18244 nest-an-anchor-element-within-a-paragraph

--description--

你可以在其他文本元素内嵌套链接。

<p>
  Here's a <a target="_blank" href="http://freecodecamp.org"> link to freecodecamp.org</a> for you to follow.
</p>

让我们来拆解一下这个例子: 通常,文本是被包裹在 p 元素内:
<p> Here's a ... for you to follow. </p> 接下来是 <a> 元素(它需要结束标签 </a> <a> ... </a> targeta 元素的属性,它用来指定链接的打开方式。属性值 "_blank" 表示链接会在新标签页打开。hrefa 的另一个属性,它用来指定链接的 URL <a href="https://freecodecamp.org"> ... </a> a 元素内的内容文本 "link to freecodecamp.org",会显示为一个可以点击的链接: <a href=" ... ">link to freecodecamp.org</a> 此示例的最终输出结果是这样:

Here's a link to freecodecamp.org for you to follow.

--instructions--

创建一个新的段落(p)标签来包裹 main 元素里的 a 节点。新段落标签的内容为:"View more cat photos",其中 "cat photos" 是一个链接,其余是纯文本。

--hints--

应包含一个链接到 "https://freecatphotoapp.com" 的 a 元素。

assert(
  $('a[href="https://freecatphotoapp.com"]').length > 0 ||
    $('a[href="http://www.freecatphotoapp.com"]').length > 0
);

a 元素的内容文本应为 "cat photos"。

assert(
  $('a')
    .text()
    .match(/cat\sphotos/gi)
);

你应该在 a 标签的外部创建一个新的 p 标签。页面中应至少包含 3 个 p 标签。

assert($('p') && $('p').length > 2);

a 应嵌套在新创建的 p 元素内。

assert(
  $('a[href="https://freecatphotoapp.com"]').parent().is('p') ||
    $('a[href="http://www.freecatphotoapp.com"]').parent().is('p')
);

p 元素应该包含文本 "View more "请注意more 之后有一个空格)。

assert(
  $('a[href="https://freecatphotoapp.com"]')
    .parent()
    .text()
    .match(/View\smore\s/gi) ||
    $('a[href="http://www.freecatphotoapp.com"]')
      .parent()
      .text()
      .match(/View\smore\s/gi)
);

a 元素中不应包含文本 "View more"。

assert(
  !$('a')
    .text()
    .match(/View\smore/gi)
);

确保每个 p 元素有结束标签。

assert(
  code.match(/<\/p>/g) &&
    code.match(/<p/g) &&
    code.match(/<\/p>/g).length === code.match(/<p/g).length
);

确保每个 a 元素有结束标签。

assert(
  code.match(/<\/a>/g) &&
    code.match(/<a/g) &&
    code.match(/<\/a>/g).length === code.match(/<a/g).length
);

--seed--

--seed-contents--

<h2>CatPhotoApp</h2>
<main>

  <a href="https://freecatphotoapp.com" target="_blank">cat photos</a>

  <img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back.">

  <p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
  <p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
</main>

--solutions--

<h2>CatPhotoApp</h2>
<main>
  <p>View more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a></p>

  <img src="https://bit.ly/fcc-relaxing-cat" alt="A cute orange cat lying on its back.">

  <p>Kitty ipsum dolor sit amet, shed everywhere shed everywhere stretching attack your ankles chase the red dot, hairball run catnip eat the grass sniff.</p>
  <p>Purr jump eat the grass rip the couch scratched sunbathe, shed everywhere rip the couch sleep in the sink fluffy fur catnip scratched.</p>
</main>