Genshi mode problems

Bug #409183 reported by Jimmy Yuen Ho Wong
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
nXhtml
Fix Released
Medium
Unassigned

Bug Description

There are multiple problems with genshi-html-mumamo.

1. Upon loading a Genshi HTML file, nXhtml won't switch to genshi-html-mumamo mode even if the file has this line: xmlns:py="http://genshi.edgewell.org/". I tried changing the magic-mode-alist regex to just that, and it still won't work.

2. The inside the py:* attribute doesn't trigger Python mode automatically.

3. Find a way to recognize the "once" attribute in py:match element. Right now for some strange reason the 'once="True"' chunk is automatically in javascript mode.

Revision history for this message
Jimmy Yuen Ho Wong (wyuenho) wrote :

Screenshot.

Revision history for this message
lborgman (lennart-borgman) wrote :

Thanks for the report, Jimmy!

1 and 3 might be easy. Shouldn't it be edgewall, not edgewell?

once="True" happen to clash with the simple heuristics I use for onmouse="..." etc. Is that a big inconvenience when using Genshi?

But 2 is a bit harder for me to say something about. I don't know Genshi/Python. Should py: really start a block of Python code? Could you give me an example so I can try to understand?

I thought it would be better if the nxml parser took care of the py: part and checked it etc.

Revision history for this message
Jimmy Yuen Ho Wong (wyuenho) wrote :

Yeah you are right, it should be edgewall, it was a typo.

The once attribute under py:match is quite often used, so yeah it's a bit inconvenient. I guess what you can do is to just exclude the once attribute specifically for genshi mode.

Genshi's syntax is easy. It has 2 kinds of commands, attributes and namespaced element. All you have to do is, if you see a py:something attribute, it's value should be in a python mode chunk. So say, you have something like <span py:if="True = False">You see me</span>, "True = False" should be in a Python mode chunk. That's it. There's no need to trigger python mode for <py:*> elements, because ${} already does that.

Revision history for this message
lborgman (lennart-borgman) wrote :

Thanks, I will see what I can do about it.

Changed in nxhtml:
importance: Undecided → Medium
status: New → In Progress
Revision history for this message
lborgman (lennart-borgman) wrote :

What about py:match?

Revision history for this message
Jimmy Yuen Ho Wong (wyuenho) wrote :

Ah. This is a special case. Only the path attribute under a py:match element should use python mode.

Revision history for this message
lborgman (lennart-borgman) wrote :

Thanks. I have uploaded a new beta 1.94 with which should handle py:.

I have also added your .rnc files, but I am unsure about how to get them to work. Can you please try? (You can try using nxml-mode in Emacs 22.)

Revision history for this message
Jimmy Yuen Ho Wong (wyuenho) wrote :

The .rnc files don't seem to be working. I missed a few elements still I think. I'm still new to RelaxNG, Can I redefine an already defined element in RelaxNG schema file? I need to make all the py:elements valid elements under the html element.

Also, I've changed my mind about py:match's attribute value and py:match element 's path attribute being in python mode. They usually only consist of XPATHs, so making them in python mode is silly.

Last thing is that I think making the python keywords inside "" don't get their highlighting right. When I type none, sometimes the last character is highlighting, something the whole keyword. It's a little strange.

Revision history for this message
lborgman (lennart-borgman) wrote :

I am not an expert on rng. Please try asking on the nxml-mode mailing list:

    http://www.thaiopensource.com/nxml-mode/

Ok, I will remove p:match then.

Please show me an example of the bad highlighting.

Revision history for this message
Jimmy Yuen Ho Wong (wyuenho) wrote :

I'm almost done with revamping the Genshi grammar files, and am now in the process of writing test cases. I'm currently soliciting response on both the Genshi and nxml mailing lists. If you speak RelaxNG, I'll post the grammar files I have so far and see if you can help me squash some bugs.

BTW, the test for Genshi in nxhtml/test/in/genshi.ghtml is not quite right. {% python %} code blocks shouldn't be allowed in markup templates, which is all nxhtml does.

Revision history for this message
lborgman (lennart-borgman) wrote :

Hi Jimmy, yes I have seen you are working on it. I do not take part very much since I do not know much about it.

Please tell me when you are satisfied with the solution so I can include the new rnc files.

Revision history for this message
lborgman (lennart-borgman) wrote :

Thanks for the new .rng files. They are now in the beta.

Changed in nxhtml:
status: In Progress → Fix Committed
Changed in nxhtml:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.