From 567ca17c84290ce472d8618581821cc308382d53 Mon Sep 17 00:00:00 2001 From: Andrea Amantini Date: Fri, 5 Apr 2024 11:23:55 +0200 Subject: [PATCH] Prepare for footnote refs --- .../markdown/parser2/types$fn__1950.class | Bin 0 -> 1395 bytes .../parser2/types$footnote_ref_getLabel.class | Bin 0 -> 1686 bytes .../parser2/types$footnote_ref_init.class | Bin 0 -> 1463 bytes .../types$loading__6798__auto____1948.class | Bin 0 -> 1614 bytes .../markdown/parser2/types/Footnote.class | Bin 5761 -> 5761 bytes .../markdown/parser2/types/FootnoteRef.class | Bin 0 -> 5693 bytes .../parser2/types/InlineFormula.class | Bin 6444 -> 6444 bytes .../markdown/parser2/types__init.class | Bin 4250 -> 4819 bytes src/nextjournal/markdown/parser2.clj | 5 +- .../markdown/parser2/footnotes.clj | 57 +++++++++--------- src/nextjournal/markdown/parser2/types.clj | 16 ++++- 11 files changed, 44 insertions(+), 34 deletions(-) create mode 100644 classes/nextjournal/markdown/parser2/types$fn__1950.class create mode 100644 classes/nextjournal/markdown/parser2/types$footnote_ref_getLabel.class create mode 100644 classes/nextjournal/markdown/parser2/types$footnote_ref_init.class create mode 100644 classes/nextjournal/markdown/parser2/types$loading__6798__auto____1948.class create mode 100644 classes/nextjournal/markdown/parser2/types/FootnoteRef.class diff --git a/classes/nextjournal/markdown/parser2/types$fn__1950.class b/classes/nextjournal/markdown/parser2/types$fn__1950.class new file mode 100644 index 0000000000000000000000000000000000000000..09a5ef5c4e278e2c1c722fc28ef83b610f01fe75 GIT binary patch literal 1395 zcmbVMTT|Ll5dIFLV2nla($Z>c#VVkJ@zSc;3sq^g^d^ooePTj5+F(eW5WM`W7H3-R zL&xX-s7^Nt2#UUxnZurMIqdoN?6>>p@2}qg=8<8T)cLVhG%BVpYl)IwAe*x}qzVYUn<+F?2fTf=vYy8 z)q26u7K!eN=zvdv7k&m&)ent*p0#94RT%ms(M(Z3l-+nA^F^*$Nd~`S=w&OHn_&oM zu3Whzn@JHOx;x>)9fqFkzxvR_Anb8#OFr5%3`;~1T>^U1cm422ns^U1E|Wyub>rS^ zIA=xNcbyL?E0;XOc%+r}4T*>t#=|ZQ;!z{uoQTJ6z|n?tz9r98TBkh6@Wjq@oMH2Z z8(TTFdTwDAu~|h$2=?1}FiBKa6s=Y>vG%5M#W1-aaR#4alu8wg097P#<;l0UeVC;> zAIc`fVl&IEWvcpKvWZj86TPXV^H>ltho=nf1#a?PKNcCfW11lscwt&o^W~Ty%M4zU zM$wNIhS4VR#_QsZ*Tfrl#OMb}u`5taXg<7h%4u;^XGs1JZ8s1V=`~gbq_B2f zUsOUL(!_YxC~$hVjH>ewl~SIY+j3qbkC3I#Q+QgnLB9*uc)qf?er$2QOnn83isPkj zZAZu!J?%oaNF7VMbS%lqu_P9vFQP(_#=RZN^C=Eb+maD&9p4sC}G&>El>rp4&~diWs+ z6TdS|HU8NkGJVPU3*~HoQo%$}I>WOI^qwL>V5ts51d??yMBsTHgjw+A8P+fG<`fgH z`FgNPfjva`9oeth_o+{UJGJZ~B&@o_O^9VjF1Kl6azq-r9Bo3A=x&*q_5>7S89@q5 LQ_`{|#Mb`-w-QVl literal 0 HcmV?d00001 diff --git a/classes/nextjournal/markdown/parser2/types$footnote_ref_getLabel.class b/classes/nextjournal/markdown/parser2/types$footnote_ref_getLabel.class new file mode 100644 index 0000000000000000000000000000000000000000..091bce41ca5dc6617ef2336c395bbd635aa60311 GIT binary patch literal 1686 zcmbVNZBrXn6n<_3Y_drOQ;JY*8{1k#Qb~!Z6tFE)Vv#^=LP7My&Str!n{0QP%?8?k z;vaDQs_l%0I^*=SKT3UWHl+z<#u;b!?!EWyx%WKhIWPOy->?4!FpKX6=3MzKsCzBn zHJ$uZ({Jp0hi-n~^qbNza^8(ikq~Xgwqb7rrS(T0kAuwh+UcKeZykokx z{8F*yT7m7k8lnR6_Tg#EsS6A(+O8ek5r}4{wvrfvregpxfu!vocnw(z%)qt;Ze&Vz z^S}(RdswYYD_EF1E8;oB2%fauhGEBq)AW_)o%+QJWg z;id7Bjw`szpoA8ZxQ;{ullYiMd%W(ZQNt&U9^Fr3N~vd%6-XFH(`H_TK}h#9x+b3= zdj4)0iVD@p?@fHF_?;FQ?`KJAX}Cp>_RN+;it~LOo$58y4U!fL_$+}L%nA$yPwb|O z^O=ldWKPR8%q5{Cp%dLa^JLL-IvJbn0G+lxpHcgY;C3YoA%?pG!#!SV-HXsZ*W;pV=qwrVTS0_ir{P#Dn&8wL=?gep?5##J(Lj;ZqIJOE}i*p*P` z?hv3m zCw1=##W%R{66gQGgB_9j_6QrV@EvjI3H>ZJ5p4192nMmuxn5acdZdS)T-A)e95#GC mTS=cRi+V0SlRjzp`hWjY)L%i*mh{=ewV9iR`PqV=UHKQMVyh1T literal 0 HcmV?d00001 diff --git a/classes/nextjournal/markdown/parser2/types$footnote_ref_init.class b/classes/nextjournal/markdown/parser2/types$footnote_ref_init.class new file mode 100644 index 0000000000000000000000000000000000000000..284028ca1d3e0b55c3a8f304be52cb0ff0ce9bfa GIT binary patch literal 1463 zcmbVMYf}EMERq=}b{G zHGb|#HJt@UM4g)Y0PlGZ=RD`(Ip;k;e|`G_Ab~7HLgR;KS+5zIq(=56V|QCW&>|Jd zsB$A7F^?*|I=-Xprly;`VDO!SqA8{T#xNwSdbwush$?BN$YQ3Z$)=)f0_+U#M&gXD zmKnNIR>}f{Js8^bpbLTs2V4vuMcdbRdCrtfMP`@?X3NsP)P#FeEOXgRhAz7pd>w_? zxlvWBCfCeO%Fqn~9tLN6Z9Tum;LrXsHt9hx`rPP2KZ8rwwW?VtL>auDX`7NkkzQPP z!-fHd{ti(3RlpE~SmNe}bg)5UF$@H+pzgs9jEES<=tYc`4C!`@ycZP^aJ$VcMxu8z zTjfUwy0J~{0=Q$byUWnm!EPfjV4R_6PpZ7tln*sdDOHAe@cm_JL!IC&ZE4q}3e}jv zq=jrmWj;4}^+J$*C_9cU1?mWw!X((DLc@Dkh zxu8^YKvH;O$+O_XEQ7GyYz;%|e-PV^UBq(>b%|!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markdown/parser2/types/InlineFormula.class b/classes/nextjournal/markdown/parser2/types/InlineFormula.class index 3edab3f181a81275dc5df638cf81f1a989291304..1a209be1677dd019a63642db5201a9f1c19766b6 100644 GIT binary patch delta 1015 zcmZ9JOH31C5XWcOLc8r(wUkmqC?U}pD5(h?R8EQ-E)pba#1{xEDk>_Vp!mWU;`@QlcA*G|{dT{d$NxX`YbkCiK2a?@tqqD^ zq3qTXa`Fo(B4?A$?#n(S;54+`!2)Ly^Kik) zyM!P@YE04ebxM6iQv_Tw16L8!;%Ydg?iA1sOO4zf1SiXug|wKyzA+T86VPj_^&vPo zQmH9Tp-4O?;HLTi7B^9L#e?A(f+xRxN3e;G%8RMi?yb1X!ZnddSP81zg5fv|--Cm8 z7=Zf%Zo?fzZ;-p1-b(9rMHBGIwDuSwwKg14xn>v+8<``N>sYq-DU2GIF@$tIvPIWI zYD1~cubQ~7u&3u{c$|gVYk4p^#7oocD~gJM3~yk<=<=5KI+o{sM6iWaea7J@_+W=g zm=f^b__Dwk>TwjWb+>Zzu>oV|I7A+(Ws)2s0(WQ3v7ge#EFs+};<3J+$bACf;kS7LT_+&f=+$W$IC$-Nq%a3{~AO;$Lyfgc`& zaZsK{Q-0E z;6dX-jNza$fFkmx_yzc_prR;>U!bD+je@hgZLybk_nmp(dFGjCx@x*=PB+U!2}Yx; z*0#MP6mFwFxw))QfunFiz&SYY0tZ|~5bdh5GZ-^03_{`N3L20%(m}bXcv!$744Jq~ z2$^v$9Mbj*7==w{=n5Tj)wbQ>0xgk9SPg28!Ejs^Fb;=ZFa{F>uEBK^cnd*hj)tJF zYKDM2cE!60iW$|_eW6G^Cg8pue}ItD8jfgOX%dc@@2BXbsFmR{JTY(6B$TqiGng?i z&k@{4WS60bwDy3(pO(0xa;;fA{SqOYId+8fgggOrHp^=|p_G@rN5~3kMxyZrc;|w7 z_#oh|`R9O7w4hX!eugjRWr>A`w3w@CuROb7f~HQ8n<}e%VSpxbiX^s=CUUFgkxs~Js_cc!wCM5DV6HP`1Q14P zKF42r^$Y+Y7VxA8o|7lnk1rB$6^U)8 zC`VqUB5W_!{m1hr$zyfFzS042wV3aLkBNaSvWjAfJ*HW2I_X!7luaheNzeSSGHf?( zWx>mdN`F&S%Pg2Zr-pPH2>hW`-T(jq diff --git a/classes/nextjournal/markdown/parser2/types__init.class b/classes/nextjournal/markdown/parser2/types__init.class index f2d183f9377afe97f322d5dd0be94ad09101d1da..63af632c2c53c72a0819a3e467dcf3b7ccb7e7f0 100644 GIT binary patch literal 4819 zcmbVPd3+pY8GgPb?M#MgNH@?DT6zGj38hJMv`tN@mOwE!O=~x{2E=8unWUS{&MdRD zNh6}72q>U@T9bx5G2%?wttrDzn{IonH=Q!mu~@=RcnX9-{kSn{v|5He z*1B(a+>Dc3El^`Q#)v?5Q}aOqHSXAHFBaP(5b2Lw&UnT(gA)f0w_Aq-wH8&VaUr$NX0^Y7@}Z7Wz_l%eem8FuZqdA6P92wEsfN{9qhlrNB)~d>h7tosr<22urQp({e(gFg4^-K}tIV4-hLsk$a3NK$ z*YN~2X}Ao{0-Mf3@=;rgxpj+zO&YGm8i7lEPh`A=)k+`7Gp=jeUTd#mS;nwsDrgZ{ zTOx746Q7{+gRWtxjkuR^=pBYdy_>Q7>=0L=BPVjX%exnJMLRk)w4t+TkPaQ&g814l zP@9Xywl*C*0y8~PU{#5Tefv!}ok)AsWUrA@&?BIvO>eL183OB?N&~obb9eJW9Xs(P z8HrC8*me#!P1sh#He;iXo6J~7F0HQC&@0WW4kzr9AnX_PAknVHZi#kXNH>N+U!d_* zL)@)8`U8#k3iMPi8FR2d;hC<%c-yC8zm%_F&TTpl1d!1XcZZIr2aqfR*DeaO*K*Q~ zmupNbk(B5Po}pnVjNQIP#|;7YGmF^mbo;Xc?AT(l_oYm`6x+}+T!P)HV0k_}0+^cxIxB&ZzBGnSdNQrS z3qy4h9T(@oUyRC{>`)!Hw zPycr>1~upu>~pWdYh}g1e}1227gX?inky(sn{x$ev+PAG-pE>HxMLQ}BCY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T|Mo;nuM RmE0%%!l9t*5DP~&@IO`6h_L_w delta 1523 zcmbW0`)?Fg6vw}3ce`_UIxX8?!X@-djNFcS3;ZmJvn74e;v^bwU)LfIy#1PiLqo;<6?7}nRiTgAm6jdD=aq` zI+liI>O}hdmO(;|?dIH~z$(IoKBus_w<g69dTFm{0# z2o0x-)#duufaPg;QSHjKHouHlbi9OD!>|fYX^AVaojv<)hdtj= zOmL@KsyEjLEb$lFoc)N}r%zPdbxFH;HErG=LS28M;JXFiI$5q!?uKJ7v>bu=IF!Hs z4p{!&iunUB=v93jt?gfJUbKgw_zGX^_!47kvT+`Lt7aLO%ft9i$02-gpr&&85w+TwBz_7v27Xo>jTtmS z9W(};lE{P_5RL)Vj(Wa_z+qLcJJdeJs|1eow*^VYEguj6A)z6~?|7t5RyH;GMeV3> zEpslFqZ0ceBJqe^DQ^yN`zVZI=p@$!xO)`$4r3C@mGSx#xkla}i>}Cu-AMH&Nj@0h z(eB<<>g4t@mIqkh9bi*{t=+vfB)3J1bT%8{weDW6O!D=}B2tkdn$0C-0B#}^x&e8I!#f&d@O q0|CC+iEje@5a7oE7a!dQEx^&eLoBLC1DaS!(Fkcs%;ynG0)GNcZMfY4 diff --git a/src/nextjournal/markdown/parser2.clj b/src/nextjournal/markdown/parser2.clj index aaa9b83..e90427f 100644 --- a/src/nextjournal/markdown/parser2.clj +++ b/src/nextjournal/markdown/parser2.clj @@ -219,7 +219,6 @@ And what. [^note1]: the _what_ - * and new text[^endnote] at the end. * the * hell^[that warm place] @@ -230,6 +229,4 @@ And what. ;; inline footnotes (might be handled via a delimited processor) (md/parse "some text with^[ and not without] a footnote") - (parse "some text with^[ and not without] a footnote") - (parse "some text with $and not -without$ a footnote")) + (parse "some text with^[ and not without] a footnote")) diff --git a/src/nextjournal/markdown/parser2/footnotes.clj b/src/nextjournal/markdown/parser2/footnotes.clj index 3844838..7eecfe0 100644 --- a/src/nextjournal/markdown/parser2/footnotes.clj +++ b/src/nextjournal/markdown/parser2/footnotes.clj @@ -1,8 +1,11 @@ (ns nextjournal.markdown.parser2.footnotes - (:require [nextjournal.markdown.parser2.types]) - (:import (nextjournal.markdown.parser2.types Footnote) - (org.commonmark.parser Parser$ParserExtension Parser$Builder SourceLine) - (org.commonmark.parser.block AbstractBlockParser BlockContinue BlockParserFactory BlockStart ParserState BlockParser))) + (:require [clojure.string :as str] + [nextjournal.markdown.parser2.types]) + (:import (nextjournal.markdown.parser2.types Footnote FootnoteRef) + (org.commonmark.node Text Node Nodes) + (org.commonmark.parser Parser$ParserExtension Parser$Builder PostProcessor SourceLine) + (org.commonmark.parser.block AbstractBlockParser BlockContinue BlockParserFactory BlockStart ParserState BlockParser) + (org.commonmark.parser.delimiter DelimiterProcessor))) (def footnote-id-regex (re-pattern "\\[\\^\\s*(.*)\\s*\\]")) (def footnote-def-regex (re-pattern "^\\[\\^\\s*(.*)\\s*\\]:")) @@ -23,32 +26,32 @@ (BlockContinue/atIndex non-space))))))) (comment - (nextjournal.markdown.parser2/parse "what the + (nextjournal.markdown.parser2/parse "init [^label] end -[^what]: * what _the_ heck -* the +[^label]: * this is nice _and_ nice + * and so so +")) -what a what")) +(defn block-parser-factory [] + (proxy [Object BlockParserFactory] [] + (tryStart [^ParserState state _matchedBlockParser] + (if (<= 4 (.getIndent state)) + (BlockStart/none) + (let [^SourceLine line (.getLine state) + line-content (.getContent line) + next-non-space (.getNextNonSpaceIndex state) + candidate-content (subs line-content next-non-space) + m (re-matcher footnote-def-regex candidate-content)] + (if (re-find m) + (let [block-index (+ next-non-space (.end m)) + label (subs line-content (+ next-non-space 2) + (+ next-non-space (- (.end m) 2))) + ^BlockParser bp (block-parser label)] + (.atIndex (BlockStart/of (into-array [bp])) + block-index)) + (BlockStart/none))))))) (defn extension [] (proxy [Object Parser$ParserExtension] [] (extend [^Parser$Builder pb] - (.customBlockParserFactory - pb (proxy [Object BlockParserFactory] [] - (tryStart [^ParserState state _matchedBlockParser] - (if (<= 4 (.getIndent state)) - (BlockStart/none) - (let [^SourceLine line (.getLine state) - line-content (.getContent line) - next-non-space (.getNextNonSpaceIndex state) - candidate-content (subs line-content next-non-space) - m (re-matcher footnote-def-regex candidate-content)] - (if (re-find m) - (let [block-index (+ next-non-space (.end m)) - label (subs line-content (+ next-non-space 2) - (+ next-non-space (- (.end m) 2))) - ^BlockParser bp (block-parser label)] - (println :match label (.start m) (.end m)) - (.atIndex (BlockStart/of (into-array [bp])) - block-index)) - (BlockStart/none)))))))))) + (.customBlockParserFactory pb (block-parser-factory))))) diff --git a/src/nextjournal/markdown/parser2/types.clj b/src/nextjournal/markdown/parser2/types.clj index 71d01cf..3fda76d 100644 --- a/src/nextjournal/markdown/parser2/types.clj +++ b/src/nextjournal/markdown/parser2/types.clj @@ -30,7 +30,17 @@ (defn footnote-init [label] [[] (ref {:label label})]) (defn footnote-getLabel [this] (:label @(.state this))) -(comment - (compile 'nextjournal.markdown.parser2.types) +(gen-class + :name nextjournal.markdown.parser2.types.FootnoteRef + :extends org.commonmark.node.CustomNode + :constructors {[String] []} + :init init + :state state + :methods [[getLabel [] String]] + :prefix "footnote-ref-") - ) +(defn footnote-ref-init [label] [[] (ref {:label label})]) +(defn footnote-ref-getLabel [this] (:label @(.state this))) + +(comment + (compile 'nextjournal.markdown.parser2.types))