mmarkdown / mmark

Mmark: a powerful markdown processor in Go geared towards the IETF
https://mmark.miek.nl
Other
480 stars 45 forks source link

Syntax highlighting #96

Closed ghost closed 5 years ago

ghost commented 5 years ago

With <{{filename}} you include a file as a code block. The main difference being it will be returned as a code block. The file’s extension will be used as the language.

https://mmark.miek.nl/post/syntax#including-files

This is not what I am getting. Using this markup:

---
markup: mmark
---

<{{content\autumn\app.php}}

Give me

<pre>
   <code></code>
</pre>

but no highlighting. Further:

Note that because the extension of the file above is “go”, this include will lead to the following block being parsed:

~~~ go
// test.go data
~~~

is not what I am getting either. If I use this:

~~~ php
<?php
date_default_timezone_set(getenv('TZ'));
~~~

again I just get a block without highlighting. Now if I follow this:

https://gohugo.io/content-management/syntax-highlighting

it works as expected:

{{< highlight php >}}
<?php
date_default_timezone_set(getenv('TZ'));
{{< / highlight >}}

but this syntax doesnt seem to work with including a file.

miekg commented 5 years ago

There is no syntax highlighting. This is WAI

ghost commented 5 years ago

Looks like Hugo can do this without MMark. First download this:

https://github.com/gohugoio/hugo/blob/master/docs/layouts/shortcodes/readfile.html

and put it as:

layouts/shortcodes/readfile.html

might need to create shortcodes folder. Then add this to your markup:

{{< readfile highlight="php" file="content/posts/app.php" >}}

if you did these steps in reverse, might need to resave the markup for it to load the change.