4

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
  • What utility are you using to format C# source? Commented Sep 22, 2020 at 21:09
  • 3
    Python library pygments do has a lexer for F#, so you can use mitned to highlight/format. Commented Sep 22, 2020 at 21:10

2 Answers 2

4

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.

3
  • I am using the ```` fsharp` code you mention but it is 100%, definitely, NOT working. Commented Oct 20, 2020 at 6:58
  • 1
    Does pandoc --list-highlight-languages | grep fsharp give any output? If not, update pandoc. If it does, please raise the issue in the GitHub repo.
    – tarleb
    Commented Oct 20, 2020 at 7:45
  • turns out there is a bug; question updated Commented Mar 21, 2022 at 20:08
0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .