]> code.delx.au - gnu-emacs-elpa/blob - packages/html5-schema/html5-schema.el
Merge commit '0cda39255827f283e7578cd469ae42daad9556a2' from js2-mode
[gnu-emacs-elpa] / packages / html5-schema / html5-schema.el
1 ;;; html5-schema.el --- Add HTML5 schemas for use by nXML -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2016 Free Software Foundation, Inc
4
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6 ;; Keywords: html, xml
7 ;; Version: 0.1
8 ;; URL: https://github.com/validator/validator
9 ;; Package-Type: multi
10
11 ;; This program is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
15
16 ;; This program is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
23
24 ;;; Commentary:
25
26 ;; The RelaxNG files are taken straight from
27 ;; https://github.com/validator/validator.git's via:
28 ;;
29 ;; git subtree -P schema/html5 split
30 ;;
31 ;; To which we manually add `locating-rules.xml` and this file.
32
33 ;;; Code:
34
35 ;;;###autoload
36 (when load-file-name
37 (let* ((dir (file-name-directory load-file-name))
38 (file (expand-file-name "locating-rules.xml" dir)))
39 (eval-after-load 'rng-loc
40 `(progn
41 (add-to-list 'rng-schema-locating-files-default 'file)
42 ;; FIXME: We should only push to rng-schema-locating-files-default,
43 ;; since rng-schema-locating-files is a custom var, but by the time
44 ;; we run, rng-schema-locating-files has already been initialized
45 ;; from rng-schema-locating-files-default, so setting
46 ;; rng-schema-locating-files-default doesn't have any effect
47 ;; any more!
48 (add-to-list 'rng-schema-locating-files ,file)
49 (put 'http://whattf.org/datatype-draft 'rng-dt-compile
50 #'nxml-html5-dt-compile)))))
51
52 ;;;###autoload
53 (add-to-list 'auto-mode-alist '("\\.html?\\'" . nxml-mode))
54
55 (defvar nxml-html5-dt-params nil)
56 (defvar nxml-html5-dt-names nil)
57
58 ;;;###autoload
59 (defun nxml-html5-dt-compile (name params)
60 ;; FIXME: How/when is `params' ever used? It seems to always be nil!
61 (add-to-list 'nxml-html5-dt-params params)
62 (add-to-list 'nxml-html5-dt-names name)
63 ;; FIXME: We currently don't do any actual validation of datatypes!
64 '(t identity))
65
66 (provide 'html5-schema)
67 ;;; html5-schema.el ends here