comparison yahtml.el @ 466:c7b93cfceb1b dev

Support iframe
author HIROSE Yuuji <yuuji@gentei.org>
date Wed, 19 Jul 2017 13:17:23 +0859
parents e9299b77df1f
children 4f8551386af2
comparison
equal deleted inserted replaced
465:e9299b77df1f 466:c7b93cfceb1b
1 ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*- 1 ;;; yahtml.el --- Yet Another HTML mode -*- coding: sjis -*-
2 ;;; (c) 1994-2017 by HIROSE Yuuji [yuuji(@)yatex.org] 2 ;;; (c) 1994-2017 by HIROSE Yuuji [yuuji(@)yatex.org]
3 ;;; Last modified Mon Jun 12 08:40:51 2017 on firestorm 3 ;;; Last modified Wed Jul 19 13:10:28 2017 on firestorm
4 ;;; $Id$ 4 ;;; $Id$
5 5
6 (defconst yahtml-revision-number "1.79.3" 6 (defconst yahtml-revision-number "1.79.3"
7 "Revision number of running yahtml.el") 7 "Revision number of running yahtml.el")
8 8
442 ("h1") ("h2") ("h3") ("h4") ("h5") ("h6") 442 ("h1") ("h2") ("h3") ("h4") ("h5") ("h6")
443 ;; ("p") ;This makes indentation screwed up! 443 ;; ("p") ;This makes indentation screwed up!
444 ("style") ("script") ("noscript") ("div") ("object") ("ins") ("del") 444 ("style") ("script") ("noscript") ("div") ("object") ("ins") ("del")
445 ("option") ("datalist") 445 ("option") ("datalist")
446 ;;HTML5 446 ;;HTML5
447 ("video") ("audio") ("figure") 447 ("video") ("audio") ("figure") ("iframe")
448 )) 448 ))
449 449
450 (if yahtml-html4-strict 450 (if yahtml-html4-strict
451 (setq yahtml-env-table 451 (setq yahtml-env-table
452 (delete (assoc "center" yahtml-env-table) yahtml-env-table))) 452 (delete (assoc "center" yahtml-env-table) yahtml-env-table)))
1000 (let ((p (point)) initial i2 cmpl path dir file listfunc beg labels 1000 (let ((p (point)) initial i2 cmpl path dir file listfunc beg labels
1001 (lim (YaTeX-minibuffer-begin)) 1001 (lim (YaTeX-minibuffer-begin))
1002 (min (if (fboundp 'field-beginning) (field-beginning) (point-min)))) 1002 (min (if (fboundp 'field-beginning) (field-beginning) (point-min))))
1003 (setq initial (YaTeX-minibuffer-string)) 1003 (setq initial (YaTeX-minibuffer-string))
1004 (cond 1004 (cond
1005 ((string-match "^http:" initial) 1005 ((string-match "^htt" initial)
1006 (setq cmpl (try-completion initial yahtml-urls) 1006 (setq cmpl (try-completion initial yahtml-urls)
1007 listfunc (list 'lambda nil 1007 listfunc (list 'lambda nil
1008 (list 'all-completions initial 'yahtml-urls)) 1008 (list 'all-completions initial 'yahtml-urls))
1009 beg min)) 1009 beg min))
1010 ((setq beg (string-match "#" initial)) 1010 ((setq beg (string-match "#" initial))
1136 (delete-region (match-beginning 0) (match-end 0)) 1136 (delete-region (match-beginning 0) (match-end 0))
1137 (insert (format "%%%x" c))))) 1137 (insert (format "%%%x" c)))))
1138 (set-marker e nil)))) 1138 (set-marker e nil))))
1139 ;; ab%defgls/.| 1139 ;; ab%defgls/.|
1140 1140
1141 (defun yahtml:a () 1141 (defun yahtml-read-url (prompt)
1142 "Add-in function for <a>"
1143 (let ((href "")) 1142 (let ((href ""))
1144 (setq yahtml-completing-buffer (current-buffer) 1143 (setq yahtml-completing-buffer (current-buffer)
1145 yahtml-urls (append yahtml-urls-private yahtml-urls-local) 1144 yahtml-urls (append yahtml-urls-private yahtml-urls-local)
1146 href (yahtml-escape-chars-string 1145 href (yahtml-escape-chars-string
1147 (read-from-minibuffer-with-history 1146 (read-from-minibuffer-with-history
1148 "href: " "" yahtml-url-completion-map))) 1147 prompt "" yahtml-url-completion-map)))
1149 (prog1 1148 (prog1
1150 (concat (yahtml-make-optional-argument 1149 href
1151 "href" href) 1150 (if (and (string-match "^https?://" href)
1152 (yahtml-make-optional-argument
1153 "name" (read-string-with-history "name: ")))
1154 (if (and (string-match "^http://" href)
1155 (null (assoc href yahtml-urls-private)) 1151 (null (assoc href yahtml-urls-private))
1156 (null (assoc href yahtml-urls-local))) 1152 (null (assoc href yahtml-urls-local)))
1157 (YaTeX-update-table 1153 (YaTeX-update-table
1158 (list href) 1154 (list href)
1159 'yahtml-urls-private 'yahtml-urls-private 'yahtml-urls-local))))) 1155 'yahtml-urls-private 'yahtml-urls-private 'yahtml-urls-local)))))
1156
1157 (defun yahtml:a ()
1158 "Add-in function for <a>"
1159 (let ((href (yahtml-read-url "href: ")))
1160 (concat (yahtml-make-optional-argument
1161 "href" href)
1162 (yahtml-make-optional-argument
1163 "name" (read-string-with-history "name: ")))))
1160 1164
1161 (defvar yahtml-parameters-completion-alist 1165 (defvar yahtml-parameters-completion-alist
1162 '(("align" ("top") ("middle") ("bottom") ("left") ("right") ("center")) 1166 '(("align" ("top") ("middle") ("bottom") ("left") ("right") ("center"))
1163 ("clear" ("left") ("right") ("center") ("all") ("none")) 1167 ("clear" ("left") ("right") ("center") ("all") ("none"))
1164 ("lang" ("ja") ("en") ("kr") ("ch") ("fr")) 1168 ("lang" ("ja") ("en") ("kr") ("ch") ("fr"))
1829 "source: " yahtml-media-file-regexp "" "" nil ""))) 1833 "source: " yahtml-media-file-regexp "" "" nil "")))
1830 1834
1831 (defun yahtml:figure () 1835 (defun yahtml:figure ()
1832 (setq yahtml-last-typeface-cmd "figcaption")) 1836 (setq yahtml-last-typeface-cmd "figcaption"))
1833 1837
1838 (defun yahtml:iframe ()
1839 (let ((src (yahtml-read-url "src: ")))
1840 (concat
1841 (yahtml-make-optional-argument "src" src)
1842 (yahtml-make-optional-argument
1843 "width" (YaTeX-read-string-or-skip "width: "))
1844 (yahtml-make-optional-argument
1845 "height" (YaTeX-read-string-or-skip "height: ")))))
1846
1834 ;;; ---------- Jump ---------- 1847 ;;; ---------- Jump ----------
1835 (defun yahtml-on-href-p () 1848 (defun yahtml-on-href-p ()
1836 "Check if point is on href clause." 1849 "Check if point is on href clause."
1837 (let ((p (point)) e cmd (case-fold-search t)) 1850 (let ((p (point)) e cmd (case-fold-search t))
1838 (save-excursion 1851 (save-excursion
2836 ((string-match "^/" file) 2849 ((string-match "^/" file)
2837 (while list 2850 (while list
2838 (if (file-directory-p (car (car list))) 2851 (if (file-directory-p (car (car list)))
2839 (progn 2852 (progn
2840 (setq url (cdr (car list))) 2853 (setq url (cdr (car list)))
2841 (if (string-match "\\(http://[^/]*\\)/" url) 2854 (if (string-match "\\(https?://[^/]*\\)/" url)
2842 (setq docroot (substring url (match-end 1))) 2855 (setq docroot (substring url (match-end 1)))
2843 (setq docroot url)) 2856 (setq docroot url))
2844 (cond 2857 (cond
2845 ((string-match (concat "^" (regexp-quote docroot)) file) 2858 ((string-match (concat "^" (regexp-quote docroot)) file)
2846 (setq realpath 2859 (setq realpath
3054 (setq yahtml-last-begend "p") 3067 (setq yahtml-last-begend "p")
3055 (yahtml-insert-single "source") 3068 (yahtml-insert-single "source")
3056 ))) 3069 )))
3057 (fset 'yahtml-intelligent-newline-video 'yahtml-intelligent-newline-audio) 3070 (fset 'yahtml-intelligent-newline-video 'yahtml-intelligent-newline-audio)
3058 3071
3072 (defun yahtml-intelligent-newline-iframe ()
3073 (insert "<p>Your browser does not support iframes.</p>"))
3074
3059 ;;; ---------- Marking ---------- 3075 ;;; ---------- Marking ----------
3060 (defun yahtml-mark-begend () 3076 (defun yahtml-mark-begend ()
3061 "Mark current tag" 3077 "Mark current tag"
3062 (interactive) 3078 (interactive)
3063 (YaTeX-beginning-of-environment) 3079 (YaTeX-beginning-of-environment)

yatex.org