kookma / TW-Refnotes

Refnotes is a reference manager tool that allows you to maintain a "personal library" of references, citations, footnotes and abbreviations in Tiddlywiki.
https://kookma.github.io/TW-Refnotes/
37 stars 6 forks source link

A bug in the v1.8.0 for narrative in-text citation #25

Closed byzheng closed 2 years ago

byzheng commented 2 years ago

In the tiddler

See <<ref "bustos-korts_modelling_2016" n>>
See <<ref bustos-korts_modelling_2016 n>>

Then in the reference list, I get this error

Reference bustos-korts_modelling_2016 n NOT FOUND. Check your input.
Reference bustos-korts_modelling_2016" n NOT FOUND. Check your input.

Narrative is only working for single quotation


See <<ref 'bustos-korts_modelling_2016' n>>
kookma commented 2 years ago

This is by design! See note 3 in https://kookma.github.io/TW-Refnotes/#demo%2Fref-macro

Narrative is only working for single quotation

If you send extra parameters than this is a limitation and not related to narrative!

kookma commented 2 years ago

Hi @marxsal If you remember to parse the references in-text (<<ref title>>) you have wrote the ($:/plugins/kookma/refnotes/macros/bibtex/regexprefs.js)

The showrefs ($:/plugins/kookma/refnotes/macros/apa/showrefs) uses the find-refs ($:/plugins/kookma/refnotes/macros/bibtex/find-refs) to find all instances of <<ref title>>.

Now in the update 1.8, Refnotes uses ref macro with three parameters (<<ref title type page>> see $:/plugins/kookma/refnotes/macros/apa/ref) The problem is find-refs works fine with one parameter but with two or three parameters, it returns wrong results e.g does not distinguish the correct number of input parameters. Strangely, if you wrap the first parameter in single quote or double brackets, it works fine

I would appreciate to have a look.

Marxsal commented 2 years ago

Do you have an example from your demo site where it doesn't work? For instance, this does work:

<<ref rostami-2022 n p16 >>

kookma commented 2 years ago

Mark, See example in https://kookma.github.io/TW-Refnotes/#demo%2Fref-macro

You also create a new tiddler with below text:

<<ref "rostami-2022" n 'p. 16'>>

<<showrefs>>

This does not work, but, the below form will work.

<<ref 'rostami-2022' n 'p. 16'>>

<<showrefs>>
Marxsal commented 2 years ago

Try testing this.

\define find-refs(tid)
<$vars regexp="(?g)<<ref .+?>>"
regexp2='<<ref "*(.*?)"*>>'
regexp3="^'(.*?)'"
regexp4="\[\[(.*?)\]\]"
regexp5="^(.*?)\s"
>
<$list filter="[[$tid$]regexprefs:text<regexp>]">
<$list filter="[all[current]regexprefs<regexp2>]">
<$list filter="""
     [all[current]regexprefs<regexp3>] 
:else[all[current]regexprefs<regexp4>]
:else[all[current]regexprefs<regexp5>]
:else[all[current]]
""" variable=p >
<<pwrapper>>
</$list>
</$list>
</$list>
</$vars>
\end

\define pwrapper() 
[[[[$(p)$]]]]
\end
kookma commented 2 years ago

This still does not work

<<ref "rostami-2022" n 'p. 16'>>

<<showrefs>>

The issue is with double quotes ("), with single quote everything works fine

Marxsal commented 2 years ago

Do we know for sure it ever worked with double quotes?

Try:

\define find-refs(tid)
<$vars regexp="(?g)<<ref .+?>>"
regexp2='<<ref\s+(.*?)>>'
regexp3='^"(.*?)"'
regexp4="^'(.*?)'"
regexp5="\[\[(.*?)\]\]"
regexp6="^(.*?)\s"
>
<$list filter="[[$tid$]regexprefs:text<regexp>]">
<$list filter="[all[current]regexprefs<regexp2>]">
<$list filter="""
     [all[current]regexprefs<regexp3>] 
:else[all[current]regexprefs<regexp4>]
:else[all[current]regexprefs<regexp5>]
:else[all[current]regexprefs<regexp6>]
:else[all[current]]
""" variable=p >
<<pwrapper>>
</$list>
</$list>
</$list>
</$vars>
\end

\define pwrapper() 
[[[[$(p)$]]]]
\end
kookma commented 2 years ago

This last one works. Despite the complexity of code, I tested all combinations of double quotes / single quotes and double bracket / quotes and all works.

<<ref [[rostami-2022]] n 'p. 16'>>
<<ref [[rostami-2022]] n "p. 16">>

<<ref 'rostami-2022' 'n' 'p. 16'>>
<<ref 'rostami-2022' "n" 'pp. 123-345'>>

<<ref "rostami-2022" "n" "pp. 123-345">>
<<ref "rostami-2022" n "pp. 123-345">>
<<ref "rostami-2022" n 'pp. 123-345'>>

<<showrefs>>

I use this code in Refnotes 1.8.1, and will push a new update shortly.

kookma commented 2 years ago

Fixed in 1.8.1