Rewrites the documentation

This commit is contained in:
Christophe HENRY 2022-08-01 11:15:30 +02:00
parent babf80b5ab
commit 8207df2b2e
12 changed files with 93 additions and 313 deletions

View File

@ -1,20 +1,20 @@
# Styles
=> index.gmi|default,htmgem.css htmgem.css
=> index.gmi|lagrange,lagrange.css lagrange.css
=> index.gmi|default,terminal.css terminal.css
=> index.gmi|default,black_wide.css black_wide.css
=> index.gmi|default,simple.css simple.css
=> index.gmi|default,raw.css raw.css
=> index.gmi|default,debug.css debug.css
=> index.gmi|default,htmgem.css default/htmgem.css
=> index.gmi|lagrange,lagrange.css lagrange/lagrange.css
=> index.gmi|default,terminal.css default/terminal.css
=> index.gmi|default,black_wide.css default/black_wide.css
=> index.gmi|default,simple.css default/simple.css
=> index.gmi|default,raw.css default/raw.css
=> index.gmi|default,debug.css default/debug.css
=> index.gmi|src Source code
=> index.gmi|source Download source code
Lorem ipsum dolor sit amet.
//Lorem// **ipsum** __dolor__ ~~sit amet~~.
* ligne un de liste non ordonnée
* ligne deux de liste non ordonnée
* 1 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
* 2 Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
> Citation : Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
@ -29,11 +29,11 @@ Lorem ipsum dolor sit amet.
|| ||
```
# Titre 1
# 1 1 1 1 1 1
## Titre 2
## 2 2 2 2 2 2
### Titre 3
### 3 3 3 3 3 3
=> https://gmi.sbgodin.fr

View File

@ -1,110 +0,0 @@
# BNF
### Backus-Naur Form
=> https://fr.wikipedia.org/wiki/Forme_de_Backus-Naur Wikipedia / BNF
Le but de ce document est de montrer la BNF que HtmGem utilise et la façon dont il détermine le type de ligne et quelles informations il en tire. Pour cela, il utilise des **accolades** pour montrer explicitement quelles informations il prend. De plus, la **forme canonique** montre comment ça devrait être affiché.
———————————————————— ✀ ————————————————————
textgemini = *(link / preformat / heading / ulist / quoted / plain)
; Preformat toggle starts as 'false'.
plain = **{[WSP] text} [WSP]** end-of-line
; If preformat toggle is false, wrap text to the
; width of the display. Otherwise, do no wrapping.
; canonical form = {[WSP] text}
preformat = "```" **[WSP]** [{alt-text}] **[WSP]** end-of-line
; Preformat toggle set to opposite state:
; false goes to true
; true goes to false
; While in preformat toggle is true, link, heading,
; ulist and quoted lines are NOT interpreted, but
; displayed as is to the user.
; canonical form = ``` [SP {alt-text}]
link = '=>' **[WSP]** [{URI-reference}] [**[WSP]** {text}] end-of-line
; canonical form = '=>' SP {uri-reference} [SP {text}]
heading = '#' **[WSP]** [{text}] **[WSP]** end-of-line
/ '##' **[WSP]** {text} **[WSP]** end-of-line
/ '###' **[WSP]** {text} **[WSP]** end-of-line
; canonical form = ('#' / '##' / '###') [SP {text}]
ulist = '*' **[WSP]** {text} **[WSP]** end-of-line
; canonical form = '*' SP {text}
quoted = '>' **[WSP]** {text} **[WSP]** end-of-line
; canonical form = '>' SP {text}
alt-text = text
text = ***UVCHAR**
end-of-line = [CR] LF
UVCHAR = VCHAR / UTF8-2v / UTF8-3 / UTF8-4
UTF8-2v = %xC2 %xA0-BF UTF8-tail ; no C1 control set
/ %xC3-DF UTF8-tail
; CRLF from RFC-5234
; DIGIT from RFC-5234
; SP from RFC-5234
; VCHAR from RFC-5234
; OCTET from RFC-5234
; WSP from RFC-5234
;
; UTF8-3 from RFC-3629
; UTF8-4 from RFC-3629
; UTF8-tail from RFC-3629
———————————————————— ✀ ————————————————————
Cette BNF a été adaptée à limplémentation de HtmGem depuis la version du groupe de travail.
=> https://gitlab.com/gemini-specification/gemini-text/-/issues/7 Gitlab / Original ticket
Changements :
* gestion des espaces blancs
* capture du texte {}
* forme canonique
Les espaces blancs terminant une ligne ne sont jamais utilisés. Voir la définition de //text// dans la BNF, qui ne contient plus //SP//.
# Exemples
## => liens
### Lien normal
> link = '=>' [WSP] [{URI-reference}] [[WSP] {text}] end-of-line
> ; canonical form = '=>' SP {uri-reference} [SP {text}]
Source: => foo.invalid text of the link
Data: '=>' {'foo.invalid'} {'text of the link'}
Canonical: => foo.invalid text of the link
Html: <a href="foo.invalid">text of the link</a>
Source: =>foo.invalid text of the link
Data: '=>' {'foo.invalid'} {'text of the link'}
Canonical: => foo.invalid text of the link
Html: <a href="foo.invalid">text of the link</a>
Source: => just_a_page
Data: '=>' {'just_a_page'} {}
Canonical: => just_a_page
Html: <a href="just_a_page">just_a_page</a>
Source: =>
Data: '=>' {''} {''}
Canonical: =>
Html: <a href="">&nbsp;</a>
## # En-têtes
> heading = '#' **[WSP]** [{text}] **[WSP]** end-of-line
> (…)
> ; canonical form = ('#' / '##' / '###') [SP {text}]
Source: #title
Data: '#' {"title"}
Canonical: # title
Source: # title with two spaces between title and with
Data: '#' {"title with spaces"}
Canonical: # title with two spaces between title and with

View File

@ -1,63 +0,0 @@
# Advanced configuration
❗️ This page works with URL rewriting enabled ❗️
By default, the same style is used for all the pages, //htmgem/css/htmgem.css//, except when a file having the same name as the page but with the extension **.css** exists in the same directory. In such as case, it's used.
When the CSS option is activated in the configuration (see /rewrite// below) other behaviors are possible. **Beware**, it won't work with a Gemini client as HtmGem is only reachable with a web browser.
* &style=**htmgem** : Uses the default style.
* &style=**none** : The page HTML is sent without style.
* &style=**<autre nom>** : The file htmgem/css/<autre nom>.css is used as a style.
* &style=**/<path>** : The provided file (absolute path) is used as a style.
* &style=**source** : The source code of the page is sent to the browser, see below…
* &style=**pre** : The source code of the page is sent to the browser enclosed in //<pre>//, see below…
## URL rewriting to set the style to use
Modifying the web server configuration works but it's rather heavy. It's possible to test a particular style this way:
> https://site.tld/htmgem/index.php?url=/url/page.gmi&style=<…>
It's also possible to make a URL rewriting which incorporate the style:
> rewrite ^(.+\.gmi)$ /htmgem/index.php?rw=1&url=$1;
> rewrite ^(.+\.gmi)\ *\|\ *([\w_]+)$ /htmgem/index.php?rw=1&url=$1&style=$2;
For instance, when it's activated:
=> configuration-en.gmi%20|%20pre Shows the readable source code on the screen, using the markup **<pre>**.
=> configuration-en.gmi%20|%20source configuration-en.gmi | source : Downloads the source code.
### With style already included…
=> configuration-en.gmi%20|%20htmgem Style //HtmGem//, the default style
=> configuration-en.gmi%20|%20none Style //none//
=> configuration-en.gmi%20|%20terminal Style //terminal//
=> configuration-en.gmi%20|%20black_wide Style //black wide//
=> configuration-en.gmi%20|%20simple Style //simple//
=> configuration-en.gmi%20|%20raw Style //raw//
=> configuration-en.gmi%20|%20debug Style //debug//
=> ../css Style selector: the page containing the style allows to test them 😎
## Text decoration
The text decoration, which interprets the **bold** for instance, is not part of GemText definition. The text decoration applies everywhere except on the titles and preformated texts.
### Disable the text decoration
It's possible to:
* disable and enable the text decoration with a line **^^^**,
* add what follows to the URL **rewriting**:
> &textDecoration=0
## BNF / Syntax
HtmGem uses a precise implementation of the GemText BNF. It indicates exactly what text portions are to be used.
=> BNF-en.gmi BNF
=> tutogemtext-en.gmi How to build GemText pages?
———————————————————— ————————————————————
Amongst the distributed files and directories, only the ones below are useful for HtmGem:
* **htmgem/*.php** : These files translate the GemText to HTML.
* **htmgem/css/htmgem.css** : If it's missing, the display will be without style — literally.
* **htmgem/css/…** : Keep the styles you use.
The others can be deleted (included this present file //configuration-en.gmi//) although they are not harmful.

View File

@ -1,63 +0,0 @@
# Configuration avancée
❗️ Cette page fonctionne avec la réécriture dURL activée ❗️
Par défaut, le même style est utilisé pour toutes les pages, //htmgem/css/htmgem.css//, sauf lorsquun fichier ayant le même nom que la page mais avec lextension **.css** existe dans le même répertoire. Dans ce cas, il est utilisé.
Lorsque loption css est activé dans la configuration (voir //rewrite// plus bas) dautres comportements sont possibles. **Attention**, cela ne fonctionnera pas avec un client Gemini puisque HtmGem nest accessible que via un navigateur web.
* &style=**htmgem** : Utilise le style par défaut.
* &style=**none** : La page HTML est envoyée sans style.
* &style=**<autre nom>** : Le fichier htmgem/css/<autre nom>.css est utilisé en tant que style.
* &style=**/<path>** : Le fichier indiqué (chemin absolu) est utilisé en tant que style.
* &style=**source** : Le code source de la page est envoyée au navigateur, voir ci-après…
* &style=**pre** : Le code source de la page est envoyée au navigateur encadré par des //<pre>//, voir ci-après…
## Réécriture dURL pour préciser le style à utiliser
Modifier la configuration du serveur web fonctionne mais est assez lourd. On peut tester un style en particulier de la façon suivante :
> https://site.tld/htmgem/index.php?url=/url/page.gmi&style=<…>
Il est aussi possible de faire une réécriture dURL qui intègre le style :
> rewrite ^(.+\.gmi)$ /htmgem/index.php?rw=1&url=$1;
> rewrite ^(.+\.gmi)\ *\|\ *([\w_]+)$ /htmgem/index.php?rw=1&url=$1&style=$2;
Par exemple, lorsque ce sera activé :
=> configuration-fr.gmi%20|%20pre Produit le code source de façon lisble à lécran en utilisant la balise **<pre>**.
=> configuration-fr.gmi%20|%20source configuration-fr.gmi | source : Téléverse le code source.
### Avec les styles déjà fournis…
=> configuration-fr.gmi%20|%20htmgem Style //HtmHem//, le style par défaut
=> configuration-fr.gmi%20|%20none Style //none//
=> configuration-fr.gmi%20|%20terminal Style //terminal//
=> configuration-fr.gmi%20|%20black_wide Style //black wide//
=> configuration-fr.gmi%20|%20simple Style //simple//
=> configuration-fr.gmi%20|%20raw Style //brut//
=> configuration-fr.gmi%20|%20debug Style //debug//
=> ../css Sélecteur de style : la page contenant les styles permet de les essayer 😎
## Décoration du texte
La décoration du texte, qui interprête le **gras** par exemple, ne fait pas partie de la définition de GemText. La décoration du texte sapplique partout sauf sur les titres et blocs préformatés.
### Désactiver la décoration du texte
On peut :
* désactiver et activer la décoration du texte avec une ligne **^^^**,
* ajouter ce qui suit à la **réécriture** dURL :
> &textDecoration=0
## BNF / Syntax
HtmGem utilise une implémentation précise de la BNF de GemText. Il indique exactement quelle portions de texte doivent être utilisées.
=> BNF-fr.gmi BNF
=> tutogemtext-fr.gmi Comment faire des pages GemText ?
———————————————————— ————————————————————
Parmi les fichiers et répertoires distribués, seuls sont utiles pour le fonctionnement de HtmGem :
* **htmgem/*.php** : Ces fichiers se chargent de traduire le GemText en HTML.
* **htmgem/css/htmgem.css** : Sil manque, laffichage sera dépourvu de style — littéralement.
* **htmgem/css/…** : Conservez les styles que vous utilisez.
Les autres peuvent être supprimés (y compris ce présent fichier //configuration-fr.gmi//) bien quils ne présentent aucun danger.

View File

@ -1,9 +1,12 @@
# Developers' documentation
=> BNF-en.gmi BNF / Backus-Naur Form
# Documentation
=> https://gmi.sbgodin.fr/htmgem Project main page
=> https://tildegit.org/Sbgodin/htmgem Source code, comments
=> https://gemini.circumlunar.space Main Gemini capsule
=> ../CHANGELOG.gmi Change log
=> ../COPYING.gmi Licence Gnu Affero General Public License v3 — 19 november 2007
=> ../COPYING.gmi License Gnu Affero General Public License v3 — 19 november 2007
=> BNF.gmi BNF / Backus-Naur Form
=> ../css Styles 😎
=> ../tests Tests 😅

View File

@ -1,42 +1,44 @@
# HtmGem, installation
# To install HtmGem
To run HtmGem — after having copied the files — there is nothing to do but to add the URL rewriting rules.
* Download HtmGem
=> https://tildegit.org/sbgodin/HtmGem/archive/master.zip
* Copy the files at the root of the website.
* Configurer la réécriture dURL (//URL Rewriting//).
* Write some text in /index.gmi.
* Just open your website!
## Prerequisites
* Go to /htmgem to get the documentation.
### Prerequisites
* Php v7.3 minimum
* Module **php-mbstring** to manage unicode
* A web server (Apache and Nginx tested)
* Module **mod-rewrite** to handle the Gemini pages
## Installation
### Download
=> https://tildegit.org/sbgodin/HtmGem/archive/master.zip Stable version
=> https://tildegit.org/Sbgodin/htmgem Project repository
* Module **Php-mbstring** to handle lunicode
* A web server (Apache and Nginx supported)
* Module **mod-rewrite** for the URL rewriting
### Nginx
```
# This text must be placed in the server's configuration
index index.gmi index.php index.html
rewrite ^(.+\.gmi)$ htmgem/index.php?rw=1&url=$1;
rewrite ^(.+\.gmi)$ /htmgem/index.php?rw=1&url=$1&style=default,htmgem.css;
error_page 403 /htmgem;
location = /favicon.ico { alias /var/www/dev/htmgem/favicon.ico; }
```
### Apache
```
# This text can be placed at the root of the web site in a file ".htaccess".
DirectoryIndex index.gmi index.php index.html
RewriteEngine on
RewriteRule ^(.+\.gmi)$ htmgem/index.php?rw=1&url=$1
rewriteRule ^(.+\.gmi)$ htmgem/index.php?rw=1&url=$1&style=default,htmgem.css
```
Afterwards,
* When a file ends by **.gmi.** is asked, HtmGem will display it in the browser.
* When only the directory is asked (http://site.tld/path) the file //index.gmi// will be automatically choosen.
## Text decoration
=> tutogemtext-en.gmi How to build GemText pages?
The text decoration, which interprets the bold for instance, is not part of GemText definition. The text decoration applies everywhere except on the titles and preformated texts.
## Advanced configuration
It's possible to disable the text decoration with a line **^^^** or add to the URL rewriting:
> &textDecoration=0
Add additional styles as a link parameter or adapt the text decoration:
=> configuration-en.gmi Advanced configuration
=> ../css Styles
=> tutogemtext-en.gmi How to make GemText pages?

View File

@ -1,42 +1,44 @@
# HtmGem, installation
# Pour installer HtmGem
Pour faire fonctionner HtmGem — après avoir copié les fichiers — il ne reste quà ajouter les règles de réécriture dURL (//URL Rewriting//).
* Télécharger HtmGem
=> https://tildegit.org/sbgodin/HtmGem/archive/master.zip
* Copier les fichiers à la racine du site.
* Configurer la réécriture dURL (//URL Rewriting//).
* Écrire du texte dans /index.gmi.
* Ouvrir la page du site!
* Accéder à /htmgem pour la documentation.
## Prérequis
* Php v7.3 minimum
* Module **Php-mbstring** pour gérer lunicode
* Un serveur web (Apache et Nginx testés)
* Module **mod-rewrite** pour prendre en charge les pages Gemini
## Installation
### Téléchargement
=> https://tildegit.org/sbgodin/HtmGem/archive/master.zip Version stable
=> https://tildegit.org/Sbgodin/htmgem Dépôt du projet
* Un serveur web (Apache et Nginx supportés)
* Module **mod-rewrite** pour la réécriture dURL
### Nginx
```
# Ce texte doit être placé dans la configuration du serveur.
index index.gmi index.php index.html
rewrite ^(.+\.gmi)$ htmgem/index.php?rw=1&url=$1;
rewrite ^(.+\.gmi)$ /htmgem/index.php?rw=1&url=$1&style=default,htmgem.css;
error_page 403 /htmgem;
location = /favicon.ico { alias /var/www/dev/htmgem/favicon.ico; }
```
### Apache
```
# Ce texte peut se placer à la racine du site dans un fichier ".htaccess".
DirectoryIndex index.gmi index.php index.html
RewriteEngine on
RewriteRule ^(.+\.gmi)$ htmgem/index.php?rw=1&url=$1
rewriteRule ^(.+\.gmi)$ htmgem/index.php?rw=1&url=$1&style=default,htmgem.css
```
Par la suite,
* Quand un fichier se terminant par **.gmi** sera demandé, HtmGem laffichera dans le navigateur.
* Quand seul le répertoire sera demandé (http://site.tld/path) le fichier //index.gmi// sera automatiquement choisi.
## Décoration du texte
La décoration du texte, qui interprête le **gras** par exemple, ne fait pas partie de la définition de GemText. La décoration du texte sapplique partout sauf sur les titres et blocs préformatés.
On peut désactiver la décoration du texte avec une ligne **^^^** ou ajouter à la **réécriture** dURL :
> &textDecoration=0
=> ../css Styles
=> tutogemtext-fr.gmi Comment faire des pages GemText ?
## Configuration avancée
Ajoutez des styles supplémentaires en paramètre de lien ou adaptez la décoration du texte :
=> configuration-fr.gmi Configuration avancée

View File

@ -71,4 +71,4 @@ HtmGem allows to host Gemini pages and publish them on a web server with **Php**
### License of this page
This page is under the free licence **CC BY-SA 2.0**.
=> https://creativecommons.org/licenses/by-sa/2.0/en/ Text under license CC BY-SA 2.0
=> gemini://gmi.sbgodin.fr/ gemini://gmi.sbgodin.fr/ ⸻ Christophe HENRY
=> https://gmi.sbgodin.fr/ https://gmi.sbgodin.fr/ ⸻ Christophe HENRY

View File

@ -68,7 +68,7 @@ HtmGem permet dhéberger des pages Gemini et de les publier sur un serveur we
=> https://gmi.sbgodin.fr/htmgem
### License de cette page
### Licence de cette page
Cette page est sous licence libre **CC BY-SA 2.0**.
=> https://creativecommons.org/licenses/by-sa/2.0/fr/ Texte sous licence CC BY-SA 2.0
=> gemini://gmi.sbgodin.fr/ gemini://gmi.sbgodin.fr/ ⸻ Christophe HENRY
=> https://gmi.sbgodin.fr/ https://gmi.sbgodin.fr/ ⸻ Christophe HENRY

View File

@ -1,13 +1,19 @@
# HtmGem
```
__ __ __ ______
|\ \ |\ \ |\ \ /\ \ v1.5.0
| ▓▓ | ▓▓_| ▓▓_ ______ ____ | ▓▓▓▓▓▓\
| ▓▓__| ▓▓ ▓▓ \ |\ \ \| ▓▓ __\▓▓/\ \| \ \
| ▓▓ ▓▓\▓▓▓▓▓▓ | ▓▓▓▓▓▓\▓▓▓▓\ ▓▓| \ ▓▓▓▓▓▓\ ▓▓▓▓▓▓\▓▓▓▓\
| ▓▓▓▓▓▓▓▓ | ▓▓ __| ▓▓ | ▓▓ | ▓▓ ▓▓ \▓▓▓▓ ▓▓ ▓▓ ▓▓ | ▓▓ | ▓▓
| ▓▓ | ▓▓ | ▓▓| \ ▓▓ | ▓▓ | ▓▓ ▓▓__| ▓▓ ▓▓▓▓▓▓▓▓ ▓▓ | ▓▓ | ▓▓
| ▓▓ | ▓▓ \▓▓ ▓▓ ▓▓ | ▓▓ | ▓▓\▓▓ ▓▓\▓▓ \ ▓▓ | ▓▓ | ▓▓
\▓▓ \▓▓ \▓▓▓▓ \▓▓ \▓▓ \▓▓ \▓▓▓▓▓▓ \▓▓▓▓▓▓▓\▓▓ \▓▓ \▓▓
=> docs/installation-fr.gmi Installation de HtmGem, en français
HtmGem rend vos pages **Gemini** accessibles sur le web. Il fonctionne aussi en hébergement mutualisé.
=> docs/tutogemtext-fr.gmi Tutoriel GemText
```
=> docs/installation-en.gmi HtmGem installation, in English
HtmGem makes your **Gemini** pages reachable on the web. It can be used on a shared host.
=> docs/tutogemtext-en.gmi GemText tutorial
=> docs/installation-fr.gmi 🇫🇷 HtmGem rend vos pages **Gemini** accessibles sur le web.
=> docs/installation-en.gmi 🇺🇸 HtmGem makes your **Gemini** pages reachable on the web.
=> docs/index.gmi **Developers' documentation**
The documentation (in English) for the developers's stands here. Please read them carefully before doing anything on the source code.
=> docs/index.gmi 🇺🇸 **Documentation**

View File

@ -1,6 +1,8 @@
# Tests
This test suite aims to check the quality of the translation of the fulltext source pages to HTML pages. As usual, its purpose is to protect the project against regression. So these tests should be run before commits (see **./cli/precommit.git**).
This test suite aims to check the quality of the translation of the fulltext source pages to HTML pages.
In the HtmGem root directory, just type **phpunit tests** to check.
### parserTest.php
The parser takes the gemtext contained in the **.gmi** file and returns the internal format.
@ -11,9 +13,10 @@ The translator takes the gemtext, parse it and returns an HTML representation.
### translateToGemtextTest.php
This translator takes the gemtext, parse it and rebuild the gemtext. The output must be identical of the input. When there are optional spaces, they are trimmed. In such cases, the translation will return a kind of normalised gemtext — that is, without the spaces.
### ./cli
It contains files to play around with the API:
### cli
The directory contains files to play around with the API:
* parse_gemtext: outputs a //print_r()// of the internal representation
* translate_to_gemtext: outputs the regenerated gemtext
* translate_to_html: outputs the html-ified gemtext
//pre-commit.git// is to be moved to //./.git/hooks/pre-commit//, be //chmod x//-ed to run this test suit before committing.
//pre-commit.git// is to be moved to //./.git/hooks/pre-commit// and //chmod x//-ed to run this test suit before committing.