92 lines
2.0 KiB
Markdown
92 lines
2.0 KiB
Markdown
> **Note**
|
|
>
|
|
> This program expects that your Gopher server treats **empty lines** as **information lines**.
|
|
>
|
|
> It also expects the server to **add the hostname** and the **port** number at the end of links.
|
|
|
|
### Compiling
|
|
|
|
You need to have Go toolchain installed:
|
|
```shell
|
|
# Debian
|
|
sudo apt install golang
|
|
|
|
# Fedora
|
|
sudo dnf install golang
|
|
```
|
|
|
|
Then, just **clone the repo** and run **`go build .`** to compile an executable.
|
|
|
|
### Usage
|
|
```shell
|
|
gemtext2gophermap input.gmi output_gophermap [max line length (default 70)] [preprocessor insertion map file]
|
|
```
|
|
|
|
## Example
|
|
|
|
### Input Gemtext
|
|
_input.gmi_
|
|
````gemtext
|
|
Everything until the first <!--break--> in the map file will be put in place of the insert-gopher tag.
|
|
|
|
```html
|
|
<!--insert-gopher-->
|
|
```
|
|
|
|
The following <script> tag will be removed because it is between to web-only tags.
|
|
|
|
```html
|
|
<!--web-only-->
|
|
```
|
|
|
|
```html
|
|
<script>
|
|
console.log("joj")
|
|
</script>
|
|
```
|
|
|
|
```html
|
|
<!--web-only-->
|
|
```
|
|
|
|
> Here, the contents after the first break in the map file will be put
|
|
|
|
```html
|
|
<!--insert-gopher-->
|
|
```
|
|
````
|
|
|
|
### A map file
|
|
_map.txt_
|
|
```gophermap
|
|
<?php
|
|
echo "i" . date(DATE_RFC2822) . "\t/FAKE\tNULL\t0";
|
|
?>
|
|
<!--break-->
|
|
iIf your Gopher server supports running PHP it should have printed the current date. /FAKE NULL 0
|
|
```
|
|
|
|
### Command
|
|
```shell
|
|
gemtext2gophermap input.gmi - 70 map.txt
|
|
```
|
|
If `-` is passed instead of `input/output` file name `stdin/stdout` will be used. Reading the **map file from stdin** is **not supported**.
|
|
|
|
### Output
|
|
```gophermap
|
|
iEverything until the first <!--break--> in the map file will be put in /FAKE NULL 0
|
|
iplace of the insert-gopher tag. /FAKE NULL 0
|
|
|
|
<?php
|
|
echo "i" . date(DATE_RFC2822) . "\t/FAKE\tNULL\t0";
|
|
?>
|
|
|
|
iThe following <script> tag will be removed because it is between to /FAKE NULL 0
|
|
iweb-only tags. /FAKE NULL 0
|
|
|
|
i> Here, the contents after the first break in the map file will be put /FAKE NULL 0
|
|
|
|
|
|
iIf your Gopher server supports running PHP it should have printed the current date. /FAKE NULL 0
|
|
```
|