<commit_before>;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause

(in-package :spinneret)

(deftag :mayberaw (body attrs &key &allow-other-keys)
  attrs
  `(:raw (if (nyxt:html-string-p (progn ,@body))
             (progn ,@body)
             (escape-string (progn ,@body)))))

(deftag :nstyle (body attrs &key &allow-other-keys)
  `(:style ,@attrs (:raw ,@body)))

(deftag :nscript (body attrs &key &allow-other-keys)
  `(:script ,@attrs (:raw ,@body)))

(spinneret:deftag :nxref (body attr &key slot class-name function command variable package &allow-other-keys)
  (let ((symbol (or package variable function command slot class-name))
        (printable (or (first body) package variable function command slot class-name)))
    `(:a :href ,(cond
                  (package `(nyxt:nyxt-url (read-from-string "nyxt:describe-package")
                                           :universal t :package ,package))
                  (variable `(nyxt:nyxt-url (read-from-string "nyxt:describe-variable")
                                            :universal t :variable ,variable))
                  (function `(nyxt:nyxt-url (read-from-string "nyxt:describe-function")
                                            :universal t :fn ,function))
                  (command `(nyxt:nyxt-url (read-from-string "nyxt:describe-command")
                                           :universal t :command ,command))
                  (slot `(nyxt:nyxt-url (read-from-string "nyxt:describe-slot")
                                        :universal t :name ,slot :class ,class-name))
                  (class-name `(nyxt:nyxt-url (read-from-string "nyxt:describe-class")
                                              :universal t :class ,class-name))
                  (t `(nyxt:javascript-url
                       (ps:ps (nyxt/ps:lisp-eval
                               (:title "describe-any")
                               ;; Not defined yet:
                               (funcall (nyxt:resolve-symbol :describe-any :function)<commit_msg>spinneret-tags: Fix :nxref requiring :universal t for packages.<commit_after>;;;; SPDX-FileCopyrightText: Atlas Engineer LLC
;;;; SPDX-License-Identifier: BSD-3-Clause

(in-package :spinneret)

(deftag :mayberaw (body attrs &key &allow-other-keys)
  attrs
  `(:raw (if (nyxt:html-string-p (progn ,@body))
             (progn ,@body)
             (escape-string (progn ,@body)))))

(deftag :nstyle (body attrs &key &allow-other-keys)
  `(:style ,@attrs (:raw ,@body)))

(deftag :nscript (body attrs &key &allow-other-keys)
  `(:script ,@attrs (:raw ,@body)))

(spinneret:deftag :nxref (body attr &key slot class-name function command variable package &allow-other-keys)
  (let ((symbol (or package variable function command slot class-name))
        (printable (or (first body) package variable function command slot class-name)))
    `(:a :href ,(cond
                  (package `(nyxt:nyxt-url (read-from-string "nyxt:describe-package") :package ,package))
                  (variable `(nyxt:nyxt-url (read-from-string "nyxt:describe-variable")
                                            :universal t :variable ,variable))
                  (function `(nyxt:nyxt-url (read-from-string "nyxt:describe-function")
                                            :universal t :fn ,function))
                  (command `(nyxt:nyxt-url (read-from-string "nyxt:describe-command")
                                           :universal t :command ,command))
                  (slot `(nyxt:nyxt-url (read-from-string "nyxt:describe-slot")
                                        :universal t :name ,slot :class ,class-name))
                  (class-name `(nyxt:nyxt-url (read-from-string "nyxt:describe-class")
                                              :universal t :class ,class-name))
                  (t `(nyxt:javascript-url
                       (ps:ps (nyxt/ps:lisp-eval
                               (:title "describe-any")
                               ;; Not defined yet:
                               (funcall (nyxt:resolve-symbol :describe-any :function)
{'fraction_non_alphanumeric': 0.13110788582486696, 'fraction_numerical': 0.0004837929366231253, 'mean_word_length': 1.8148400272294078, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 22, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4091085', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1132, 'n_words': 290}