Skip to content

fix: formatter for html and special casing of content-type #170

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

Merged
merged 2 commits into from
Dec 30, 2022
Merged

fix: formatter for html and special casing of content-type #170

merged 2 commits into from
Dec 30, 2022

Conversation

udayvir-singh
Copy link
Contributor

@udayvir-singh udayvir-singh commented Dec 30, 2022

FIX 1

Fixes error caused by html formatter running even when tidy is not available on the system. Also fixes docs related to disabling formatters.

This PR is a cleaner version of #165.


Reason why formatter should be set to false instead of nil:

nil means nothing, ie. absence of value; that's why you have how pass false instead which has a actual value 0 in binary which can be set to a variable and passed around.

Here's another analogy:

Let's say you asked me to put something in a box, and I put <nothing> in the box. Is the box now empty or does it contain nothing? There is no way for you to verify that.

FIX 2

Fixes #157 hardcoded lower casing of content-type.

Fixes error caused by html formatter running even when tidy is not
available on the system. Also fixes docs related to disabling
formatters.
@udayvir-singh udayvir-singh changed the title fix: formatter for html fix: formatter for html and special casing of content-type Dec 30, 2022
@teto
Copy link
Collaborator

teto commented Dec 30, 2022

nil means nothing, ie. absence of value; that's why you have how pass false instead which has a actual value 0 in binary which can be set to a variable and passed around.

setting the value to nil is the standard way of removing a key from a table http://lua-users.org/wiki/StoringNilsInTables so I was surprised by the current behavior, which may be an oddity of tbl_deep_extend (maybe worth documenting upstream). I will test then merge

@udayvir-singh
Copy link
Contributor Author

udayvir-singh commented Dec 30, 2022

@teto

From lua-users wiki:

Lua tables make no distinction between a table value being nil and the corresponding key not existing in the table

In fact, you may think of {} as a table with all possible keys set to nil, and this still takes only a small finite amount of memory because all those keys having nil values are not explicitly stored.

So basically coming back to my original comment, the following two tables are indistinguishable:

local tbl1 = {}

local tbl2 = {
  a = nil,
  b = nil,
  c = nil,
  d = nil,
  ... -- all the way to infinity
}

@teto teto merged commit 60365bf into rest-nvim:main Dec 30, 2022
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

Successfully merging this pull request may close these issues.

use content-type:, other casing doesn't work
2 participants