The accepted answer for org-mode is written by me. org-mode is tricky because its own check-word-predicate is already defined.

markdown is simpler because it uses default predicate provided by flyspell-mode,

    (defun flyspell-generic-textmode-verify ()
      "Used for `flyspell-generic-check-word-predicate' in text modes."
      ;; (point) is next char after the word. Must check one char before.
      (let ((f (get-text-property (- (point) 1) 'face)))
        (not (memq f '(markdown-pre-face)))))
    
    (setq flyspell-generic-check-word-predicate 'flyspell-generic-textmode-verify)
    (flyspell-mode 1)

By the way, `M-x describe-function ENTER flyspell-prog-mode ENTER`, you will find similar setup. 

Use the Source, Luke.