From c7be107240cfe0189c0d0bfd6de435ad84ee9414 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Sun, 25 Jul 2021 09:56:29 +0200 Subject: [PATCH 1/4] Update markdown stub --- exercises/practice/markdown/.meta/tests.toml | 30 +++++++++++++++++-- exercises/practice/markdown/lib/markdown.ex | 3 +- .../practice/markdown/test/markdown_test.exs | 28 +++++++++++++++++ 3 files changed, 57 insertions(+), 4 deletions(-) diff --git a/exercises/practice/markdown/.meta/tests.toml b/exercises/practice/markdown/.meta/tests.toml index fecbcf5003..28b7baa720 100644 --- a/exercises/practice/markdown/.meta/tests.toml +++ b/exercises/practice/markdown/.meta/tests.toml @@ -1,6 +1,13 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [e75c8103-a6b8-45d9-84ad-e68520545f6e] description = "parses normal text as a paragraph" @@ -20,9 +27,26 @@ description = "with h1 header level" [d0f7a31f-6935-44ac-8a9a-1e8ab16af77f] description = "with h2 header level" +[9df3f500-0622-4696-81a7-d5babd9b5f49] +description = "with h3 header level" + +[50862777-a5e8-42e9-a3b8-4ba6fcd0ed03] +description = "with h4 header level" + +[ee1c23ac-4c86-4f2a-8b9c-403548d4ab82] +description = "with h5 header level" + [13b5f410-33f5-44f0-a6a7-cfd4ab74b5d5] description = "with h6 header level" +[6dca5d10-5c22-4e2a-ac2b-bd6f21e61939] +description = "with h7 header level" +include = false + +[81c0c4db-435e-4d77-860d-45afacdad810] +description = "h7 header level is a paragraph" +reimplements = "6dca5d10-5c22-4e2a-ac2b-bd6f21e61939" + [25288a2b-8edc-45db-84cf-0b6c6ee034d6] description = "unordered lists" diff --git a/exercises/practice/markdown/lib/markdown.ex b/exercises/practice/markdown/lib/markdown.ex index 7d9c1caca5..33f1b4d7ab 100644 --- a/exercises/practice/markdown/lib/markdown.ex +++ b/exercises/practice/markdown/lib/markdown.ex @@ -16,7 +16,8 @@ defmodule Markdown do end defp process(t) do - if String.starts_with?(t, "#") || String.starts_with?(t, "*") do + if (String.starts_with?(t, "#") && !String.starts_with?(t, "#######")) || + String.starts_with?(t, "*") do if String.starts_with?(t, "#") do enclose_with_header_tag(parse_header_md_level(t)) else diff --git a/exercises/practice/markdown/test/markdown_test.exs b/exercises/practice/markdown/test/markdown_test.exs index 0c58df0b4a..c546fff5f7 100644 --- a/exercises/practice/markdown/test/markdown_test.exs +++ b/exercises/practice/markdown/test/markdown_test.exs @@ -43,6 +43,27 @@ defmodule MarkdownTest do assert Markdown.parse(input) == expected end + # @tag :pending + test "with h3 header level" do + input = "### This will be an h3" + expected = "

This will be an h3

" + assert Markdown.parse(input) == expected + end + + # @tag :pending + test "with h4 header level" do + input = "#### This will be an h4" + expected = "

This will be an h4

" + assert Markdown.parse(input) == expected + end + + # @tag :pending + test "with h5 header level" do + input = "##### This will be an h5" + expected = "
This will be an h5
" + assert Markdown.parse(input) == expected + end + # @tag :pending test "with h6 header level" do input = "###### This will be an h6" @@ -50,6 +71,13 @@ defmodule MarkdownTest do assert Markdown.parse(input) == expected end + # @tag :pending + test "h7 header level is a paragraph" do + input = "####### This will not be an h7" + expected = "

####### This will not be an h7

