Sometimes, I use MS Word to draft content in Markdown, due to autosave and other helpful features. The syntax for a link is to have the readable text in square brackets immediately followed by the URL in parentheses, like this:
Commonly, I copy the URL from a browser, and go to paste it into the draft.
If I paste in Notepad, or most places in the Word document, the first characters (http...) begin immediately where the cursor was when I hit paste.
However, if I'm in Word with the cursor immediately after a
]( sequence, Word adds a space before the URL, breaking the markdown link (depending on parser strictness). It also does this if pasting text from elsewhere even in the same document, with no leading space.
How do I stop Word from doing this?
(Edition: Office 365 ProPlus, macros disabled).
Per comments from @fixit: After a paste in Word, I copied the )[ through the pasted content and pasted it in cell A1 of an Excel spreadsheet. In A2, I put the formula
=RIGHT(A1,LEN(A1)-1) (equivalent to
substring(1) in some other programming languages) and dragged that formula down several columns, with each row's A cell showing the same as the previous row minus the first character.
In the next column (B1) I used the formula
=CODE(A1) which shows the character code for the first character in the string.
Where that space character is first (A3), the code (B3) is 32. As this is on a Windows machine, that's the ANSI character set, for which values 0-127 match ASCII, and character 32 is a space. Therefore, the character in question is a space, not some nonprintable character that Notepad ignores and Word shows as a space. Additionally, if such a character were part of the copied string, it would show up when pasted after other characters, such as
( when it is not immediately preceded by
]. However, in such cases, no space is added.