In Markdown, use a pair of ``` for code blocks,
How can I achieve it in LaTeX?
I use the packet csquotes and encounter two questions:
- how to remove double quotes
- how to add background color
For the color part of the problem, I used a tcolorbox approach as given in the answer to this question: Change background color for text block
For the markdown parsing one can borrow and adapt from my answer at Use Markdown-style formatting for bold and italic.
Here I interpret triple backticks as delimiters for a myquote environment, using the macro \triplequote. Not knowing from your question how to interpret single and double backticks, I merely show how they are parsed, using placeholders defined in the macros \singlequote and \doublequote.
The macros \quoteON and \quoteOFF are used to enable and disable the active parsing.
\documentclass{article} \usepackage[most]{tcolorbox} \definecolor{block-gray}{gray}{0.85} \newtcolorbox{myquote}{colback=block-gray,grow to right by=-10mm,grow to left by=-10mm, boxrule=0pt,boxsep=0pt,breakable} \makeatletter \def\quoteparse{\@ifnextchar`{\quotex}{\singlequote}} \def\quotex#1{\@ifnextchar`{\triplequote\@gobble}{\doublequote}} \makeatother \def\singlequote#1`{[StartQ]#1[EndQ]\quoteON} \def\doublequote#1``{[StartQQ]#1[EndQQ]\quoteON} \long\def\triplequote#1```{\begin{myquote}\parskip 1ex#1\end{myquote}\quoteON} \def\quoteON{\catcode``=\active} \def\quoteOFF{\catcode``=12} \quoteON \def`{\quoteOFF \quoteparse} \quoteOFF \begin{document} \quoteON This is a `test of single quoted` material and this is a ``test of double quoted material``, and this is the test of a ```triple quoted material. We will make it long enough to test line wrapping and we will even\\ add a manual linebreak. Even a new paragraph.``` Resuming normal text. \quoteOFF Here should be triple backticks ```xxx``` \end{document} Once it is known how single-quoted and double-quoted material should behave, those macros can be adjusted to implement it.
<code>/</code>pairs. The triple-tic introducing a code block is part of the GitHub-flavored markdown. The triple-tic for a blockquote may be some other flavor?csquoteshas its own facilities to create block quotations if a quoted string is longer than a specified length, which you can adjust. Otherwise you can usequoteorquotationenvironment from standard LaTeX. Adding the colorbox would be an extra customization, though.