Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solve issue/192 (the case when <br> tag exists within <pre> tag) #552

Merged
merged 1 commit into from
Oct 15, 2019

Conversation

kawacchu
Copy link
Contributor

@kawacchu kawacchu commented Oct 15, 2019

In no.750 and no.751, the author have written sample case using <br> tag within <pre> tag, which is not a user concern but we might not have expected such cases.


For example, no.750 サンプル1 入力1
<pre>6<br />1 1<br />7 4<br />0 5<br />1 3<br />-8 9<br />5 1</pre>
is given for online-judge-tools.


Beautiful Soup documents says that

If a tag contains more than one thing, then it’s not clear what .string should refer to, so .string is defined to be None:


So we should fix
s = tag.string or '' # tag.string for the tag "<pre></pre>" returns None
(in _parse_sample_tag function, onlinejudge/service/yukicoder.py file).


In this pull request, I use .strings generator and iterate to make what the user expects.


But the unexpected behavior for the user will remain in some problems. (although I have never seen them in a real environment.)

Let me show a tricky problem.

問題文
文字列Sが1行で与えられる. Sは小文字のアルファベットと<>/を用いて構成される.
Sに含まれるrの個数を1行で出力しなさい.
制約
1 <= S <= 100
サンプル
入力1
yukicode
r
出力1
4

... because this problem's author thinks 入力1 as <strong>yuki</strong>code<br>r

In my opinion, user's expectation for oj d is to download what they see and we have not to handle with such tricky problems.

Copy link
Member

@kmyk kmyk left a comment

Choose a reason for hiding this comment

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

LGTM
It's perfect!

@kmyk
Copy link
Member

kmyk commented Oct 15, 2019

In terms of problems whose samples freely use HTML tags, I think we ideally should just abandon entire parsing or ignore non-<br> tags (i.e. read as yukicode\nr). Using emphasis in samples is considerable, but, it seems enough rare to just ignore them for now.

(Note: If the problem author think the string <strong>yuki</strong>code<br>r itself as an input, it will be escaped and appears as &gt;strong&lt;yuki;&gt;/strong&lt;yuki;code&gt;br&lt;r in HTML.)

@kmyk kmyk merged commit 6bf35d6 into online-judge-tools:master Oct 15, 2019
@kawacchu
Copy link
Contributor Author

Thank you for your kind review !
I will consider what you replied in #553 .

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