Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(341)

Side by Side Diff: grit/format/html_inline.py

Issue 1374383003: Ignore Polymer bound src="[[attr]]" from grit processing. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: test fixes Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | grit/format/html_inline_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Flattens a HTML file by inlining its external resources. 6 """Flattens a HTML file by inlining its external resources.
7 7
8 This is a small script that takes a HTML file, looks for src attributes 8 This is a small script that takes a HTML file, looks for src attributes
9 and inlines the specified file, producing one HTML file with no external 9 and inlines the specified file, producing one HTML file with no external
10 dependencies. It recursively inlines the included files. 10 dependencies. It recursively inlines the included files.
(...skipping 28 matching lines...) Expand all
39 _END_IF_BLOCK = lazy_re.compile('\s*</if>') 39 _END_IF_BLOCK = lazy_re.compile('\s*</if>')
40 40
41 # Used by DoInline to replace various links with inline content. 41 # Used by DoInline to replace various links with inline content.
42 _STYLESHEET_RE = lazy_re.compile( 42 _STYLESHEET_RE = lazy_re.compile(
43 '<link rel="stylesheet"[^>]+?href="(?P<filename>[^"]*)".*?>(\s*</link>)?', 43 '<link rel="stylesheet"[^>]+?href="(?P<filename>[^"]*)".*?>(\s*</link>)?',
44 re.DOTALL) 44 re.DOTALL)
45 _INCLUDE_RE = lazy_re.compile( 45 _INCLUDE_RE = lazy_re.compile(
46 '<include[^>]+?src="(?P<filename>[^"\']*)".*?>(\s*</include>)?', 46 '<include[^>]+?src="(?P<filename>[^"\']*)".*?>(\s*</include>)?',
47 re.DOTALL) 47 re.DOTALL)
48 _SRC_RE = lazy_re.compile( 48 _SRC_RE = lazy_re.compile(
49 r'<(?!script)(?:[^>]+?\s)src=(?P<quote>")(?P<filename>[^"\']*)\1', 49 r'<(?!script)(?:[^>]+?\s)src=(?P<quote>")(?!\[\[|{{)(?P<filename>[^"\']*)\1' ,
50 re.MULTILINE) 50 re.MULTILINE)
51 _ICON_RE = lazy_re.compile( 51 _ICON_RE = lazy_re.compile(
52 r'<link rel="icon"\s(?:[^>]+?\s)?' 52 r'<link rel="icon"\s(?:[^>]+?\s)?'
53 'href=(?P<quote>")(?P<filename>[^"\']*)\1', 53 'href=(?P<quote>")(?P<filename>[^"\']*)\1',
54 re.MULTILINE) 54 re.MULTILINE)
55 55
56 56
57 def GetDistribution(): 57 def GetDistribution():
58 """Helper function that gets the distribution we are building. 58 """Helper function that gets the distribution we are building.
59 59
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 414
415 def main(): 415 def main():
416 if len(sys.argv) <= 2: 416 if len(sys.argv) <= 2:
417 print "Flattens a HTML file by inlining its external resources.\n" 417 print "Flattens a HTML file by inlining its external resources.\n"
418 print "html_inline.py inputfile outputfile" 418 print "html_inline.py inputfile outputfile"
419 else: 419 else:
420 InlineToFile(sys.argv[1], sys.argv[2], None) 420 InlineToFile(sys.argv[1], sys.argv[2], None)
421 421
422 if __name__ == '__main__': 422 if __name__ == '__main__':
423 main() 423 main()
OLDNEW
« no previous file with comments | « no previous file | grit/format/html_inline_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698