Skip to content

Тимур Бабаев#249

Open
truefolder wants to merge 5 commits intokontur-courses:masterfrom
truefolder:homework
Open

Тимур Бабаев#249
truefolder wants to merge 5 commits intokontur-courses:masterfrom
truefolder:homework

Conversation

@truefolder
Copy link

Идея следующая: разбиваем каждый элемент который можем распарсить на "токены", представляем их в виде классов наследующихся от IToken где лежит вся инфа о md и html теге, а также о его парности. Каждый парсер будет унаследован от IParser, задачей парсера будет корректно обработать свой тег для которого он создавался и возвращать токен. Токенайзер будет пытаться использовать каждый из парсеров на символ (на обычный текст не будет парсера, так что если мы не нашли ни один парсер который может обработать символ - значит это обычный текст), затем все токены собираются и вместо md тегов подставляются html теги.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лишнее

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил

Comment on lines 32 to 34

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$"<{htmlTag}>{text}</{htmlTag}>
И лучше в метод расширения, потому что у тебя эта логика повторяется

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил

IsMarkedListItemOfType(tokens, lookAhead, listTagType) &&
newLines < 2)
{
if (newLines > 0) html.Append('\n');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше использовать Environment.NewLine везде

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Обсудили, из-за проблем с тесткейсами решили оставить просто "\n"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

У тебя index всегда будет равен 0. Потом что выше проверка на то, что index != 0.
Поэтому подчеркивает, что операция сложения с нулем бессмысленная

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Проверки на тип плохи тем, что когда у тебя появится цепочка наследований, то придется переписывать :)

Потому что будет AnotherTag : SomeTag : ITag

Copy link
Author

@truefolder truefolder Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил, теперь в ITag есть Enum со списком типов тегов

Comment on lines 11 to 77

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не смотря на то, что Action(Из AAA) будет везде одинаковый, тут лучше разделить на несколько методов, каждый из которых тестирует свои теги и взаимодействие этого тега с другими.

В тестах нам не требуется прям по максимуму все переиспользовать, но желательно. В данном случае мы продублируем не так много, зато получим логическое разделение и читаемость

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А еще у меня часть тестов завалились

{072FCB84-66D7-4DF9-86B7-D697764A2D5A}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Поправил

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А еще у меня часть тестов завалились

{072FCB84-66D7-4DF9-86B7-D697764A2D5A}

Обсудили, ошибка не с моей стороны

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments