riboseinc / asciidoctor-bibliography

Citations in AsciiDoc
MIT License
30 stars 8 forks source link

Intolerance to any white space in multiple citation #76

Open shahryareiv opened 6 years ago

shahryareiv commented 6 years ago

In a chain multiple citation cite:[key1]+[key2]+[key3] just a white space breaks the chain, so cite:[key1]+[key2]+ [key3] ignores the third item. I do not know how Asciidoctor tokenizes the text-block and if it is possible to ignore white spaces. I also do not know if there could be cases where ignoring white space might cause globing too much. Otherwise it might be easier for the writer to care less about possible white-spaces in between the chain. This might happen, especially, when the chain is spread over two lines.

Alternatively, a suggestion might be to support cite:[key1;key2;key3].

ronaldtse commented 6 years ago

@shahryareiv that's indeed an oft-encountered problem with Asciidoctor -- for example, a control phrase that uses underscores or other syntax symbols will get cut off with a linebreak, so it's not a specific issue with asciidoctor-bibliography.

We could possibly support the suggested syntax of cite:[key1;key2;key3]. Thoughts @paolobrasolin @opoudjis ?

paolobrasolin commented 6 years ago

Thanks for your feedback @shahryareiv!

I initially though about using semicolons as separators myself, but I decided not to in order to offer a syntax reminiscent of other common macros to target a specific indices within a multiple citations:

cite:foo_index[Aa2017]+bar_index[Bb2017]

Ignoring whitespace is technically easy but refraining from it avoided ambiguity in edge cases, e.g. when you'd want a literal + [something] after a citation. It's a bit far fetched, but still possible.

Furthermore, allowing to break the line after + would create a behaviour diverging from the default expected one.

Another point in favour of not allowing line breaks could be that these are an inline macros - but I do realise they can get too long to maintain very quickly.

A solution might be as follows:

// single citation
cite:[foo_key]
// single citation w/ non default target 
cite:my_index[foo_key]
// single citation w/ non default target (alt. syntax) 
cite:[foo_key, target=my_index]
// multiple citations
cite:[foo_key; bar_key]
// multiple citations w/ common non default target
cite:my_index[foo_key; bar_key]
// multiple citations w/ common non default target and a local target override
cite:my_index[foo_key; bar_key; baz_key, target=your_index]

All this while allowing for arbitrary whitespace in the attribute list in canonical way.

On top of that, we could also allow for line breaks within the square brackets; this would be a non canonical behaviour for an inline macro, but might greatly improve its usability.

(If we decide to implement this I'd keep the +-concatenation but drop it at the next major; this syntax seems a bit more reasonable.)

@ronaldtse Any thoughts? My only concern is that allowing line breaks inside the attribute list of an inline macro is a non canonical behaviour.