def testNestedHtmlFile(self): self.assertContentsPreserved( """<script></script><script></script><script> // sometimes functions might be evil and do something like this, but we // should still use the original values when returning the filtered array </script> """, comment_scrubber.HtmlCommentExtractor())
def _MakeHtmlScrubbers(self): html_scrubbers = [] html_scrubbers.append( comment_scrubber.CommentScrubber( comment_scrubber.HtmlCommentExtractor(), self._CommentScrubbers())) line_scrubbers = self._PolyglotLineOrientedScrubbers() for js_directory_rename in self.js_directory_renames: line_scrubbers.append(js_directory_rename) html_scrubbers.append(line_scrubber.LineScrubber(line_scrubbers)) html_scrubbers.extend(self._PolyglotFileScrubbers()) return html_scrubbers
def testHtmlCommentWithoutDelimiters(self): extractor = comment_scrubber.HtmlCommentExtractor() self.assertEqual('foo', extractor.CommentWithoutDelimiters('<!--foo-->')) self.assertEqual('foo>', extractor.CommentWithoutDelimiters('<!--foo>-->')) self.assertEqual(' foo', extractor.CommentWithoutDelimiters('<!-- foo-->')) self.assertEqual('foo', extractor.CommentWithoutDelimiters('/*foo*/')) self.assertEqual('foo', extractor.CommentWithoutDelimiters('//foo')) self.assertRaises(base.Error, extractor.CommentWithoutDelimiters, '<!-- whoops */')
def testHtmlCommentExtraction(self): TestCommentExtractor(self, comment_scrubber.HtmlCommentExtractor(), os.path.join(TEST_DATA_DIR, 'test_file.html.txt'), os.path.join(TEST_DATA_DIR, 'html_comments.txt'))
def testStripLineDirectiveHtml(self): scrubber = comment_scrubber.CommentScrubber( comment_scrubber.HtmlCommentExtractor()) self.assertContents( scrubber, ['a = ""', 'c = a'], ['a = ""', 'b = a <!-- MOE:strip_line -->', 'c = a'])
def testExcludeHtmlDelimiters(self): self.CheckReplace(comment_scrubber.HtmlCommentExtractor(), [ ('<!-- MOE:end_strip_and_replace foo -->', 'foo'), ('<!--MOE:end_strip_and_replace foo-->', 'foo'), ('<!--MOE:end_strip_and_replace foo\nbar-->', 'foo\nbar'), ])