Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Configuration option to remove consecutive whitespace without outputting all on one line #57

Closed
jnvsor opened this issue Nov 12, 2015 · 8 comments · Fixed by #60
Closed
Milestone

Comments

@jnvsor
Copy link
Collaborator

jnvsor commented Nov 12, 2015

I would prefer my outputted source code to be somewhat easy to read. jekyll-compress-html is hard to read on one line, and jekyll itself is hard to read with dozens of lines of whitespace in between lines.

Could you please add a configuration option that would remove empty lines, but not all whitespace?

Something along the lines of:

replace(/\n\s+\n/, "\n")
@kleinfreund
Copy link

You can disable compression entirely during production in your _config.yml with

compress_html:
  ignore:
    envs: [local]

and the JEKYLL_ENV environment variable set to local.

If you want to have what you suggested in production, @penibelst will answer that.

@jnvsor
Copy link
Collaborator Author

jnvsor commented Nov 12, 2015

For all intents and purposes, this disables the compression entirely - I'm looking for a middle ground where repeated newlines are removed, but not all newlines.

@jnvsor
Copy link
Collaborator Author

jnvsor commented Nov 13, 2015

I've almost got a working version (Bug with pres I'm working on now) - here are the outputs

I'd appreciate build instructions - a quick google turned up nothing and knitting the file together by hand is murder :(

Site output default

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Compress HTML in Jekyll</title>
  <link rel="stylesheet" href="/ui/app.css">
  <link rel="icon" href="/ui/img/favicon-1.png">

    <link rel="prefetch" href="https://github.com/penibelst/jekyll-compress-html">
    <link rel="prerender" href="https://github.com/penibelst/jekyll-compress-html">

</head>

Site output jekyll-compress-html

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Compress HTML in Jekyll</title> <link rel="stylesheet" href="/ui/app.css"> <link rel="icon" href="/ui/img/favicon-1.png"> <link rel="prefetch" href="https://github.com/penibelst/jekyll-compress-html"> <link rel="prerender" href="https://github.com/penibelst/jekyll-compress-html"> </head>

Site output jekyll-compress-html with my patches and the config var on

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Compress HTML in Jekyll</title>
  <link rel="stylesheet" href="/ui/app.css">
  <link rel="icon" href="/ui/img/favicon-1.png">
    <link rel="prefetch" href="https://github.com/penibelst/jekyll-compress-html">
    <link rel="prerender" href="https://github.com/penibelst/jekyll-compress-html">
</head>

@doktorbro
Copy link
Collaborator

@jnvsor Nice to see you start an implementation. Feel free to make a PR, so I can assist you.

@doktorbro doktorbro added this to the v2.1 milestone Nov 13, 2015
@jnvsor
Copy link
Collaborator Author

jnvsor commented Nov 13, 2015

I had to move the comment stripping before the whitespace stripping or it would leave in empty lines that had comments.

As a result the comments/inside test changed one byte (Only one space in a row instead of 2. Yay!) and the profile has started giving the wrong stats in profile/whitespace.

I intend to fix that last bug and write a test for human readable mode before submitting a PR

PS: I keep running into a build error where it seems to double the last part of the file:

...ippings }}{% endif %} </table>{% endif %}{% endif %}
ndif %}{% endif %}

Any ideas?

@kleuter
Copy link

kleuter commented Jul 30, 2016

I'd love to have it implemented. Why not?

@jnvsor
Copy link
Collaborator Author

jnvsor commented Jul 30, 2016

It's been implemented since december: See blanklines

@kleuter
Copy link

kleuter commented Jul 31, 2016

jnvsor, thanks. But how do I enable ONLY this option?

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
4 participants