Skip to content

Commit

Permalink
Merge pull request #552 from kawacchu/issue/192
Browse files Browse the repository at this point in the history
solve issue/192 (the case when <br> tag exists within <pre> tag)
  • Loading branch information
kmyk authored Oct 15, 2019
2 parents 3042fc1 + 302b7c6 commit 6bf35d6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 10 additions & 1 deletion onlinejudge/service/yukicoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,16 @@ def _parse_sample_tag(self, tag: bs4.Tag) -> Optional[Tuple[str, str]]:
if prv.name == 'h6' and tag.parent.name == 'div' and tag.parent['class'] == ['paragraph'] and pprv.name == 'h5':
log.debug('h6: %s', str(prv))
log.debug('name.encode(): %s', prv.string.encode())
s = tag.string or '' # tag.string for the tag "<pre></pre>" returns None

# tag.string for the tag below returns None
# - "<pre></pre>"
# - "<pre>6<br />1 1<br />7 4<br />0 5<br />1 3<br />-8 9<br />5 1</pre>"
# for more details, see https://www.crummy.com/software/BeautifulSoup/bs4/doc/#string
if tag.string is not None:
s = tag.string
else:
s = bs4.NavigableString(''.join(string + '\n' for string in tag.strings))

return utils.textfile(s.lstrip()), pprv.string + ' ' + prv.string
return None

Expand Down
1 change: 0 additions & 1 deletion tests/service_yukicoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ def test_donwload_sample_cases_issue_355(self):
TestCase(name='sample-4', input_name='サンプル4 入力', input_data=b'1 1\n2\n', output_name='サンプル4 出力', output_data=b'-1\n'),
])

@unittest.expectedFailure
def test_donwload_sample_cases_issue_192(self):
# see https://github.com/kmyk/online-judge-tools/issues/192
self.assertEqual(YukicoderProblem.from_url('https://yukicoder.me/problems/no/750').download_sample_cases(), [
Expand Down

0 comments on commit 6bf35d6

Please sign in to comment.