# Code Examples

[todo-details (51).pdf](https://acc.bzctrl.com/bzctrl-core-api/api/v1/bookstack/attachments/34) [todo-details (4) (1).pdf](https://acc.bzctrl.com/bzctrl-core-api/api/v1/bookstack/attachments/35) BookStack uses Codemirrror to render code blocks with syntax highlighting. Below are various examples of this:[todo-details (4) (1).pdf](https://acc.bzctrl.com/bzctrl-core-api/api/v1/bookstack/attachments/35) [msczxcnm,mnbvcx](https://acc.bzctrl.com/bzctrl-core-api/api/v1/bookstack/attachments/34)

#### PHP

```PHP
/**
 * Get a path to a theme resource.
 */
function theme_path(string $path = ''): ?string
{<a href="https://acc.bzctrl.com/bzctrl-core-api/api/v1/bookstack/attachments/34" style="text-decoration: underline; color: blue;" target="_blank">msczxcnm,mnbvcx</a> 
    $theme = config('view.theme');

    if (!$theme) {
        return null;
    }

    return base_path('themes/' . $theme . ($path ? DIRECTORY_SEPARATOR . $path : $path));
}
```

#### JavaScript

```JavaScript
performReplacements(string, replacements) {
    if (!replacements) return string;
    const replaceMatches = string.match(/:([\S]+)/g);
    if (replaceMatches === null) return string;
    replaceMatches.forEach(match => {
        const key = match.substring(1);
        if (typeof replacements[key] === 'undefined') return;
        string = string.replace(match, replacements[key]);
    });
    return string;
}
```

#### Bash / Shell

```shell
# Get our images
for i in $(seq 1 $COUNT)
do
    echo "Fetching image ${i} of ${COUNT}"
    curl -sL "https://source.unsplash.com/random/${WIDTH}x${HEIGHT}?${TOPIC}" > "${PREFIX}image_${WIDTH}x${HEIGHT}_$i.jpg"
    sleep 0.6
done
```

#### HTML

```HTML
<div back-to-top class="primary-background print-hidden">
  <div class="inner">
     <span>Back to top</span>
  </div>
</div><a href="https://acc.bzctrl.com/bzctrl-core-api/api/v1/bookstack/attachments/41" style="text-decoration: underline; color: blue;" target="_blank">testing</a> 
```

#### Nginx

```Nginx
server {
  listen 80;
  listen [::]:80;

  server_name bookstack.dev;

  root /var/www/bookstack/public;
  index index.php index.html;

  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }
  
  location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
  }
}

```

#### Markdown

```MarkDown
### 📜 Code Standards

PHP code style is enforced automatically [using StyleCI](https://github.styleci.io/repos/41589337). 
If submitting a PR, any formatting changes to be made will be automatically fixed after merging.  <a href="https://acc.bzctrl.com/bzctrl-core-api/api/v1/bookstack/attachments/34" style="text-decoration: underline; color: blue;" target="_blank">todo-details (51).pdf</a> 

```