| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917 | ;;; test-oc.el --- Tests for Org Cite library        -*- lexical-binding: t; -*-;; Copyright (C) 2021  Nicolas Goaziou;; Author: Nicolas Goaziou <mail@nicolasgoaziou.fr>;; This program is free software; you can redistribute it and/or modify;; it under the terms of the GNU General Public License as published by;; the Free Software Foundation, either version 3 of the License, or;; (at your option) any later version.;; This program is distributed in the hope that it will be useful,;; but WITHOUT ANY WARRANTY; without even the implied warranty of;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the;; GNU General Public License for more details.;; You should have received a copy of the GNU General Public License;; along with this program.  If not, see <https://www.gnu.org/licenses/>.;;; Code:(require 'oc)(require 'ox);; We need `org-test-with-parsed-data' macro.(require 'test-ox "../testing/lisp/test-ox.el")(ert-deftest test-org-cite/register-processor ()  "Test `org-cite-register-processor'."  ;; Default test.  (should   (let ((org-cite--processors nil))     (org-cite-register-processor 'name)))  ;; Handle duplicate processor.  (should   (let ((org-cite--processors nil))     (org-cite-register-processor 'name)     (org-cite-register-processor 'name)))  ;; Invalid name type.  (should-error (org-cite-register-processor "name"))  ;; Unknown property.  (should-error   (let ((org-cite--processors nil))     (org-cite-register-processor :foo 'bar))))(ert-deftest test-org-cite/unregister-processor ()  "Test `org-cite-unregister-processor'."  ;; Default test.  (should-not   (let ((org-cite--processors nil))     (org-cite-register-processor 'name)     (org-cite-unregister-processor 'name)     org-cite--processors))  ;; Error out with an unknown processor.  (should-error   (let ((org-cite--processors nil))     (org-cite-unregister-processor 'name))))(ert-deftest test-org-cite/inside-footnote-p ()  "Test `org-cite-inside-footnote-p'."  ;; Regular tests.  (should   (org-test-with-parsed-data "[fn:1] <point>[cite:@key]"     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t))))  (should   (org-test-with-parsed-data "[fn::<point>[cite:@key]]"     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t))))  (should-not   (org-test-with-parsed-data "[cite:@key]"     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t))))  (should   (org-test-with-parsed-data "[fn:1] Text.<point>[cite:@key]"     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t))))  (should   (org-test-with-parsed-data "[fn:1] <point>[cite:@key]\n: fixed width"     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t))))  (should   (org-test-with-parsed-data "[fn:1] <point>[cite:@key]  "     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t))))  ;; Test optional argument.  (should   (org-test-with-parsed-data "[fn:1] <point>[cite:@key]"     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t)      t)))  (should-not   (org-test-with-parsed-data "[fn:1] <point>See [cite:@key]."     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t)      t)))  (should   (org-test-with-parsed-data "[fn::<point>[cite:@key]]"     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t)      t)))  (should-not   (org-test-with-parsed-data "[fn::<point>See [cite:@key].]"     (org-cite-inside-footnote-p      (org-element-map tree 'citation #'identity info t)      t))))(ert-deftest test-org-cite/processor-has-capability-p ()  "Test `org-cite-processor-has-capability-p'."  ;; Unknown capability error.  (should-error   (let ((org-cite--processors nil))     (org-cite-register-processor 'name :activate #'ignore)     (org-cite-processor-has-capability-p 'name 'unknown)))  ;; Test `activate' capability.  (should   (let ((org-cite--processors nil))     (org-cite-register-processor 'name :activate #'ignore)     (org-cite-processor-has-capability-p 'name 'activate)))  (should-not   (let ((org-cite--processors nil))     (org-cite-register-processor 'name :follow #'ignore)     (org-cite-processor-has-capability-p 'name 'activate)))  ;; Test `export' capability.  (should   (let ((org-cite--processors nil))     (org-cite-register-processor 'name       :export-bibliography #'ignore       :export-citation #'ignore)     (org-cite-processor-has-capability-p 'name 'export)))  (should   (let ((org-cite--processors nil))     (org-cite-register-processor 'name :export-citation #'ignore)     (org-cite-processor-has-capability-p 'name 'export)))  (should-not   (let ((org-cite--processors nil))     (org-cite-register-processor 'name :export-bibliography #'ignore)     (org-cite-processor-has-capability-p 'name 'export)))  ;; Test `follow' capability.  (should   (let ((org-cite--processors nil))     (org-cite-register-processor 'name :follow #'ignore)     (org-cite-processor-has-capability-p 'name 'follow)))  (should-not   (let ((org-cite--processors nil))     (org-cite-register-processor 'name :activate #'ignore)     (org-cite-processor-has-capability-p 'name 'follow)))  ;; Unknown processors have no capabilities.  (should-not (org-cite-processor-has-capability-p 'foo 'activate))  (should-not (org-cite-processor-has-capability-p 'foo 'export))  (should-not (org-cite-processor-has-capability-p 'foo 'follow)))(ert-deftest test-org-cite/get-references ()  "Test `org-cite-get-references'."  ;; Return a list of citation reference objects.  (should   (equal '(citation-reference)          (org-test-with-temp-text "[cite:@a]"            (mapcar #'org-element-type                    (org-cite-get-references (org-element-context))))))  (should   (equal '("a")          (org-test-with-temp-text "[cite:@a]"            (mapcar (lambda (r) (org-element-property :key r))                    (org-cite-get-references (org-element-context))))))  ;; Preserve order of references.  (should   (equal '("a" "b")          (org-test-with-temp-text "[cite:@a;@b]"            (mapcar (lambda (r) (org-element-property :key r))                    (org-cite-get-references (org-element-context))))))  ;; Parse prefix and suffix.  (should   (equal '("a" "b")          (org-test-with-temp-text "[cite:prefix @a suffix;@b]"            (mapcar (lambda (r) (org-element-property :key r))                    (org-cite-get-references (org-element-context))))))  (should   (equal '(("prefix ") nil)          (org-test-with-temp-text "[cite:prefix @a suffix;@b]"            (mapcar (lambda (r) (org-element-property :prefix r))                    (org-cite-get-references (org-element-context))))))  (should   (equal '((" suffix") nil)          (org-test-with-temp-text "[cite:prefix @a suffix;@b]"            (mapcar (lambda (r) (org-element-property :suffix r))                    (org-cite-get-references (org-element-context))))))  ;; Ignore common prefix and suffix.  (should   (equal '("a")          (org-test-with-temp-text "[cite:common prefix; @a ; common suffix]"            (mapcar (lambda (r) (org-element-property :key r))                    (org-cite-get-references (org-element-context))))))  ;; Preserve buffer positions.  (should   (org-test-with-temp-text "[cite:@a] [cite<point>:@b]"     (= (1+ (point))        (org-element-property :begin                              (car (org-cite-get-references (org-element-context)))))))  ;; Handle citation from a full parse tree.  (should   (equal '(1 2)          (org-test-with-temp-text "[cite:@a] [cite:@a;@b]"            (org-element-map (org-element-parse-buffer) 'citation              (lambda (c) (length (org-cite-get-references c)))))))  ;; Test optional argument.  (should   (equal '("a" "b")          (org-test-with-temp-text "[cite:@a;@b]"            (org-cite-get-references (org-element-context) t))))  (should   (equal '("a" "b")          (org-test-with-temp-text "[cite:@a;@b]"            (org-element-map (org-element-parse-buffer) 'citation              (lambda (c) (org-cite-get-references c t)) nil t)))))(ert-deftest test-org-cite/key-boundaries ()  "Test `org-cite-key-boundaries'."  (should   (equal "@key"          (org-test-with-temp-text "[cite:<point>@key]"            (let ((boundaries (org-cite-key-boundaries (org-element-context))))              (buffer-substring-no-properties               (car boundaries)               (cdr boundaries))))))  (should   (equal "@key"          (org-test-with-temp-text "[cite:<point>prefix @key]"            (let ((boundaries (org-cite-key-boundaries (org-element-context))))              (buffer-substring-no-properties               (car boundaries)               (cdr boundaries))))))  (should   (equal "@key"          (org-test-with-temp-text "[cite:<point>@key suffix]"            (let ((boundaries (org-cite-key-boundaries (org-element-context))))              (buffer-substring-no-properties               (car boundaries)               (cdr boundaries))))))  (should   (equal "@key"          (org-test-with-temp-text "[cite:global ;<point>@key]"            (let ((boundaries (org-cite-key-boundaries (org-element-context))))              (buffer-substring-no-properties               (car boundaries)               (cdr boundaries))))))  (should   (equal "@key"          (org-test-with-temp-text "[cite:<point>@key; global]"            (let ((boundaries (org-cite-key-boundaries (org-element-context))))              (buffer-substring-no-properties               (car boundaries)               (cdr boundaries)))))))(ert-deftest test-org-cite/main-affixes ()  "Test `org-cite-main-affixes'."  (should   (equal '(nil . nil)          (org-test-with-temp-text "[cite:@key]"            (org-cite-main-affixes (org-element-context)))))  (should   (equal '(nil . nil)          (org-test-with-temp-text "[cite:@key1;@key2]"            (org-cite-main-affixes (org-element-context)))))  (should   (equal '(("pre ") . nil)          (org-test-with-temp-text "[cite:pre @key]"            (org-cite-main-affixes (org-element-context)))))  (should   (equal '(("pre ") . (" post"))          (org-test-with-temp-text "[cite:pre @key post]"            (org-cite-main-affixes (org-element-context)))))  (should   (equal '(("pre ") . nil)          (org-test-with-temp-text "[cite:global pre;pre @key]"            (org-cite-main-affixes (org-element-context)))))  (should   (equal '(nil . (" post"))          (org-test-with-temp-text "[cite:@key post;global post]"            (org-cite-main-affixes (org-element-context)))))  (should   (equal '(("global pre") . ("global post"))          (org-test-with-temp-text "[cite:global pre;@key1;@key2;global post]"            (org-cite-main-affixes (org-element-context)))))  (should   (equal '(("global pre") . nil)          (org-test-with-temp-text "[cite:global pre;pre1 @key1;pre2 @key2]"            (org-cite-main-affixes (org-element-context)))))  (should   (equal '(nil . (" global post"))          (org-test-with-temp-text "[cite:@key1 post1;@key2 post2; global post]"            (org-cite-main-affixes (org-element-context))))))(ert-deftest test-org-cite/supported-styles ()  "Test `org-cite-supported-styles'."  ;; Default behavior is to use export processors.  (should   (equal '((("")))          (let ((org-cite--processors nil)                (org-cite-export-processors '((t test))))            (org-cite-register-processor 'test :cite-styles '(((""))))            (org-cite-supported-styles))))  (should   (equal '((("foo" "f")) (("")))          (let ((org-cite--processors nil)                (org-cite-export-processors '((t test))))            (org-cite-register-processor 'test              :cite-styles '((("foo" "f")) ((""))))            (org-cite-supported-styles))))  ;; Explicitly provide a processor.  (should   (equal '((("")))          (let ((org-cite--processors nil))            (org-cite-register-processor 'test :cite-styles '(((""))))            (org-cite-supported-styles '(test)))))  ;; Merge style shortcuts.  (should   (equal '((("foo" "f" "g")))          (let ((org-cite--processors nil))            (org-cite-register-processor 'test :cite-styles '((("foo" "f"))))            (org-cite-register-processor 'test2 :cite-styles '((("foo" "g"))))            (org-cite-supported-styles '(test test2)))))  ;; Merge style variants.  (should   (equal '((("foo") ("bar") ("baz")))          (let ((org-cite--processors nil))            (org-cite-register-processor 'test              :cite-styles '((("foo") ("bar"))))            (org-cite-register-processor 'test2              :cite-styles '((("foo") ("baz"))))            (org-cite-supported-styles '(test test2)))))  ;; Merge variant shortcuts.  (should   (equal '((("foo") ("bar" "b" "c")))          (let ((org-cite--processors nil))            (org-cite-register-processor 'test              :cite-styles '((("foo") ("bar" "b"))))            (org-cite-register-processor 'test2              :cite-styles '((("foo") ("bar" "c"))))            (org-cite-supported-styles '(test test2)))))  ;; Ignore duplicates.  (should   (equal '((("foo") ("bar")))          (let ((org-cite--processors nil))            (org-cite-register-processor 'test              :cite-styles '((("foo") ("bar"))))            (org-cite-register-processor 'test2              :cite-styles '((("foo") ("bar"))))            (org-cite-supported-styles '(test test2)))))  (should   (equal '((("foo") ("bar" "b")))          (let ((org-cite--processors nil))            (org-cite-register-processor 'test              :cite-styles '((("foo") ("bar" "b"))))            (org-cite-register-processor 'test2              :cite-styles '((("foo") ("bar" "b"))))            (org-cite-supported-styles '(test test2))))))(ert-deftest test-org-cite/delete-citation ()  "Test `org-cite-delete-citation'."  ;; Error when not on a citation or citation reference.  (should-error   (org-test-with-temp-text "Text"     (org-cite-delete-citation (org-element-context))))  ;; When argument is a citation, delete it completely.  Manage  ;; properly blanks around it.  (should   (equal ""          (org-test-with-temp-text "[cite:@key]"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal "Before After"          (org-test-with-temp-text "Before [<point>cite:@key] After"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal "Before After"          (org-test-with-temp-text "Before [<point>cite:@key]After"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal "Before After"          (org-test-with-temp-text "Before[<point>cite:@key] After"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  ;; Ensure there is at least a blank to separate consecutive objects.  (should   (equal "Before After"          (org-test-with-temp-text "Before[<point>cite:@key]After"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  ;; Remove trailing blanks when removing the citation.  (should   (equal "Before"          (org-test-with-temp-text "Before[<point>cite:@key]  "            (org-cite-delete-citation (org-element-context))            (buffer-string))))  ;; Preserve indentation if citation is at the beginning of the line.  (should   (equal "  After"          (org-test-with-temp-text "  [<point>cite:@key] After"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  ;; When the citation is alone on a line, remove the whole line.  (should   (equal "Line 1\nLine 3"          (org-test-with-temp-text "Line 1\n[<point>cite:@key]\nLine 3"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  ;; When there is only one citation reference object, remove the full  ;; citation.  (should   (equal ""          (org-test-with-temp-text "[cite:@<point>key]"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal ""          (org-test-with-temp-text "[cite:pre @<point>key post]"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal ""          (org-test-with-temp-text "[cite:pre; @<point>key ;post]"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  ;; Otherwise, remove the reference, including any affix.  (should   (equal "[cite:@before;@after]"          (org-test-with-temp-text "[cite:@before;@<point>key;@after]"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal "[cite:@before;@after]"          (org-test-with-temp-text "[cite:@before;pre @<point>key post;@after]"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal "[cite:@before]"          (org-test-with-temp-text "[cite:@before;@<point>key]"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal "[cite:@before;post]"          (org-test-with-temp-text "[cite:@before;@<point>key;post]"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal "[cite:@after]"          (org-test-with-temp-text "[cite:@<point>key;@after]"            (org-cite-delete-citation (org-element-context))            (buffer-string))))  (should   (equal "[cite:pre;@after]"          (org-test-with-temp-text "[cite:pre;@<point>key;@after]"            (org-cite-delete-citation (org-element-context))            (buffer-string)))))(ert-deftest test-org-cite/list-bibliography-files ()  "Test `org-cite-list-bibliography-files'."  (should   (equal '("/bibliography")          (org-test-with-temp-text "#+bibliography: /bibliography"            (let ((org-cite-global-bibliography nil))              (org-cite-list-bibliography-files)))))  (should   (equal '("/bibliography")          (org-test-with-temp-text "#+bibliography: \"/bibliography\""            (let ((org-cite-global-bibliography nil))              (org-cite-list-bibliography-files)))))  (should   (equal '("/bibliography" "/other-bibliography")          (org-test-with-temp-text "#+bibliography: /bibliography"            (let ((org-cite-global-bibliography '("/other-bibliography")))              (org-cite-list-bibliography-files)))))  (should   (equal '(t)          (org-test-with-temp-text "#+bibliography: ./bibliography"            (let ((org-cite-global-bibliography nil))              (mapcar #'file-name-absolute-p (org-cite-list-bibliography-files))))))  (should   (equal '("/bibliographyA" "/bibliographyB")          (org-test-with-temp-text              "#+bibliography: /bibliographyA\n#+bibliography: /bibliographyB"            (let ((org-cite-global-bibliography nil))              (org-cite-list-bibliography-files)))))  (should   (equal '("/bibliographyA")          (org-test-with-temp-text              "#+bibliography: /bibliographyA\n#+bibliography: /bibliographyA"            (let ((org-cite-global-bibliography nil))              (org-cite-list-bibliography-files))))))(ert-deftest test-org-cite/bibliography-style ()  "Test `org-cite-bibliography-style'."  ;; Extract style from global processor definition.  (should   (equal "a"          (catch :exit            (org-test-with-temp-text "#+print_bibliography:"              (let ((org-cite-export-processors '((t . (foo "a" "b"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-bibliography (lambda (_ _ s _ _ _) (throw :exit s))                  :export-citation #'ignore)                (org-export-as (org-export-create-backend)))))))  ;; Extract style from local processor definition.  (should   (equal "a"          (catch :exit            (org-test-with-temp-text                "#+cite_export: foo a b\n#+print_bibliography:"              (let ((org-cite-export-processors nil)                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-bibliography (lambda (_ _ s _ _ _) (throw :exit s))                  :export-citation #'ignore)                (org-export-as (org-export-create-backend)))))))  (should   (equal "a b"          (catch :exit            (org-test-with-temp-text                "#+cite_export: foo \"a b\" c\n#+print_bibliography:"              (let ((org-cite-export-processors nil)                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-bibliography (lambda (_ _ s _ _ _) (throw :exit s))                  :export-citation #'ignore)                (org-export-as (org-export-create-backend)))))))  ;; Test priority: first keyword, then local.  (should   (equal "local"          (catch :exit            (org-test-with-temp-text                "#+print_bibliography:\n#+cite_export: foo local a\n[cite:@a]"              (let ((org-cite-export-processors '((t . (foo "global" "b"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-bibliography (lambda (_ _ s _ _ _) (throw :exit s))                  :export-citation #'ignore)                (org-export-as (org-export-create-backend)))))))  ;; Explicit "nil" styles forces default style.  (should-not   (catch :exit     (org-test-with-temp-text         "#+print_bibliography:\n#+cite_export: foo nil a\n[cite:@a]"       (let ((org-cite-export-processors '((t . (foo "global" "b"))))             (org-cite--processors nil))         (org-cite-register-processor 'foo           :export-bibliography (lambda (_ _ s _ _ _) (throw :exit s))           :export-citation #'ignore)         (org-export-as (org-export-create-backend)))))))(ert-deftest test-org-cite/bibliography-properties ()  "Test `org-cite-bibliography-properties'."  ;; Return nil without properties.  (should-not   (org-test-with-parsed-data "#+print_bibliography:"     (org-element-map tree 'keyword       #'org-cite-bibliography-properties info t)))  ;; Regular tests.  (should   (equal    '(:key "value")    (org-test-with-parsed-data "#+print_bibliography: :key value"      (org-element-map tree 'keyword        #'org-cite-bibliography-properties info t))))  (should   (equal    '(:key "value" :key2 "value2")    (org-test-with-parsed-data "#+print_bibliography: :key value :key2 value2"      (org-element-map tree 'keyword        #'org-cite-bibliography-properties info t))))  ;; Allow empty values.  (should   (equal    '(:key)    (org-test-with-parsed-data "#+print_bibliography: :key"      (org-element-map tree 'keyword        #'org-cite-bibliography-properties info t))))  (should   (equal    '(:key "")    (org-test-with-parsed-data "#+print_bibliography: :key \"\""      (org-element-map tree 'keyword        #'org-cite-bibliography-properties info t))))  ;; Allow space with double quotes.  (should   (equal    '(:key "space space")    (org-test-with-parsed-data "#+print_bibliography: :key \"space space\""      (org-element-map tree 'keyword        #'org-cite-bibliography-properties info t))))  ;; Ignore spurious values.  (should   (equal    '(:key "space")    (org-test-with-parsed-data "#+print_bibliography: :key space space"      (org-element-map tree 'keyword        #'org-cite-bibliography-properties info t))))  ;; Gracefully handle incomplete quotations.  (should   (equal    '(:key "\"space" :key2 "value2")    (org-test-with-parsed-data "#+print_bibliography: :key \"space :key2 value2"      (org-element-map tree 'keyword        #'org-cite-bibliography-properties info t)))))(ert-deftest test-org-cite/citation-style ()  "Test `org-cite-citation-style'."  ;; Extract style from global processor definition.  (should   (equal '("b")          (catch :exit            (org-test-with-temp-text "[cite:@a]"              (let ((org-cite-export-processors '((t . (foo "a" "b"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '("b" . "variant")          (catch :exit            (org-test-with-temp-text "[cite:@a]"              (let ((org-cite-export-processors '((t . (foo "a" "b/variant"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  ;; Extract style from local processor definition.  (should   (equal '("b")          (catch :exit            (org-test-with-temp-text "#+cite_export: foo a b\n[cite:@a]"              (let ((org-cite-export-processors nil)                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '("b c")          (catch :exit            (org-test-with-temp-text "#+cite_export: foo a \"b c\"\n[cite:@a]"              (let ((org-cite-export-processors nil)                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '("b" . "variant")          (catch :exit            (org-test-with-temp-text "#+cite_export: foo a b/variant\n[cite:@a]"              (let ((org-cite-export-processors nil)                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '("b c" . "variant")          (catch :exit            (org-test-with-temp-text                "#+cite_export: foo a \"b c/variant\"\n[cite:@a]"              (let ((org-cite-export-processors nil)                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  ;; Extract style from citation itself.  (should   (equal '("b")          (catch :exit            (org-test-with-temp-text "[cite/b:@a]"              (let ((org-cite-export-processors '((t . (foo nil nil))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '("b" . "variant")          (catch :exit            (org-test-with-temp-text "[cite/b/variant:@a]"              (let ((org-cite-export-processors '((t . (foo nil nil))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  ;; Test priority: first object, then local.  (should   (equal '("object")          (catch :exit            (org-test-with-temp-text                "#+cite_export: foo nil local\n[cite/object:@a]"              (let ((org-cite-export-processors '((t . (foo nil "global"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '("local")          (catch :exit            (org-test-with-temp-text                "#+cite_export: foo nil local\n[cite:@a]"              (let ((org-cite-export-processors '((t . (foo nil "global"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  ;; Force default style with "nil".  (should   (equal '(nil)          (catch :exit            (org-test-with-temp-text                "#+cite_export: foo nil nil\n[cite:@a]"              (let ((org-cite-export-processors '((t . (foo nil "global"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '(nil)          (catch :exit            (org-test-with-temp-text "[cite/nil:@a]"              (let ((org-cite-export-processors '((t . (foo nil "global"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  ;; Test variant inheritance.  (should   (equal '("local" . "v2")          (catch :exit            (org-test-with-temp-text "[cite/local/v2:@a]"              (let ((org-cite-export-processors '((t . (foo nil "global/v1"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '("global" . "v2")          (catch :exit            (org-test-with-temp-text "[cite//v2:@a]"              (let ((org-cite-export-processors '((t . (foo nil "global/v1"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '(nil . "v2")          (catch :exit            (org-test-with-temp-text "[cite/nil/v2:@a]"              (let ((org-cite-export-processors '((t . (foo nil "global/v1"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend)))))))  (should   (equal '("local" . nil)          (catch :exit            (org-test-with-temp-text "[cite/local:@a]"              (let ((org-cite-export-processors '((t . (foo nil "global/v1"))))                    (org-cite--processors nil))                (org-cite-register-processor 'foo                  :export-citation (lambda (_ s _ _) (throw :exit s)))                (org-export-as (org-export-create-backend))))))))(ert-deftest test-org-cite/list-citations ()  "Test `org-cite-list-citations'."  (should   (equal '("a")          (org-test-with-parsed-data "Test [cite:@a]"            (cl-mapcan (lambda (c)                         (mapcar (lambda (ref)                                   (org-element-property :key ref))                                 (org-element-contents c)))                       (org-cite-list-citations info)))))  (should   (equal '("a" "b")          (org-test-with-parsed-data "Test [cite:@a] [cite:@b]"            (cl-mapcan (lambda (c)                         (mapcar (lambda (ref)                                   (org-element-property :key ref))                                 (org-element-contents c)))                       (org-cite-list-citations info)))))  (should   (equal '("a")          (org-test-with-parsed-data "Test[fn:1]\n[fn:1] [cite:@a]"            (cl-mapcan (lambda (c)                         (mapcar (lambda (ref)                                   (org-element-property :key ref))                                 (org-element-contents c)))                       (org-cite-list-citations info)))))  (should   (equal '("a" "b")          (org-test-with-parsed-data "First[cite:@a] Second[fn:1]\n[fn:1] [cite:@b]"            (cl-mapcan (lambda (c)                         (mapcar (lambda (ref)                                   (org-element-property :key ref))                                 (org-element-contents c)))                       (org-cite-list-citations info)))))  (should   (equal '("b" "a")          (org-test-with-parsed-data "First[fn:1] Second[cite:@a]\n[fn:1] [cite:@b]"            (cl-mapcan (lambda (c)                         (mapcar (lambda (ref)                                   (org-element-property :key ref))                                 (org-element-contents c)))                       (org-cite-list-citations info)))))  (should   (equal '("a" "b")          (org-test-with-parsed-data              "Text[fn:1][fn:2]\n[fn:1] [cite:@a]\n\n[fn:2] [cite:@b]"            (cl-mapcan (lambda (c)                         (mapcar (lambda (ref)                                   (org-element-property :key ref))                                 (org-element-contents c)))                       (org-cite-list-citations info)))))  (should   (equal '("b" "a")          (org-test-with-parsed-data              "Text[fn:1]\n[fn:1] [fn:2][cite:@a]\n\n[fn:2] [cite:@b]"            (cl-mapcan (lambda (c)                         (mapcar (lambda (ref)                                   (org-element-property :key ref))                                 (org-element-contents c)))                       (org-cite-list-citations info)))))  (should   (equal '("a" "b")          (org-test-with-parsed-data              "Text[fn:1]\n[fn:1] [cite:@a][fn:2]\n\n[fn:2] [cite:@b]"            (cl-mapcan (lambda (c)                         (mapcar (lambda (ref)                                   (org-element-property :key ref))                                 (org-element-contents c)))                       (org-cite-list-citations info)))))  (should   (equal '("a")          (org-test-with-parsed-data "Text[fn::[cite:@a]]"            (cl-mapcan (lambda (c)                         (mapcar (lambda (ref)                                   (org-element-property :key ref))                                 (org-element-contents c)))                       (org-cite-list-citations info))))))(ert-deftest test-org-cite/list-keys ()  "Test `org-cite-list-keys'."  (should   (equal '("a")          (org-test-with-parsed-data "Test [cite:@a]"            (org-cite-list-keys info))))  (should   (equal '("a" "b")          (org-test-with-parsed-data "Test [cite:@a] [cite:@b]"            (org-cite-list-keys info))))  ;; Remove duplicates.  (should   (equal '("a")          (org-test-with-parsed-data "Test [cite:@a] [cite:@a]"            (org-cite-list-keys info))))  ;; Keys are ordered by first appearance in the document.  (should   (equal '("a" "b")          (org-test-with-parsed-data "Test [cite:@a] [cite:@b] [cite:@a]"            (org-cite-list-keys info))))  (should   (equal '("a" "b" "c")          (org-test-with-parsed-data              "Test [cite:@a][fn:1] [cite:@c] [cite:@a]\n[fn:1] [cite:@b]"            (org-cite-list-keys info)))))(ert-deftest test-org-cite/key-number ()  "Test `org-cite-key-number'."  (should   (= 1 (org-test-with-parsed-data "[cite:@key]"          (org-cite-key-number "key" info))))  (should   (equal '(1 2)          (org-test-with-parsed-data "[cite:@key] [cite:@key2] [cite:@key]"            (list (org-cite-key-number "key" info)                  (org-cite-key-number "key2" info)))))  ;; When "predicate" is nil, keys are sorted by appearance order in  ;; the buffer.  (should   (equal '((1 . "a") (2 . "c") (3 . "b"))          (org-test-with-parsed-data              "[cite:@a][fn:1] [cite:@b]\n[fn:1] [cite:@c]"            (sort (mapcar (lambda (key)                            (cons (org-cite-key-number key info) key))                          '("a" "b" "c"))                  #'car-less-than-car))))  (should   (equal '((1 . "a") (2 . "b") (3 . "c"))          (org-test-with-parsed-data              "[cite:@a][fn:1] [cite:@b]\n[fn:1] [cite:@c]"            (sort (mapcar (lambda (key)                            (cons (org-cite-key-number key info #'string<) key))                          '("a" "b" "c"))                  #'car-less-than-car)))))(ert-deftest test-org-cite/wrap-citation ()  "Test `org-cite-wrap-citation'."  ;; Reference test.  (should   (org-test-with-parsed-data "[cite:@key]"     (org-element-map tree 'citation       (lambda (c)         (org-cite-wrap-citation c info)         (org-cite-inside-footnote-p c))       info)))  ;; Created footnote is anonymous.  (should-not   (org-test-with-parsed-data "[cite:@key]  "     (org-element-map tree 'citation       (lambda (c)         (org-cite-wrap-citation c info)         (org-element-property :label (org-cite-inside-footnote-p c)))       info)))  ;; Created footnote is inline.  (should   (equal '(inline)          (org-test-with-parsed-data "[cite:@key]"            (org-element-map tree 'citation              (lambda (c)                (org-cite-wrap-citation c info)                (org-element-property :type                                      (org-cite-inside-footnote-p c)))              info))))  ;; Preserve `:post-blank' property.  (should   (equal '(2)          (org-test-with-parsed-data "[cite:@key]  "            (org-element-map tree 'citation              (lambda (c)                (org-cite-wrap-citation c info)                (org-element-property :post-blank                                      (org-cite-inside-footnote-p c)))              info))))  ;; Set `:post-blank' to 0 in the element before new footnote.  (should-not   (org-test-with-parsed-data "Text [cite:@key]"     (org-element-map tree 'citation       (lambda (c)         (org-cite-wrap-citation c info)         (let ((previous                (org-export-get-previous-element                 (org-cite-inside-footnote-p c) info)))           (string-match (rx blank string-end) previous)))       info)))  (should   (equal '(0)          (org-test-with-parsed-data "*Text* [cite:@key]"            (org-element-map tree 'citation              (lambda (c)                (org-cite-wrap-citation c info)                (let ((previous                       (org-export-get-previous-element                        (org-cite-inside-footnote-p c) info)))                  (org-element-property :post-blank previous)))              info))))  (should   (equal '("Text")          (org-test-with-parsed-data "Text [cite:@key]"            (org-element-map tree 'citation              (lambda (c)                (org-cite-wrap-citation c info)                (org-export-get-previous-element                 (org-cite-inside-footnote-p c) info))              info)))))(defun test-org-cite--export-with-rule (text &optional rule punct)  "Export TEXT string using RULE for punctuation positioning.Call `org-cite-adjust-note' on each citation object with RULE and, PUNCTarguments.  Replace citation with \"@\" character in the output."  (org-test-with-temp-text text    (let ((org-cite--processors nil))      (org-cite-register-processor 'test        :export-citation        (lambda (citation _s _b info)          (org-cite-adjust-note citation info rule punct)          "@"))      (let ((org-cite-export-processors '((t . (test nil nil)))))        (org-trim         (org-export-as	  (org-export-create-backend	   :transcoders	   '((section . (lambda (_s c _i) (replace-regexp-in-string " @" "@" c)))             (paragraph . (lambda (_s c _i) c))))))))))(ert-deftest test-org-cite/adjust-note ()  "Test `org-cite-adjust-note' function."  ;; Basic tests for all rules.  In the output, @ replaces citation.  (let ((cases '("\"[cite:@k]!"                 ".\"[cite:@k]!"                 "\"[cite:@k]"                 ".\"[cite:@k]"                 ".[cite:@k]"                 "[cite:@k]!")))    (should                             ;test (inside inside after)     (equal      '(iia "!@\"" ".@\"!" "@\"" ".@\"" ".@" "!@")      (cons 'iia            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(inside inside after)))                    cases))))    (should                             ;test (inside inside before)     (equal      '(iib "@!\"" "@.\"!" "@\"" "@.\"" "@." "@!")      (cons 'iib            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(inside inside before)))                    cases))))    (should                             ;test (inside outside after)     (equal      '(ioa "!\"@" ".\"!@" "\"@" ".\"@" ".@" "!@")      (cons 'ioa            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(inside outside after)))                    cases))))    (should                             ;test (inside outside before)     (equal      '(iob "!\"@" ".\"@!" "\"@" ".\"@" "@." "@!")      (cons 'iob            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(inside outside before)))                    cases))))    (should                             ;test (inside same after)     (equal      '(isa "!@\"" ".\"!@" "\"@" ".@\"" ".@" "!@")      (cons 'isa            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(inside same after)))                    cases))))    (should                             ;test (inside same before)     (equal      '(isb "@!\"" ".\"@!" "\"@" "@.\"" "@." "@!")      (cons 'isb            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(inside same before)))                    cases))))    (should                             ;test (outside inside after)     (equal      '(oia "@\"!" ".@\"!" "@\"" "@\"." ".@" "!@")      (cons 'oia            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(outside inside after)))                    cases))))    (should                             ;test (outside inside before)     (equal      '(oib "@\"!" "@.\"!" "@\"" "@\"." "@." "@!")      (cons 'oib            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(outside inside before)))                    cases))))    (should                             ;test (outside outside after)     (equal      '(ooa "\"!@" ".\"!@" "\"@" "\".@" ".@" "!@")      (cons 'ooa            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(outside outside after)))                    cases))))    (should                             ;test (outside outside before)     (equal      '(oob "\"@!" ".\"@!" "\"@" "\"@." "@." "@!")      (cons 'oob            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(outside outside before)))                    cases))))    (should                             ;test (outside same after)     (equal      '(osa "\"!@" ".\"!@" "\"@" "\".@" ".@" "!@")      (cons 'osa            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(outside same after)))                    cases))))    (should                             ;test (outside same before)     (equal      '(osb "\"@!" ".\"@!" "\"@" "\"@." "@." "@!")      (cons 'osb            (mapcar (lambda (c)                      (test-org-cite--export-with-rule                       c '(outside same before)))                    cases)))))  ;; Test `adaptive' behaviour.  (should   (equal "@\"."          (test-org-cite--export-with-rule ".\" [cite:@k]"                                           '(adaptive inside after))))  (should   (equal "@\"!"          (test-org-cite--export-with-rule "\" [cite:@k]!"                                           '(adaptive inside after))))  (should   (equal ".@\""          (test-org-cite--export-with-rule ".\"[cite:@k]"                                           '(adaptive inside after))))  (should   (equal "!@\""          (test-org-cite--export-with-rule "\"[cite:@k]!"                                           '(adaptive inside after))))  ;; Handle white space when inserting citation before quotation mark  ;; or punctuation.  (should   (equal ",@\" next"          (test-org-cite--export-with-rule ",\" [cite:@k] next"                                           '(inside inside after))))  (should   (equal "@,\" next"          (test-org-cite--export-with-rule ",\" [cite:@k] next"                                           '(inside inside before))))  (should   (equal "@\"."          (test-org-cite--export-with-rule "\" [cite:@k]."                                           '(outside inside before))))  (should   (equal "@\" !"          (test-org-cite--export-with-rule "\" [cite:@k] !"                                           '(outside inside before))))  (should   (equal "text@ !"          (test-org-cite--export-with-rule "text ![cite:@k]"                                           '(inside outside before))))  ;; Preserve white space between citation and final punctuation when  ;; moving citation past final punctuation.  (should   (equal "text !@"          (test-org-cite--export-with-rule "text [cite:@k] !"                                           '(inside inside after))))  (should   (equal "text\n !@"          (test-org-cite--export-with-rule "text [cite:@k]\n !"                                           '(inside inside after))))  ;; Choose punctuation with optional argument.  (should-not   (equal "!@"          (test-org-cite--export-with-rule "[cite:@k]!"                                           '(inside outside after)                                           '("."))))  (should   (equal ".@"          (test-org-cite--export-with-rule "[cite:@k]."                                           '(inside outside after)                                           '(".")))))(ert-deftest test-org-cite/parse-elements ()  "Test `org-cite-parse-elements' function."  (should-error (org-cite-parse-elements "* H"))  (should-error (org-cite-parse-elements "Paragraph\n* H"))  (should   (equal '(paragraph)          (mapcar #'org-element-type (org-cite-parse-elements "s"))))  (should   (equal '(paragraph paragraph)          (mapcar #'org-element-type (org-cite-parse-elements "Text\n\nText")))))(ert-deftest test-org-cite/parse-objects ()  "Test `org-cite-parse-objects' function."  (should   (equal '(plain-text)          (mapcar #'org-element-type (org-cite-parse-objects "s"))))  (should   (equal '(plain-text bold)          (mapcar #'org-element-type (org-cite-parse-objects "s *b*"))))  (should   (equal '(link)          (mapcar #'org-element-type (org-cite-parse-objects "[[link]]"))))  ;; When optional argument is non-nil, only recognize types allowed  ;; in as a citation reference affix.  (should-not   (equal '(link)          (mapcar #'org-element-type (org-cite-parse-objects "[[link]]" t))))  (should   (equal '(bold)          (mapcar #'org-element-type (org-cite-parse-objects "*b*" t)))))(ert-deftest test-org-cite/make-paragraph ()  "Test `org-cite-make-paragraph' function."  ;; Check string as argument.  (should   (eq 'paragraph       (org-element-type (org-cite-make-paragraph "a"))))  (should   (equal '("a")          (org-element-contents (org-cite-make-paragraph "a"))))  ;; Check object as argument.  (should   (eq 'paragraph       (org-element-type        (org-cite-make-paragraph (org-element-create 'bold nil "b")))))  (should   (equal '(bold)          (mapcar #'org-element-type                  (org-element-contents                   (org-cite-make-paragraph (org-element-create 'bold nil "b"))))))  ;; Check secondary string as argument.  (should   (eq 'paragraph       (org-element-type (org-cite-make-paragraph '("a")))))  (should   (equal '("a")          (org-element-contents (org-cite-make-paragraph '("a")))))  ;; Mix all types of arguments.  (should   (equal '(plain-text bold plain-text)          (mapcar #'org-element-type                  (org-element-contents                   (org-cite-make-paragraph                    "a" (org-element-create 'bold nil "b") '("c"))))))  ;; Check `:parent' property.  (should   (eq 'paragraph       (org-element-type        (org-element-property         :parent         (car (org-element-contents (org-cite-make-paragraph "a"))))))))(ert-deftest test-org-cite/emphasize ()  "Test `org-cite-emphasize' function."  ;; Raise an error if first argument has wrong type.  (should-error (org-cite-emphasize 'code "a"))  ;; Check string argument.  (should (eq 'bold (org-element-type (org-cite-emphasize 'bold "a"))))  (should (equal '("a") (org-element-contents (org-cite-emphasize 'bold "a"))))  ;; Check object argument.  (should   (eq 'bold       (org-element-type        (org-cite-emphasize 'bold (org-element-create 'bold nil "a")))))  (should   (equal '(italic)          (mapcar #'org-element-type                  (org-element-contents                   (org-cite-emphasize 'bold                     (org-element-create 'italic nil "a"))))))  ;; Check secondary string argument.  (should (eq 'bold (org-element-type (org-cite-emphasize 'bold '("a")))))  (should (equal '("a") (org-element-contents (org-cite-emphasize 'bold '("a")))))  ;; Mix all types of arguments.  (should   (equal '(plain-text italic plain-text)          (mapcar #'org-element-type                  (org-element-contents                   (org-cite-emphasize 'bold                     "a" (org-element-create 'italic nil "b") '("c"))))))  ;; Check `:parent' property.  (should   (eq 'bold       (org-element-type        (org-element-property         :parent         (car (org-element-contents (org-cite-emphasize 'bold "a"))))))))(ert-deftest test-org-cite/concat ()  "Test `org-cite-concat' function."  ;; Return nil when there is no data.  (should   (equal "" (org-element-interpret-data (org-cite-concat))))  ;; Concatenate strings, objects and secondary strings.  (should   (equal "ab"          (org-element-interpret-data (org-cite-concat "a" "b"))))  (should   (equal "*a* b"          (org-element-interpret-data           (org-cite-concat (org-element-create 'bold nil "a") " b"))))  (should   (equal "*a* b"          (org-element-interpret-data           (org-cite-concat            (list (org-element-create 'bold nil "a")) " b"))))  ;; Return an error for any other object type.  (should-error (org-cite-concat 2)))(ert-deftest test-org-cite/mapconcat ()  "Test `org-cite-mapconcat' function."  (should   (equal ""          (org-element-interpret-data           (org-cite-mapconcat #'identity nil ""))))  (should   (equal "ab"          (org-element-interpret-data           (org-cite-mapconcat #'identity '("a" "b") ""))))  (should   (equal "*a* b *c*"          (org-element-interpret-data           (org-cite-mapconcat            #'identity            (list (org-element-create 'bold nil "a")                  (list " b " (org-element-create 'bold nil "c"))) ""))))  (should   (equal "*a* *b*"          (org-element-interpret-data           (org-cite-mapconcat            (lambda (s) (org-element-create 'bold nil s))            '("a" "b") " "))))  (should   (equal "*a* b*c*"          (org-element-interpret-data           (org-cite-mapconcat            #'identity            (list (org-element-create 'bold nil "a")                  (list "b" (org-element-create 'bold nil "c"))) " ")))));;; Test capabilities.(ert-deftest test-org-cite/activate-capability ()  "Test \"activate\" capability."  ;; Standard test.  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "[cite:@key]"           (let ((org-cite--processors nil)                 (org-cite-activate-processor 'foo))             (org-cite-register-processor 'foo               :activate (lambda (_) (throw :exit 'success)))             (font-lock-ensure))))))  ;; If there is no "follow" processor, or if processor does not  ;; handle this capability, fall back to fontifying whole citation  ;; with `org-cite' face and each key with `org-cite-key' face.  (should   (eq 'org-cite       (org-test-with-temp-text "[cite:@key]"         (let ((org-cite-activate-processor nil))           (font-lock-ensure)           (face-at-point)))))  (should   (eq 'org-cite-key       (org-test-with-temp-text "[cite:@<point>key]"         (let ((org-cite-activate-processor nil))           (font-lock-ensure)           (face-at-point)))))  (should   (eq 'org-cite       (org-test-with-temp-text "[cite:@key]"         (let ((org-cite--processors nil)               (org-cite-activate-processor 'foo))           (org-cite-register-processor 'foo)           (font-lock-ensure)           (face-at-point))))))(ert-deftest test-org-cite/export-capability ()  "Test \"export\" capability."  ;; Regular citations export.  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "[cite:@key]"           (let ((org-cite--processors nil)                 (org-cite-export-processors '((t . (foo nil nil)))))             (org-cite-register-processor 'foo               :export-citation (lambda (&rest _) (throw :exit 'success)))             (org-export-as (org-export-create-backend)))))))  ;; Export citation as string.  (should   (equal "citation\n"          (org-test-with-temp-text "[cite:@key]"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-citation (lambda (&rest _) "citation"))              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c)))))))))  ;; Export citation as parsed object.  (should   (equal "success\n"          (org-test-with-temp-text "[cite:@key]"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-citation (lambda (&rest _)                                   (org-element-create 'bold nil "cite")))              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c))                                (bold . (lambda (&rest _) "success")))))))))  ;; Export citation as a secondary string.  (should   (equal "boldtwo\n"          (org-test-with-temp-text "[cite:@key]"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-citation (lambda (&rest _)                                   (list (org-element-create 'bold nil "one")                                         "two")))              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c))                                (bold . (lambda (&rest _) "bold")))))))))  ;; When exporting citation as a secondary string, last object  ;; inherits post-blank from initial citation.  (should   (equal "twobold one-space\n"          (org-test-with-temp-text "[cite:@key] one-space"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-citation (lambda (&rest _)                                   (list "two"                                         (org-element-create 'bold nil "one"))))              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c))                                (bold . (lambda (&rest _) "bold")))))))))  (should   (equal "boldtwo one-space\n"          (org-test-with-temp-text "[cite:@key] one-space"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-citation (lambda (&rest _)                                   (list (org-element-create 'bold nil "one")                                         "two")))              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c))                                (bold . (lambda (&rest _) "bold")))))))))  ;; Make sure to have a space between a quote and a citation.  (should   (equal "\"quotation\" citation\n"          (org-test-with-temp-text "\"quotation\"[cite:@key]"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-citation (lambda (&rest _) "citation"))              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c)))))))))  (should   (equal "\"quotation\"  citation\n"          (org-test-with-temp-text "\"quotation\"  [cite:@key]"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-citation (lambda (&rest _) "citation"))              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c)))))))))  ;; Regular bibliography export.  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "#+print_bibliography:"           (let ((org-cite--processors nil)                 (org-cite-export-processors '((t . (foo nil nil)))))             (org-cite-register-processor 'foo               :export-bibliography (lambda (&rest _) (throw :exit 'success))               :export-citation #'ignore)             (org-export-as (org-export-create-backend)))))))  (should   (equal ""          (org-test-with-temp-text "#+print_bibliography:"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-citation #'ignore)              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c)))))))))  ;; Export bibliography as string.  (should   (equal "bibliography\n"          (org-test-with-temp-text "#+print_bibliography:"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-bibliography (lambda (&rest _) "bibliography")                :export-citation #'ignore)              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c)))))))))  ;; Export bibliography as a parsed element.  (should   (equal "success\n"          (org-test-with-temp-text "#+print_bibliography:"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-bibliography                (lambda (&rest _)                  (org-element-create 'example-block '(:value "foo")))                :export-citation #'ignore)              (org-export-as               (org-export-create-backend                :transcoders                '((section . (lambda (_ c _) c))                  (example-block . (lambda (&rest _) "success")))))))))  ;; Export bibliography as a list of parsed elements.  (should   (equal "success\nsuccess\n"          (org-test-with-temp-text "#+print_bibliography:"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-bibliography                (lambda (&rest _)                  (list (org-element-create 'example-block '(:value "foo"))                        (org-element-create 'example-block '(:value "bar"))))                :export-citation #'ignore)              (org-export-as               (org-export-create-backend                :transcoders                '((section . (lambda (_ c _) c))                  (example-block . (lambda (&rest _) "success")))))))))  ;; When exporting bibliography as a list of parsed elements, the  ;; last element inherits post-blank from initial keyword.  (should   (equal "success\nsuccess\n\nText\n"          (org-test-with-temp-text "#+print_bibliography:\n\nText"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-bibliography                (lambda (&rest _)                  (list (org-element-create 'example-block '(:value "foo"))                        (org-element-create 'example-block '(:value "bar"))))                :export-citation #'ignore)              (org-export-as               (org-export-create-backend                :transcoders                '((section . (lambda (_ c _) c))                  (example-block . (lambda (&rest _) "success"))                  (paragraph . (lambda (_ c _) c)))))))))  ;; Use more appropriate citation processor.  (should   (equal    '(p1 p1 p1 p3)    (org-test-with-temp-text "[cite:@a]"      (let ((org-export-registered-backends nil)            (org-cite--procesors nil)            (org-cite-export-processors             '((b1 . (p1))               (t  . (p3)))))        (org-cite-register-processor 'p1          :export-citation (lambda (&rest _) (throw :exit 'p1)))        (org-cite-register-processor 'p2          :export-citation (lambda (&rest _) (throw :exit 'p2)))        (org-cite-register-processor 'p3          :export-citation (lambda (&rest _) (throw :exit 'p3)))        (org-export-define-backend 'b1 nil)        (org-export-define-derived-backend 'b2 'b1)        (org-export-define-derived-backend 'b3 'b2)        (list (catch :exit (org-export-as 'b1))              (catch :exit (org-export-as 'b2))              (catch :exit (org-export-as 'b3))              (catch :exit (org-export-as (org-export-create-backend))))))))  (should   (eq 'p2       (org-test-with-temp-text "#+cite_export: p2\n[cite:@a]"         (let ((org-export-registered-backends nil)               (org-cite--procesors nil)               (org-cite-export-processors '((t  . (p1)))))           (org-cite-register-processor 'p1             :export-citation (lambda (&rest _) (throw :exit 'p1)))           (org-cite-register-processor 'p2             :export-citation (lambda (&rest _) (throw :exit 'p2)))           (catch :exit (org-export-as (org-export-create-backend)))))))  ;; Test finalizer.  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "[cite:@key]"           (let ((org-cite--processors nil)                 (org-cite-export-processors '((t . (foo nil nil)))))             (org-cite-register-processor 'foo               :export-citation (lambda (&rest _) "")               :export-finalizer (lambda (&rest _) (throw :exit 'success)))             (org-export-as (org-export-create-backend)))))))  (should   (equal "finalized!"          (org-test-with-temp-text "[cite:@key]"            (let ((org-cite--processors nil)                  (org-cite-export-processors '((t . (foo nil nil)))))              (org-cite-register-processor 'foo                :export-citation #'ignore                :export-finalizer (lambda (&rest _) "finalized!"))              (org-export-as (org-export-create-backend))))))  ;; Ignore citations when there is no selected "export" processor.  ;; In that case, white space is removed before the citation, not  ;; after.  (should   (equal ""          (org-test-with-temp-text "[cite:@key]"            (let ((org-cite-export-processors nil))              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c)))))))))  (should   (equal "Text.\n"          (org-test-with-temp-text "Text [cite:@key]."            (let ((org-cite-export-processors nil))              (org-export-as (org-export-create-backend                              :transcoders                              '((section . (lambda (_ c _) c))                                (paragraph . (lambda (_ c _) c)))))))))  ;; Throw an error if selected processor does not handle "export"  ;; capability.  (should-error   (org-test-with-temp-text "[cite:@key]"     (let ((org-cite--processors nil)           (org-cite-export-processors '((t . (foo nil nil)))))       (org-cite-register-processor 'foo)       (org-export-as (org-export-create-backend))))))(ert-deftest test-org-cite/follow-capability ()  "Test \"follow\" capability."  ;; Standard test.  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "[cite:@key]"           (let ((org-cite--processors nil)                 (org-cite-follow-processor 'foo))             (org-cite-register-processor 'foo               :follow (lambda (_ _) (throw :exit 'success)))             (org-open-at-point))))))  ;; Throw an error if there is no "follow" processor, or if it is  ;; unable to follow a citation.  (should-error   (org-test-with-temp-text "[cite:@key]"     (let ((org-cite-follow-processor nil))       (org-open-at-point))))  (should-error   (org-test-with-temp-text "[cite:@key]"     (let ((org-cite--processors nil)           (org-cite-follow-processor 'foo))       (org-cite-register-processor 'foo)       (org-open-at-point)))))(ert-deftest test-org-cite/make-insert-processor ()  "Test `org-cite-make-insert-processor'."  (should-error (org-cite-make-insert-processor 1 2))  (should-error   (org-test-with-temp-text "[cite:@<point>a]"     (let ((org-cite--processors nil)           (org-cite-insert-processor 'foo))       (org-cite-register-processor 'foo         :insert (org-cite-make-insert-processor                  #'ignore (lambda (&rest _) "s")))       (org-cite-insert nil))))  (should   (equal "[cite:@k]"          (org-test-with-temp-text "[cite:@<point>a]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal "[cite:@k;@a]"          (org-test-with-temp-text "[cite:<point>@a]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal "[cite:@k;pre @a]"          (org-test-with-temp-text "[cite:<point>pre @a]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal "[cite:pre;@k;@a]"          (org-test-with-temp-text "[cite:<point>pre;@a]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal "[cite:@a;@k]"          (org-test-with-temp-text "[cite:@a<point>]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal "[cite:@a post;@k]"          (org-test-with-temp-text "[cite:@a post<point>]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal "[cite:@a;@k;post]"          (org-test-with-temp-text "[cite:@a;post<point>]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal ""          (org-test-with-temp-text "[cite:@<point>a]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "s")))              (org-cite-insert t)              (buffer-string)))))  (should   (equal "[cite/s:@a]"          (org-test-with-temp-text "[cite<point>:@a]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal "[cite:@a]"          (org-test-with-temp-text "[cite<point>/style:@a]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) "k") (lambda (&rest _) "")))              (org-cite-insert nil)              (buffer-string)))))  (should-error   (org-test-with-temp-text "[cite<point>/style:@a]"     (let ((org-cite--processors nil)           (org-cite-insert-processor 'foo))       (org-cite-register-processor 'foo         :insert (org-cite-make-insert-processor                  (lambda (&rest _) "k") #'ignore))       (org-cite-insert nil))))  (should   (equal "[cite:@a][cite:@k]"          (org-test-with-temp-text "[cite:@a]<point>"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) '("k")) (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal "[cite:@k][cite:@a]"          (org-test-with-temp-text "<point>[cite:@a]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) '("k")) (lambda (&rest _) "s")))              (org-cite-insert nil)              (buffer-string)))))  (should   (equal "[cite/s:@k][cite:@a]"          (org-test-with-temp-text "<point>[cite:@a]"            (let ((org-cite--processors nil)                  (org-cite-insert-processor 'foo))              (org-cite-register-processor 'foo                :insert (org-cite-make-insert-processor                         (lambda (&rest _) '("k")) (lambda (&rest _) "s")))              (org-cite-insert t)              (buffer-string))))))(ert-deftest test-org-cite/insert-capability ()  "Test \"insert\" capability."  ;; Standard test.  (should   (eq 'success       (catch :exit         (org-test-with-temp-text ""           (let ((org-cite--processors nil)                 (org-cite-insert-processor 'foo))             (org-cite-register-processor 'foo               :insert (lambda (_ _) (throw :exit 'success)))             (call-interactively #'org-cite-insert))))))  ;; Throw an error if there is no "insert" processor, or if it is  ;; unable to insert a citation.  (should-error   (org-test-with-temp-text ""     (let ((org-cite-insert-processor nil))       (call-interactively #'org-cite-insert))))  (should-error   (org-test-with-temp-text ""     (let ((org-cite--processors nil)           (org-cite-insert-processor 'foo))       (org-cite-register-processor 'foo)       (call-interactively #'org-cite-insert))))  ;; Throw an error if the location is inappropriate for a citation.  (should-error   (org-test-with-temp-text "=verbatim<point> text="     (let ((org-cite--processors nil)           (org-cite-insert-processor 'foo))       (org-cite-register-processor 'foo         :insert (lambda (_ _) (throw :exit 'success)))       (call-interactively #'org-cite-insert))))  ;; Allow inserting citations at the beginning of a footnote  ;; definition, right after the label.  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "[fn:1]<point>"           (let ((org-cite--processors nil)                 (org-cite-insert-processor 'foo))             (org-cite-register-processor 'foo               :insert (lambda (_ _) (throw :exit 'success)))             (call-interactively #'org-cite-insert))))))  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "[fn:1] <point>"           (let ((org-cite--processors nil)                 (org-cite-insert-processor 'foo))             (org-cite-register-processor 'foo               :insert (lambda (_ _) (throw :exit 'success)))             (call-interactively #'org-cite-insert))))))  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "[fn:1]<point>\nParagraph"           (let ((org-cite--processors nil)                 (org-cite-insert-processor 'foo))             (org-cite-register-processor 'foo               :insert (lambda (_ _) (throw :exit 'success)))             (call-interactively #'org-cite-insert))))))  (should-error   (org-test-with-temp-text "[fn:1<point>]"     (let ((org-cite--processors nil)           (org-cite-insert-processor 'foo))       (org-cite-register-processor 'foo         :insert (lambda (_ _) (throw :exit 'success)))       (call-interactively #'org-cite-insert))))  (should-error   (org-test-with-temp-text "<point>[fn:1]"     (let ((org-cite--processors nil)           (org-cite-insert-processor 'foo))       (org-cite-register-processor 'foo         :insert (lambda (_ _) (throw :exit 'success)))       (call-interactively #'org-cite-insert))))  ;; Allow inserting citations in captions.  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "#+caption: <point>\n| table |"           (let ((org-cite--processors nil)                 (org-cite-insert-processor 'foo))             (org-cite-register-processor 'foo               :insert (lambda (_ _) (throw :exit 'success)))             (call-interactively #'org-cite-insert))))))  ;; Allow inserting citations in table cells.  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "| <point>table |"           (let ((org-cite--processors nil)                 (org-cite-insert-processor 'foo))             (org-cite-register-processor 'foo               :insert (lambda (_ _) (throw :exit 'success)))             (call-interactively #'org-cite-insert))))))  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "| table<point> |"           (let ((org-cite--processors nil)                 (org-cite-insert-processor 'foo))             (org-cite-register-processor 'foo               :insert (lambda (_ _) (throw :exit 'success)))             (call-interactively #'org-cite-insert))))))  (should   (eq 'success       (catch :exit         (org-test-with-temp-text "| table  <point> |"           (let ((org-cite--processors nil)                 (org-cite-insert-processor 'foo))             (org-cite-register-processor 'foo               :insert (lambda (_ _) (throw :exit 'success)))             (call-interactively #'org-cite-insert)))))))(provide 'test-oc);;; test-oc.el ends here
 |