Page 3 of 8

Filters

Posted: Mon 07 Oct, 2019 14:57
by HaRT

Latest post of the previous page:

pepak, a bug surfaced: the “JSON format” filter does not show up in *.json files where the top-level element is not an object, mostly affecting JSON files with a top-level array. According to the grammar, object is not the only valid top-level element, and top-level arrays are of particular importance.
How to reproduce: create a file named e.g. json.json with 2 characters: [], invoke Filters.

Filters

Posted: Mon 07 Oct, 2019 16:21
by pepak
That is a limitation of the component used, I think. It would be possible to fix by wrapping the array inside an object, but it seems the detection of this case is more complicated than simply creating the wrapper manually. Also, if it really is a major issue for someone, they can easily set up an external JSON formatter instead of the built-in one and that will take care of any similar issues immediately.

Filters

Posted: Mon 07 Oct, 2019 16:28
by HaRT
pepak wrote: Mon 07 Oct, 2019 16:21 That is a limitation of the component used, I think.
What's the component? Those I used myself just had a separate method to handle top-level arrays.
If it turns out to be a limitation indeed, please document this to save people like me from spending time trying to figure out why the plug-in does not work in their case.

Filters

Posted: Wed 09 Oct, 2019 18:41
by pepak
HaRT wrote: Mon 07 Oct, 2019 16:28
pepak wrote: Mon 07 Oct, 2019 16:21 That is a limitation of the component used, I think.
What's the component? Those I used myself just had a separate method to handle top-level arrays.
Henri Gourvest's SuperObject.
If it turns out to be a limitation indeed, please document this to save people like me from spending time trying to figure out why the plug-in does not work in their case.
Frankly, it never occurred to me that this might be a problem in the component. Maybe it can even cope, somehow.

Filters

Posted: Wed 23 Oct, 2019 21:40
by LAT
Could you please advice an utility for formatting of the javascript-code, that can be used as external filter for this plugin?

Filters

Posted: Sat 26 Oct, 2019 04:35
by pepak
I wish! Looking for one myself.

Filters

Posted: Mon 28 Oct, 2019 07:11
by stefanenko
XML is read as windows-2151 and encoded in utf-8. When pressed again, the conversion 1251-> utf-8 again occurs and all non-English text goes bad!

Filters

Posted: Mon 28 Oct, 2019 09:16
by pepak
stefanenko wrote: Mon 28 Oct, 2019 07:11 XML is read as windows-2151 and encoded in utf-8. When pressed again, the conversion 1251-> utf-8 again occurs and all non-English text goes bad!
Nope. XML is read in the editor's encoding and written also in editor's encoding.

Filters

Posted: Mon 28 Oct, 2019 12:49
by stefanenko

Code: Select all

--- open file

C:\2Work\phpunit.xml                                 │  │1251 │
<?xml version="1.0" encoding="windows-1251"?>
<phpunit>
<env name="TEST" value="тестовая строка"/>
</phpunit>

--- after press F5

C:\2Work\phpunit.xml                                 │* │1251 │
<?xml version="1.0" encoding="windows-1251"?>
<phpunit>
  <env name="TEST" value="тестовая строка"/>
</phpunit>

--- after press Shift-F8 and select UTF-8

C:\2Work\phpunit.xml                                     │* │UTF-8│
<?xml version="1.0" encoding="windows-1251"?>
<phpunit>
  <env name="TEST" value="тестовая строка"/>
</phpunit>

--- again press F5

C:\2Work\phpunit.xml                                     │* │UTF-8│
<?xml version="1.0" encoding="windows-1251"?>
<phpunit>
  <env name="TEST" value="тестовая строка"/>
</phpunit>

--  done. the encoding is broken. (if save)

Filters

Posted: Mon 28 Oct, 2019 12:51
by stefanenko
OR open

Code: Select all

<?xml version="1.0" encoding="windows-1251"?>
<phpunit>
<env name="TEST" value="тестовая строка"/>
</phpunit>
and press F5 four times...

Code: Select all

<?xml version="1.0" encoding="windows-1251"?>
<phpunit>
  <env name="TEST" value="тестовая строка"/>
</phpunit>

Filters

Posted: Mon 28 Oct, 2019 12:53
by stefanenko
By the way, I like the plugin. I can do external formatting with my tools. Thanks

Filters

Posted: Mon 28 Oct, 2019 13:18
by HaRT
stefanenko wrote: Mon 28 Oct, 2019 07:11 XML is read as windows-2151 and encoded in utf-8. When pressed again, the conversion 1251-> utf-8 again occurs and all non-English text goes bad!
I experience the same (mis-)behavior.

Filters

Posted: Mon 28 Oct, 2019 14:26
by stefanenko
I wanted to be able to have several handlers with a choice

Code: Select all

Autoselect
HTML View using elinks                  *.htm,*.html,*.xhtml
XML Format                 *.xml,*.xsd,*.xslt,*.wsdl,*.xhtml
xmllint                                                *.xml
2nd tools                                              *.xml
JSON Format                                           *.json

Filters

Posted: Mon 28 Oct, 2019 16:29
by pepak
Hmm. Seems like the encoding attribute is the problem. Once you remove it, everything is fine. I will have to remove it before the filter starts its work, I guess. Or something like that.

Filters

Posted: Mon 28 Oct, 2019 17:09
by HaRT
pepak wrote: Mon 28 Oct, 2019 16:29 Seems like the encoding attribute is the problem.
How come? It matches the editor's current encoding. If it did not, it would make sense to ask the user which encoding to use.

Filters

Posted: Mon 28 Oct, 2019 18:09
by pepak
Just try it and you will see.