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

Multiple Line <include> Directives Leave Behind the End Tag #19

Open
GoogleCodeExporter opened this issue Jul 8, 2015 · 4 comments
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Put in a directive like the following:
<include
    src="foobaz.html"
</include>
2. Run the grit tool on that file
3. Observe the </include> is left behind

What is the expected output? What do you see instead?
</include> should no longer be there. It should have been removed when the file 
was inlined.

What version of the product are you using? On what operating system?
r126

Please provide any additional information below.
The proposed fix is below:

For the tags that get replaced wholesale, change the .*> at the end to .*?> and 
use the modifier re.DOTALL to include newlines.

--- grit/format/html_inline.py  (revision 126)
+++ grit/format/html_inline.py  (working copy)
@@ -33,10 +33,10 @@
 # Used by DoInline to replace various links with inline content.
 _STYLESHEET_RE = lazy_re.compile(
     '<link rel="stylesheet"[^>]+?href="(?P<filename>[^"]*)".*?>',
-    re.MULTILINE)
+    re.DOTALL)
 _INCLUDE_RE = lazy_re.compile(
-    '<include[^>]+?src="(?P<filename>[^"\']*)".*>',
-    re.MULTILINE)
+    '<include[^>]+?src="(?P<filename>[^"\']*)".*?>',
+    re.DOTALL)
 _SRC_RE = lazy_re.compile(
     r'<(?!script)(?:[^>]+?\s)src=(?P<quote>")(?P<filename>[^"\']*)\1',
     re.MULTILINE)

Original issue reported on code.google.com by [email protected] on 13 Jun 2013 at 7:51

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

No branches or pull requests

1 participant