" + assert Markdown.parse(input) == expected + end + # @tag :pending test "unordered lists" do input = "* Item 1\n* Item 2" From de3cbf4a27690353e5b13046b2af8a0dc8b6f629 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Sun, 25 Jul 2021 09:58:27 +0200 Subject: [PATCH 2/4] Update markdown example --- exercises/practice/markdown/.meta/example.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/exercises/practice/markdown/.meta/example.ex b/exercises/practice/markdown/.meta/example.ex index 57ab01ca5b..d0eb042c1d 100644 --- a/exercises/practice/markdown/.meta/example.ex +++ b/exercises/practice/markdown/.meta/example.ex @@ -20,7 +20,12 @@ defmodule Markdown do defp process(t = "#" <> _) do [h, tail] = String.split(t, " ", parts: 2) - wrap_in_html_tag(tail, "h#{byte_size(h)}") + + if byte_size(h) < 7 do + wrap_in_html_tag(tail, "h#{byte_size(h)}") + else + wrap_in_html_tag(t, "p") + end end defp process("*" <> t) do From e482fdfedac0703a8cd847abae10ef1d601d32c6 Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Sun, 25 Jul 2021 10:05:03 +0200 Subject: [PATCH 3/4] Add new grade-school test --- .../practice/grade-school/.meta/tests.toml | 24 +++++++++++++++---- .../grade-school/test/school_test.exs | 11 ++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/exercises/practice/grade-school/.meta/tests.toml b/exercises/practice/grade-school/.meta/tests.toml index cdfae59aea..81e3799427 100644 --- a/exercises/practice/grade-school/.meta/tests.toml +++ b/exercises/practice/grade-school/.meta/tests.toml @@ -1,19 +1,35 @@ -# This is an auto-generated file. Regular comments will be removed when this -# file is regenerated. Regenerating will not touch any manually added keys, -# so comments can be added in a "comment" key. +# This is an auto-generated file. +# +# Regenerating this file via `configlet sync` will: +# - Recreate every `description` key/value pair +# - Recreate every `reimplements` key/value pair, where they exist in problem-specifications +# - Remove any `include = true` key/value pair (an omitted `include` key implies inclusion) +# - Preserve any other key/value pair +# +# As user-added comments (using the # character) will be removed when this file +# is regenerated, comments can be added via a `comment` key. [6d0a30e4-1b4e-472e-8e20-c41702125667] description = "Adding a student adds them to the sorted roster" [c125dab7-2a53-492f-a99a-56ad511940d8] description = "A student can't be in two different grades" +include = false + +[a0c7b9b8-0e89-47f8-8b4a-c50f885e79d1] +description = "A student can only be added to the same grade in the roster once" +reimplements = "c125dab7-2a53-492f-a99a-56ad511940d8" [233be705-dd58-4968-889d-fb3c7954c9cc] -description = "Adding more student adds them to the sorted roster" +description = "Adding more students adds them to the sorted roster" [75a51579-d1d7-407c-a2f8-2166e984e8ab] description = "Adding students to different grades adds them to the same sorted roster" +[6a03b61e-1211-4783-a3cc-fc7f773fba3f] +description = "A student cannot be added to more than one grade in the sorted roster" +reimplements = "c125dab7-2a53-492f-a99a-56ad511940d8" + [a3f0fb58-f240-4723-8ddc-e644666b85cc] description = "Roster returns an empty list if there are no students enrolled" diff --git a/exercises/practice/grade-school/test/school_test.exs b/exercises/practice/grade-school/test/school_test.exs index a8ee74d0d6..e065ac512a 100644 --- a/exercises/practice/grade-school/test/school_test.exs +++ b/exercises/practice/grade-school/test/school_test.exs @@ -8,7 +8,16 @@ defmodule SchoolTest do assert actual == %{2 => ["Aimee"]} end - test "a student can't be in two different grades" do + test "a student only be added to the same grade once" do + actual = + @db + |> School.add("Aimee", 2) + |> School.add("Aimee", 2) + + assert actual == %{2 => ["Aimee"]} + end + + test "a student cannot be added to more than one grade" do actual = @db |> School.add("Aimee", 2) From ba6b1ab36e55a1bb3bcd40bc3c0591af39712ddb Mon Sep 17 00:00:00 2001 From: Angelika Tyborska Date: Sun, 25 Jul 2021 10:07:12 +0200 Subject: [PATCH 4/4] Typo --- exercises/practice/grade-school/test/school_test.exs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/grade-school/test/school_test.exs b/exercises/practice/grade-school/test/school_test.exs index e065ac512a..cdae708b3c 100644 --- a/exercises/practice/grade-school/test/school_test.exs +++ b/exercises/practice/grade-school/test/school_test.exs @@ -8,7 +8,7 @@ defmodule SchoolTest do assert actual == %{2 => ["Aimee"]} end - test "a student only be added to the same grade once" do + test "a student can only be added to the same grade once" do actual = @db |> School.add("Aimee", 2)