Can I mix markdown code block declaration and latex commands in a custom latex command?

Viewed 14

For markdown, with Latex, I wrote a convenient command :

\newcommand{\mauve}[1]{\textcolor{Purple}{#1}}
\newcommand{\fonction}[1]{\begingroup\small\mauve{\texttt{#1}}\endgroup}
\newcommand{\cadreGris}{\renewtcolorbox{quote}{colback=darkgray!5!white,arc=0pt,outer arc=0pt,boxrule=0pt,lowerbox=invisible,code={\tcbset{enlarge left by=0cm}}}}
\newcommand{\code}{\begingroup\cadreGris\footnotesize}

that helps me formatting my source code in markdown that way:

   On peut rajouter aux périodes des durées avec \fonction{plusYears(...)}, \fonction{plusMonths(...)}... ou en retrancher avec \fonction{minusDays(...)}...

   - la classe \fonction{Duration}...

   \code

   > ```scala
   > import java.time.Duration
   > java.time.temporal.ChronoUnit
   >
   > Duration.of(10192927, ChronoUnit.MILLIS) // PT2H49M52.927S
   > ```
 
   \endgroup

   Il est possible d'utiliser les méthodes \fonction{toHours()}, \fonction{toDays()}... Mais attention : elles retournent des nombres entiers. Ci-dessus, un `getDays()` renverra 0, car il y a 0 jours... et 2 heures.

Which produces this result I enjoy:

enter image description here


But is there a way I could create a new command, for example \scala,
that would perform:

\code
> ```scala

and then an \endcode that would produce:

> ```
\endgroup

Meaning : is there a way to mix blocks declaration of "markdown kind" and latex commands in a command definition?

0 Answers
Related