Fortran-FOSS-Programmers / ford

Automatically generates FORtran Documentation from comments within the code.
https://forddocs.readthedocs.io
GNU General Public License v3.0
410 stars 134 forks source link

Fortran keywords are highlighed in a regular preformatted code block #636

Closed blaylockbk closed 7 months ago

blaylockbk commented 8 months ago

Given these FORD documentation lines in my program that shows preformatted text:

!! This text is part of my FORD docs.
!!
!!     This is just a regular preformatted code block. It actually highlights
!!     words like if and end even when I don't need them highlighted.
!!
!! The above is preformatted text, and this line is regular.

image

As you can see, FORD colors the words if, and, and end. It seems like FORD is trying to apply Fortran highlighting to this preformatted block that isn't actually Fortran code. Is this a bug?

I expected that FORD would not apply any highlighting to regular preformatted code blocks, and only apply Fortran highlighting when using the fenced code block syntax (i.e., ```fortran)

ZedThree commented 7 months ago

This is actually a feature of the highlighter we use, codehilite, which attempts to guess the language for highlighting. You can control it by either using the triple-backticks format, or triple-colons:

  !! Simple Fortran program to demonstrate the usage of FORD and to test its installation
  !!
  !!     :::C
  !!     struct {
  !!         int x;
  !!     };

will highlight the block as C

blaylockbk commented 7 months ago

Ah, gotcha. So I guess I need to specify a "none" language so no highlighting is done. I wonder if codehilite lets you do that. Something like

```none
This is just preformatted text without any highlighting
```

but I don't see anything like "none" in the list of languages https://pygments.org/languages/

Languages — Pygments
ZedThree commented 7 months ago

Yup, you want text