Skip to content

Instantly share code, notes, and snippets.

@harikt
Last active November 29, 2019 07:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harikt/7963895ee5e94fc1edf5deaeaa7ea778 to your computer and use it in GitHub Desktop.
Save harikt/7963895ee5e94fc1edf5deaeaa7ea778 to your computer and use it in GitHub Desktop.
PHP code highlighting not working for hugo
```yaml
pygmentsuseclasses: false
pygmentsCodeFences: true
pygmentsCodeFencesGuessSyntax: true
markup:
highlight:
codeFences: true
hl_Lines: ""
lineNoStart: 1
lineNos: true
lineNumbersInTable: true
noClasses: true
style: monokai
tabWidth: 4
```
PHP code is not highlighted.
```php
$hello = function () {
echo "Hello World";
};
```
{{< highlight php >}}
$hello = function () {
echo "Hello World";
};
{{< /highlight >}}
But if we add a <?php in front it will convert to html inside span with color. All below code works.
```
<?php
$hello = function () {
echo "Hello World";
};
```
{{< highlight html >}}
<section id="main">
<div>
<h1 id="title">{{ .Title }}</h1>
{{ range .Data.Pages }}
{{ .Render "summary"}}
{{ end }}
</div>
</section>
{{< /highlight >}}
{{< highlight php >}}
<section id="main">
<div>
<h1 id="title"><?= $title ?></h1>
<?php $value = "Hello World"; ?>
</div>
</section>
{{< /highlight >}}
```html
<section id="main">
<div>
<h1 id="title"><?= $title ?></h1>
<?php $value = "Hello World"; ?>
</div>
</section>
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment