81 lines
2.0 KiB
Markdown
81 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.gmi**
|
|
````markdown
|
|
Everything until the first <!--break--> in the map file will be put in place of the following insert-gopher tag.
|
|
|
|
<!--insert-gopher-->
|
|
|
|
The <script> tag should be removed because it is between two web-only tags.
|
|
|
|
<!--web-only-->
|
|
<script>
|
|
console.log("joj")
|
|
</script>
|
|
<!--web-only-->
|
|
|
|
> Everything after the first <!--break--> in the map file:
|
|
|
|
<!--insert-gopher-->
|
|
````
|
|
|
|
**map.txt**
|
|
```gophermap
|
|
<?php
|
|
echo "i" . date(DATE_RFC2822) . "\tFAKE\tNULL\t0";
|
|
?>
|
|
<!--break-->
|
|
A line from map.txt
|
|
```
|
|
|
|
> If a line in map.txt isn't in format `i /PATH host 123` it **will not** automatically get converted into that format,
|
|
> your **server is expected to do that** or you should write that explicitly in the map.txt file.
|
|
>
|
|
> This has been done to allow injecting PHP scripts.
|
|
> (to avoid: `i<?php /FAKE NULL 0`)
|
|
|
|
#### Command
|
|
```shell
|
|
gemtext2gophermap input.gmi - 70 map.txt
|
|
```
|
|
If `-` is passed instead of `input or output` file name `stdin or 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 following insert-gopher tag. /FAKE NULL 0
|
|
<?php
|
|
echo date(DATE_RFC2822);
|
|
?>
|
|
|
|
iThe <script> tag should be removed because it is between two web-only /FAKE NULL 0
|
|
itags. /FAKE NULL 0
|
|
i> Everything after the first <!--break--> in the map file: /FAKE NULL 0
|
|
|
|
A line from map.txt
|
|
```
|