<commit_before>(defpackage #:lem-html-mode
  (:use #:cl
        #:lem
        #:lem.language-mode
        #:lem-xml-mode)
  (:import-from #:lem-xml-mode
                #:*xml-mode-keymap*
                #:*xml-syntax-table*
                #:*xml-open-tag-p*
                #:*xml-close-tag-p*
                #:xml-calc-indent)
  (:import-from #:cl-ppcre))
(in-package #:lem-html-mode)

(defvar *html-mode-hook* '())

(define-major-mode html-mode language-mode
    (:name "html"
     :keymap *xml-mode-keymap*
     :syntax-table *xml-syntax-table*)
  (setf (variable-value 'enable-syntax-highlight) t
        (variable-value 'tab-width) 2
        (variable-value 'calc-indent-function) 'html-calc-indent)
  (run-hooks *html-mode-hook*))

(defvar *void-elements*
  '("area" "base" "br" "col" "embed" "hr" "img" "input" "link" "meta" "param" "source" "track" "wbr"))

(defun open-tag-p (string)
  (ppcre:register-groups-bind (tag-content tag-name)
      ("^<(([^/>\\s]+)[^>]*)>$" string)
    (and (not (eql (aref tag-content 0) #\!))
         (not (ppcre:scan "/\\s*$" tag-content))
         (not (find tag-name *void-elements* :test 'string-equal)))))

(defun close-tag-p (string)
  (and (ppcre:scan "^</([^/\\s<>]+)>$" string)
       t))

(defun html-calc-indent (point)
  (let ((*xml-open-tag-p* #'open-tag-p)
        (*xml-close-tag-p* #'close-tag-p))
    (xml-calc-indent point)))

(pushnew (cons "\\.html$" 'html-mode) *auto-mode-alist* :test #'equal)<commit_msg>[html-mode] inherit xml-mode<commit_after>(defpackage #:lem-html-mode
  (:use #:cl
        #:lem
        #:lem.language-mode)
  (:import-from #:lem-xml-mode
                #:xml-mode
                #:*xml-open-tag-p*
                #:*xml-close-tag-p*
                #:xml-calc-indent)
  (:import-from #:cl-ppcre))
(in-package #:lem-html-mode)

(defvar *html-mode-hook* '())

(define-major-mode html-mode xml-mode
    (:name "HTML"
     :keymap *html-mode-keymap*)
  (setf (variable-value 'enable-syntax-highlight) t
        (variable-value 'tab-width) 2
        (variable-value 'calc-indent-function) 'html-calc-indent)
  (run-hooks *html-mode-hook*))

(defvar *void-elements*
  '("area" "base" "br" "col" "embed" "hr" "img" "input" "link" "meta" "param" "source" "track" "wbr"))

(defun open-tag-p (string)
  (ppcre:register-groups-bind (tag-content tag-name)
      ("^<(([^/>\\s]+)[^>]*)>$" string)
    (and (not (eql (aref tag-content 0) #\!))
         (not (ppcre:scan "/\\s*$" tag-content))
         (not (find tag-name *void-elements* :test 'string-equal)))))

(defun close-tag-p (string)
  (and (ppcre:scan "^</([^/\\s<>]+)>$" string)
       t))

(defun html-calc-indent (point)
  (let ((*xml-open-tag-p* #'open-tag-p)
        (*xml-close-tag-p* #'close-tag-p))
    (xml-calc-indent point)))

(pushnew (cons "\\.html$" 'html-mode) *auto-mode-alist* :test #'equal)
{'fraction_non_alphanumeric': 0.2280393534785664, 'fraction_numerical': 0.0014054813773717498, 'mean_word_length': 2.65, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 22}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5497550', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1107, 'n_words': 209}