validation...

--HG--
branch : pmacs2
This commit is contained in:
moculus 2008-05-19 02:04:39 +00:00
parent 277a12111d
commit 1a7ddfc0d1
1 changed files with 24 additions and 1 deletions

View File

@ -1,4 +1,4 @@
import os import os, urllib
import color, method, mode import color, method, mode
from lex import Grammar, PatternRule, RegionRule from lex import Grammar, PatternRule, RegionRule
from mode.xml import TagGrammar from mode.xml import TagGrammar
@ -35,6 +35,28 @@ class HtmlViewPage(method.Method):
else: else:
w.application.run_external(*argv) w.application.run_external(*argv)
class HtmlValidatePage(method.Method):
'''View the HTML data in a browser (curses or external)'''
args = [method.arg('url', dv=default.build_mode_var('url'), ld=True,
h='')]
base = 'http://validator.w3.org/check?'
def _execute(self, w, **vargs):
w.mode.url = vargs['url']
viewcmd = w.application.config.get('html.viewcmd')
viewbg = viewcmd.endswith('&')
if viewbg:
viewcmd = viewcmd[:-1]
urlarg = urllib.urlencode({'uri': w.mode.url})
argv = (viewcmd, self.base + urlarg)
if viewbg:
if os.fork() == 0:
try:
os.execvp(viewcmd, argv)
except OSError:
os._exit(1)
else:
w.application.run_external(*argv)
class HtmlCheckSpelling(method.Method): class HtmlCheckSpelling(method.Method):
"""Check the spelling of the document via ispell -t""" """Check the spelling of the document via ispell -t"""
def _execute(self, w, **vargs): def _execute(self, w, **vargs):
@ -79,5 +101,6 @@ class HTML(mode.Fundamental):
self.add_bindings('xml-create-tag', ('M-t',)) self.add_bindings('xml-create-tag', ('M-t',))
self.add_action(HtmlViewPage()) self.add_action(HtmlViewPage())
self.add_action(HtmlCheckSpelling()) self.add_action(HtmlCheckSpelling())
self.url = None
install = HTML.install install = HTML.install