From fcda5f2587832cbcada5bf1309c724c846c3ff7c Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Sat, 23 Sep 2023 22:35:32 +0200 Subject: [PATCH] Extend string quoting guidelines - Add a note about URI & quoting - Add note about XML - Clarify scope and usage if in doubt Clarification --- CONTRIBUTING.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d549136af0..7e97eedb52 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -97,7 +97,15 @@ print(d['small']) In above example, `l1` contains identifiers (keys of dict `d`) while others are English words/phrases. In the dict declaration, keys are single-quoted but values are double-quoted. -Otherwise, choose whichever limit the number of escaped characters. +URIs (and paths used in URIs) should be, in general, enclosed in double quotes, +mainly because single quotes can appear in URI, unencoded, as sub-delimiters as specified +by [RFC3986](https://www.rfc-editor.org/rfc/rfc3986#section-2.2). + +HTML/XML code often contains attributes that are enclosed by double quotes, so in this case, +better use single quotes, e.g. `html = 'text'`. + +In doubt, choose whichever limit the number of escaped characters. +Typically single quote strings that are meant to contain double quotes (e.g. `'The file is "{file}"'`). ## Git Work-flow