Skip to content

Commit

Permalink
Extend string quoting guidelines
Browse files Browse the repository at this point in the history
- Add a note about URI & quoting
- Add note about XML
- Clarify scope and usage if in doubt

Clarification
  • Loading branch information
zas authored and phw committed Sep 25, 2023
1 parent 713c435 commit a9d4efd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '<a href="someurl">text</a>'`.

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
Expand Down

0 comments on commit a9d4efd

Please sign in to comment.