Not sure of the relevance of issue 2956, which is about pandoc not recognising options in parentheses. There are no parentheses in the problematic header inclusion.

On Tuesday, 8 August 2017 03:56:00 UTC+9:30, John MacFarlane wrote:
See https://github.com/jgm/pandoc/issues/2956

Alternatively, in the dev version of pandoc you can tell
it you've got raw latex, not Markdown:

header-includes:
- `\let\oldsection\section`{=latex}

Final remark:  I don't understand why it's not parsing
the `\section` as raw tex.  I'll need to look into this;
it may be a bug in the LaTeX reader.

+++ David Nebauer [Aug 07 17 00:39 ]:
>   If I process this markdown file ('mwe-latex.md'):
>   ---
>   title: "Minimal Working Example"
>   header-includes:
>   - \let\oldsection\section
>   - \renewcommand{\section}[1]{\clearpage\oldsection{#1}}
>   ---
>   Text.
>   with the pandoc command:
>   pandoc -t latex --latex-engine=xelatex --output=mwe-latex.pdf
>   mwe-latex.md
>   I get the the error:
>   ! LaTeX Error: Missing \begin{document}.
>   See the LaTeX manual or LaTeX Companion for explanation.
>   Type H <return> for immediate help.
>   ...
>   l.49 \let\oldsection\textbackslash{}s
>   pandoc: Error producing PDF
>   On generating latex output with the command:
>   pandoc -t latex --latex-engine=xelatex --standalone
>   --output=mwe-latex.tex mwe-latex.md
>   and examining line 49 of the output file it becomes apparent that this
>   line from the header inclusion:
>   \let\oldsection\section
>   has been munged by pandoc to:
>   \let\oldsection\textbackslash{}section
>   and this is causing the processing problem. (Note: changing latex
>   engines makes no difference.)
>   Once line 49 is edited to resemble the original command from the header
>   inclusion the error disappears.
>   How can I prevent this latex command in the header inclusion from being
>   munged by pandoc?
>
>   --
>   You received this message because you are subscribed to the Google
>   Groups "pandoc-discuss" group.
>   To unsubscribe from this group and stop receiving emails from it, send
>   an email to [1]pandoc-discus...@googlegroups.com.
>   To post to this group, send email to
>   [2]pandoc-...@googlegroups.com.
>   To view this discussion on the web visit
>   [3]https://groups.google.com/d/msgid/pandoc-discuss/85d3801f-6a20-4873-
>   bf2e-e8cd7f13445e%40googlegroups.com.
>   For more options, visit [4]https://groups.google.com/d/optout.
>
>References
>
>   1. mailto:pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
>   2. mailto:pandoc-...@googlegroups.com
>   3. https://groups.google.com/d/msgid/pandoc-discuss/85d3801f-6a20-4873-bf2e-e8cd7f13445e@googlegroups.com?utm_medium=email&utm_source=footer
>   4. https://groups.google.com/d/optout

--
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To post to this group, send email to pandoc-discuss-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/c39d6355-1b71-4355-813f-5e85a1beb988%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.