Anthony Scemama
Anthony Scemama

Reputation: 1593

How do I enable syntax highlighting for Fortran in GitBook

Original Question:

I can't find how to activate syntax highlighting on GitBook! It works perfectly when I look at the .md files on GitHub where my repository is hosted, by not when I look at my rendered gitbook on the web. Any ideas? Thanks

Edit:

it works for bash, Python, C, C++, javascript, etc, but not for Fortran! It seems that gitbook and github don't use the same syntax highlighting package. Is there a way to activate syntax highlighting with Fortran on GitBook?

Sample code:

``` fortran
program compute_t
    implicit none

    integer :: d1, d2, d3, d4 d5  ! Input data
    integer :: u1, u2, v, w, t    ! Computed entities

    call read_data(d1,d2,d3,d4,d5)

    call compute_u(d1,d2,u1)
    call compute_u(d3,d4,u2)
    call compute_w(d5,w)
    call compute_v(u2,w,v)
    call compute_t(u1,v,t)

    write(*,*), "t=", t

end program
```

Upvotes: 1

Views: 1706

Answers (1)

Chris
Chris

Reputation: 137088

GitBook's own documentation, which is available as a GitBook, uses named fenced code blocks as popularized by GitHub:

```markdown
# H1
## H2
### H3
#### H4
##### H5
###### H6
```

Although I can't find any documentation that explicitly says this is supported, I suspect that it works just fine.

Edit:

it works for bash, Python, C, C++, javascript, etc, but not for Fortran! It seems that gitbook and github don't use the same syntax highlighting package.

GitHub uses a Ruby library called Linguist for syntax highlighting. It looks like GitBook uses the JavaScript library highlight.js, which doesn't support Fortran.

Is there a way to activate syntax highlighting with Fortran on GitBook?

Short of contributing Fortran support to highlight.js, I don't think there's a good solution for this at the moment.

Upvotes: 4

Related Questions