vim-pandoc / vim-pandoc-syntax

pandoc markdown syntax, to be installed alongside vim-pandoc
MIT License
425 stars 61 forks source link

Italics are not correctly highlighted when the terminating asterisk is followed by a some characters. #304

Open cjns1989 opened 4 years ago

cjns1989 commented 4 years ago

In French typography it is customary to separate some punctuation characters (such as '!', '?', ':', ';', '%', '»' etc.) from the last letter of the preceding word by a non breakable thin space ­— i.e. 0x202f.

As it appears this causes the pandoc.vim syntax file to fail to detect the end of an italicised sequence correctly when the terminating asterisk is followed by a thin space and continue highlighting until it runs into another asterisk… or the end of the file.

*First italicised sequence ends here* ! … blah… blah… some text follows … *2nd it. seq. ends*

In the above sample the asterisk that follows the word 'here' is itself followed by an 0x202f and then by an exclamation mark (!). Instead of stopping on the last letter of the word 'here', the highlighting continues until the last letter of the word 'ends' that terminates the 2nd italicised sequence because this particular asterisk happens to be followed by a regular space.

Note, that this also happens when the thin space is replaced by a full width non-breakable space (0x160). I didn't other variations.

Workaround in most cases is to move the terminating asterisk after the punctuation sign.

Thanks,

CJ

alerque commented 4 years ago

Given that we're trying to follow as closely as possible what pandoc itself is going to parse this is pretty clearly a bug. The fix shouldn't be too hard but I'm about to leave for a week of travel so it might take a little while to get around to. Feel free to send a PR for review when I get back ;-)

Out of curiosity though, other languages I've worked with almost always prefer to italicize punctuation that touches italicized text anyway. To me your "workaround" would be the typographically correct way to do this anyway. Is that different in French? Just asking ... a couple weeks ago I was looking into a few spacing issues in The SILE Typesetter that were French specific. We haven't sorted out yet if or how to introduce special handling of kerning for punctuation next to italicized text (e.g. in foo (*bar!*) baz the closing parenthesis is pretty much guaranteed to look bad after the italicized exclamation point). I'm curious what the respected typographical convention is in French.

cjns1989 commented 4 years ago

Thanks for prompt response.

As to your curiosity… I'm afraid I do not have any knowledge of French typography rules apart from the fact that they appear to be quite… shall we say… difficult… I somehow started producing mobile device friendly versions of a few public domain novels that were only available in scanned pdf form (of dubious quality¹) from a number of sources and noticed just by looking at the text that the way the various punctuation signs were handled was somewhat different from what one more familiar with anglo-american typography would expect. Managed to find some information about this particular aspect of French typography and that thinspace business by reading what's available on line either in wikipedia or forums of the stackexchange or even the Quora type. So it's really not for me to voice an opinion or put forward recommendations on anything regarding the subject.

As you clearly demonstrate with the example above (not) systematically italicising punctuation when the preceding text is italicised is clearly not the answer. Another example that comes to mind is a poem or manifest where every line (or every other line…) ends with an exclamation mark or a question mark… This looks fine… until you hit a verse that ends with italicised text for any reason… (something in a foreign tongue, latin… e.g.)… and bam… now you have a slanting exclamation/question mark that refuses to be neatly aligned with the rest of them…

Since I can read French like a native more or less, I looked around and found this:

http://jacques-andre.fr/faqtypo/lessons.pdf

Only skimmed through it but it seems to be a decent introduction to the subject.

Otherwise there appear to be two reliable sources that both publish a complete set of rules… the French national printing department — i.e. the people whose job it is to print all the official… legal… administrative… financial… etc. literature on a daily basis… and the French printers' & publishers' association for literary stuff & newpapers… don't remember their official names but you should find some wikipedia articles about all this easily.

As an aside… on a different subject: I have used the pandoc markdown inline footnotes quite a bit lately, e.g.

`[this is an inline footnote]{.smallcaps}

and noticed that in the different vim 256 colours colorschemes that I tried apart from my own personal on that the text is highlighted via a specific color… the square brackets another… which is nice… but the '{.smallcaps}' part is not. Not going to 'make an issue of this' (pun intended) naturally, but wouldn't it be better if that small caps marker were more clearly visible ­(it appears to point to the 'Normal' high-level highlight group…).

Thanks,

CJ

¹ If you want to take a peek at traditional French high quality typography done by professionals who do know the rules this may be of interest…

https://en.wikipedia.org/wiki/Biblioth%C3%A8que_de_la_Pl%C3%A9iade

alerque commented 4 years ago

Thanks for the French pointers ;-)

By all means do open up an issue for the highlighting of attributes. I've noticed that too, but thought there was an open issue. Since I can't find it please open one.

Also, the syntax you show is for smallcaps class attribute on an inline span, not inline footnotes which would be text^[inline footnote].

cjns1989 commented 4 years ago

Ouch… :-$ … I meant something like:

[Bring out yer Small Caps!]{.smallcaps}

Sorry about that… trying to juggle too many balls on a Sunday I guess…

Will open an enhancement request tomorrow.

Thanks,

CJ

cjns1989 commented 4 years ago

Opened #305 as per your request.

cjns1989 commented 4 years ago

ping…

of course 'Note, that this also happens when the thin space is replaced by a full width non-breakable space (0x160). I didn't other variations.' above should read non breaking space (0xA0)'…