Filters

Here you can discuss about your favorite plug-in.
User avatar
HaRT
Moderator
Posts: 9088
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 90 times
Been thanked: 157 times

Filters

Post by HaRT » Mon 07 Oct, 2019 14:57

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.
Фар есть инструмент, а не нянька. © 2009 DrKnS

pepak
Posts: 433
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 6 times
Been thanked: 24 times

Filters

Post by pepak » Mon 07 Oct, 2019 16:21

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.
Last edited by pepak on Mon 07 Oct, 2019 16:22, edited 1 time in total.

User avatar
HaRT
Moderator
Posts: 9088
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 90 times
Been thanked: 157 times

Filters

Post by HaRT » 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.
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.
Last edited by HaRT on Mon 07 Oct, 2019 16:31, edited 1 time in total.
Фар есть инструмент, а не нянька. © 2009 DrKnS

pepak
Posts: 433
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 6 times
Been thanked: 24 times

Filters

Post by pepak » Wed 09 Oct, 2019 18:41

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.

LAT
Posts: 236
Joined: Thu 21 Jan, 2010 20:00
Has thanked: 10 times
Been thanked: 15 times

Filters

Post by LAT » Wed 23 Oct, 2019 21:40

Could you please advice an utility for formatting of the javascript-code, that can be used as external filter for this plugin?

pepak
Posts: 433
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 6 times
Been thanked: 24 times

Filters

Post by pepak » Sat 26 Oct, 2019 04:35

I wish! Looking for one myself.

stefanenko
Posts: 119
Joined: Sun 20 Jun, 2010 12:37
Has thanked: 23 times
Been thanked: 4 times

Filters

Post by stefanenko » 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!

pepak
Posts: 433
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 6 times
Been thanked: 24 times

Filters

Post by pepak » Mon 28 Oct, 2019 09:16

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.

stefanenko
Posts: 119
Joined: Sun 20 Jun, 2010 12:37
Has thanked: 23 times
Been thanked: 4 times

Filters

Post by stefanenko » Mon 28 Oct, 2019 12:49

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)

stefanenko
Posts: 119
Joined: Sun 20 Jun, 2010 12:37
Has thanked: 23 times
Been thanked: 4 times

Filters

Post by stefanenko » Mon 28 Oct, 2019 12:51

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>

stefanenko
Posts: 119
Joined: Sun 20 Jun, 2010 12:37
Has thanked: 23 times
Been thanked: 4 times

Filters

Post by stefanenko » Mon 28 Oct, 2019 12:53

By the way, I like the plugin. I can do external formatting with my tools. Thanks

User avatar
HaRT
Moderator
Posts: 9088
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 90 times
Been thanked: 157 times

Filters

Post by HaRT » Mon 28 Oct, 2019 13:18

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.
Фар есть инструмент, а не нянька. © 2009 DrKnS

stefanenko
Posts: 119
Joined: Sun 20 Jun, 2010 12:37
Has thanked: 23 times
Been thanked: 4 times

Filters

Post by stefanenko » Mon 28 Oct, 2019 14:26

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

pepak
Posts: 433
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 6 times
Been thanked: 24 times

Filters

Post by pepak » Mon 28 Oct, 2019 16:29

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.

User avatar
HaRT
Moderator
Posts: 9088
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 90 times
Been thanked: 157 times

Filters

Post by HaRT » Mon 28 Oct, 2019 17:09

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.
Фар есть инструмент, а не нянька. © 2009 DrKnS

pepak
Posts: 433
Joined: Sun 13 Jul, 2008 11:18
Has thanked: 6 times
Been thanked: 24 times

Filters

Post by pepak » Mon 28 Oct, 2019 18:09

Just try it and you will see.

User avatar
HaRT
Moderator
Posts: 9088
Joined: Tue 30 Aug, 2005 17:21
Location: Санкт-Петербург
Has thanked: 90 times
Been thanked: 157 times

Filters

Post by HaRT » Mon 28 Oct, 2019 18:24

pepak wrote:
Mon 28 Oct, 2019 18:09
Just try it and you will see.
I believe it does so. But that behavior is an obvious error as the encoding line clearly should not affect the result in this case.
So just removing the line looks more like a workaround rather than a fix.
Фар есть инструмент, а не нянька. © 2009 DrKnS

Post Reply

Return to “General Plug-In Discussions”