<commit_before>#|
link : https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/
|#

(defpackage :lem-asciidoc-mode
  (:use :cl :lem :lem.language-mode)
  (:export :*asciidoc-mode-hook*))
(in-package :lem-asciidoc-mode)

(defun make-tmlanguage-asciidoc ()
  (labels ((tm-builtin (pattern)
             (make-tm-match pattern :name 'syntax-builtin-attribute))
           (tm-constant (pattern)
             (make-tm-match pattern :name 'syntax-constant-attribute))
           (tm-function-name (pattern)
             (make-tm-match pattern :name 'syntax-function-name-attribute))
           (tm-string (pattern)
             (make-tm-match pattern :name 'syntax-string-attribute)))
    (let* ((patterns (make-tm-patterns
                      ;; line breaks
                      (tm-constant "(\\+)|(\\[%hardbreaks\\])")
                      ;; lead style
                      (tm-constant "\\[\\.lead\\]")
                      ;; admonition
                      (tm-constant "((NOTE)|(TIP)|(IMPORTANT)|(WARNING)|(CAUTION))\\:")
                      ;; bold and italic
                      (tm-string "(\\*[^*]+\\*)|(\\*\\*[^*]+\\*\\*)")
                      (tm-string "(_[^_]+_)|(__[^_]+__)")
                      (tm-string "(`[^`]+`)|(``[^`]+``)")
                      ;; section
                      (tm-function-name "={1,6} .+")
                      ;; unordered list
                      (tm-builtin "^(\\*){1,5} ")
                      (tm-builtin "^-{1,5} ")
                      ;; check list
                      (tm-builtin "^((\\*)|-) \\[[ x*]\\] ")
                      ;; ordered list
                      (tm-builtin "^(\\.){1,5} ")
                      (tm-builtin "^\\d\\. ")
                      ;; subscript and superscript
                      (tm-string "~[^~]+~")
                      (tm-string "\\^[^^]+\\^"))))
      (make-tmlanguage :patterns patterns))))

(defvar *asciidoc-syntax-table*
  (let ((table (make-syntax-table :space-chars '(#\space #\tab #\newline)))
        (tmlanguage (make-tmlanguage-asciidoc)))
    (set-syntax-parser table tmlanguage)
    table))

(define-major-mode asciidoc-mode language-mode
    (:name "AsciiDoc"
     :keymap *asciidoc-mode-keymap*
     :syntax-table *asciidoc-syntax-table*
     :mode-hook *asciidoc-mode-hook*)
  (setf (variable-value 'enable-syntax-highlight) t))

(pushnew (cons "\\.adoc$" 'asciidoc-mode) *auto-mode-alist*)<commit_msg>Added some highlight to asciidoc mode<commit_after>#|
link : https://asciidoctor.org/docs/asciidoc-syntax-quick-reference/
|#

(defpackage :lem-asciidoc-mode
  (:use :cl :lem :lem.language-mode)
  (:export :*asciidoc-mode-hook*))
(in-package :lem-asciidoc-mode)

(defun make-tmlanguage-asciidoc ()
  (labels ((tm-builtin (pattern)
             (make-tm-match pattern :name 'syntax-builtin-attribute))
           (tm-constant (pattern)
             (make-tm-match pattern :name 'syntax-constant-attribute))
           (tm-function-name (pattern)
             (make-tm-match pattern :name 'syntax-function-name-attribute))
           (tm-string (pattern)
             (make-tm-match pattern :name 'syntax-string-attribute)))
    (let* ((patterns (make-tm-patterns
                      ;; block
                      (make-tm-region '(:sequence "----")
                                      '(:sequence "----")
                                      :name 'syntax-comment-attribute)
                      ;; line breaks
                      (tm-constant "(\\+)|(\\[%hardbreaks\\])")
                      ;; lead style
                      (tm-constant "\\[\\.lead\\]")
                      ;; admonition
                      (tm-constant "((NOTE)|(TIP)|(IMPORTANT)|(WARNING)|(CAUTION))\\:")
                      ;; bold and italic
                      (tm-string "(\\*[^*]+\\*)|(\\*\\*[^*]+\\*\\*)")
                      (tm-string "(_[^_]+_)|(__[^_]+__)")
                      (tm-string "(`[^`]+`)|(``[^`]+``)")
                      ;; curved quotation marks
                      (tm-string "\"`[^`\"]+`\"")
                      (tm-string "'`[^`']+`'")
                      ;; section
                      (tm-function-name "={1,6} .+")
                      ;; unordered list
                      (tm-builtin "^(\\*){1,5} ")
                      (tm-builtin "^-{1,5} ")
                      ;; check list
                      (tm-builtin "^((\\*)|-) \\[[ x*]\\] ")
                      ;; ordered list
                      (tm-builtin "^(\\.){1,5} ")
                      (tm-builtin "^\\d\\. ")
                      ;; subscript and superscript
                      (tm-string "~[^~]+~")
                      (tm-string "\\^[^^]+\\^")
                      ;; tables
                      (tm-builtin "^\\|(\\=)+$")
                      (tm-builtin "^\\[.+\\]"))))
      (make-tmlanguage :patterns patterns))))

(defvar *asciidoc-syntax-table*
  (let ((table (make-syntax-table :space-chars '(#\space #\tab #\newline)))
        (tmlanguage (make-tmlanguage-asciidoc)))
    (set-syntax-parser table tmlanguage)
    table))

(define-major-mode asciidoc-mode language-mode
    (:name "AsciiDoc"
     :keymap *asciidoc-mode-keymap*
     :syntax-table *asciidoc-syntax-table*
     :mode-hook *asciidoc-mode-hook*)
  (setf (variable-value 'enable-syntax-highlight) t))

(pushnew (cons "\\.adoc$" 'asciidoc-mode) *auto-mode-alist*)
{'fraction_non_alphanumeric': 0.1976981622424355, 'fraction_numerical': 0.002970113235567106, 'mean_word_length': 1.4613978985838283, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7376409', 'n_tokens_mistral': 1759, 'n_tokens_neox': 1632, 'n_words': 262}