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

Breaks if there's word "body" anywhere in the content (not tag) #7

Closed
szimek opened this issue Apr 24, 2017 · 2 comments
Closed

Breaks if there's word "body" anywhere in the content (not tag) #7

szimek opened this issue Apr 24, 2017 · 2 comments

Comments

@szimek
Copy link
Contributor

szimek commented Apr 24, 2017

This plugin won't work correctly if there's any "body*" word in the content of the pug file.

E.g. in such case:

doctype html
html
  head
    meta(charset="utf-8")
    title Bodyweight training
  body
    #root

it will generate:

doctype html
html
  head
    meta(charset="utf-8")
    title  link(href="css/app-f3c2fb29e007744ea4a5.css" rel="stylesheet")
 Bodyweight training
  body
    #root
  script(type="text/javascript" src="js/app-f3c2fb29e007744ea4a5.bundle.js")

It can be fixed by changing the regexp used from /( *)(%?body)/i to /^( *)(%?body)\b/im (in line #138).

I can prepare PR for it, but because there are no tests, I'm not sure if it won't break anything.

BTW. It might be a better idea to parse PUG using their parser to get AST and modify that instead using regexes, but then it would support only PUG files...

@szimek szimek changed the title Breaks if there's word body anywhere in the content (not tag) Breaks if there's word "body" anywhere in the content (not tag) Apr 24, 2017
@negibouze
Copy link
Owner

Thank you for your report and PR.
And I'm sorry for the late reply.

I will append examples and release new version.

It might be a better idea to parse PUG using their parser to get AST and modify that instead using regexes, but then it would support only PUG files...

Thank you for your idea too.

@negibouze
Copy link
Owner

I released a new version.

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

No branches or pull requests

2 participants