I'm using MiKTeX via pandoc to make a book that contains C# and F# source code. The C# source code gets formatted just fine. How do I make sure the F# code gets formatted also?
2 Answers
Pandoc uses the syntax definitions from KDE's Kate editor. F# is included in that list. In fact, if you run pandoc --list-highlight-languages
, you'll find cs
(for C#) and fsharp
(for F#). Not sure how that inconsitency came to be.
So it should be sufficient to start your code blocks with ``` fsharp
to get proper highlighting. You may have to update pandoc to make sure fsharp support is included.
If you'd rather use minted than pandoc's built-in highlighter, checkout the minted
pandoc Lua filter.
-
I am using the ```` fsharp` code you mention but it is 100%, definitely, NOT working. Commented Oct 20, 2020 at 6:58
-
1Does
pandoc --list-highlight-languages | grep fsharp
give any output? If not, update pandoc. If it does, please raise the issue in the GitHub repo.– tarlebCommented Oct 20, 2020 at 7:45 -
Turns out this problem is the result of a bug/omission. For C#, you can use either c#
or csharp
as the language identifier. For F#, you can use fsharp
but NOT f#
, the latter simply does not work. Changing everything to fsharp
fixed the issue.
pygments
do has a lexer for F#, so you can usemitned
to highlight/format.