[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: créer des liens html depuis fichier texte



Marc,

Je vais garder ta solution, désolé les autres.
Je vais creuser.

Bon week-à tous

Le 15 septembre 2017 à 15:57, Marc Chantreux <mc@unistra.fr> a écrit :
On Fri, Sep 15, 2017 at 03:06:40PM +0200, David Martin wrote:
> L'ideal serait que je trouve un petit projet opensource, avec un petit
> formulaire php qui permette
> à l'exploitation de les saisir.

degainer php pour ca me semble bien overkill ... pour transformer ca:

http://example.fr haah mais trop bien
http://example.fr haah mais trop bien
http://example.fr haah mais trop bien

en ca:


<p>
<a href="" href="http://example.fr" rel="noreferrer" target="_blank">http://example.fr" target="_blank">haah mais trop bien</a>
<a href="" href="http://example.fr" rel="noreferrer" target="_blank">http://example.fr" target="_blank">haah mais trop bien</a>
<a href="" href="http://example.fr" rel="noreferrer" target="_blank">http://example.fr" target="_blank">haah mais trop bien</a>
</p>

voila qui me semble suffisant

        sed -r 's/^(\S+) +(.*)/[\2](\1){target="_blank"}/' | pandoc -thtml

avec tous les avantages liés a pandoc : tu pourras avoir la sortie html,
pdf, ajouter des templates ...

au passage: j'aurais tendance a écrire tout en utilisant pandoc

$ grep . links.*
links.template:# list of my links
links.template:$for(links)$ [$links.desc$]($links.url$) $endfor$
links.yml:---
links.yml:links:
links.yml:    - {url: "http://les exemples (pas cools)", desc: "voici une URL flinguée"}
links.yml:    - {url: "http://les.exemples"            , desc:  "une 2eme pour la route"}
links.yml:oops:
links.yml:    - ["hello","world"]
links.yml:---
$ pandoc --template links.template links.yml|pandoc

 <h1 id="list-of-my-links">list of my links</h1>
 <p><a href="" href="http://les" rel="noreferrer" target="_blank">http://les%20exemples%20(pas%20cools)">voici une URL
 flinguée</a> <a href="" href="http://les.exemples" rel="noreferrer" target="_blank">http://les.exemples">une 2eme pour la
 route</a></p>

si tu ajoute un -s au dernier pandoc, il te fait une page complete.

cordialement,
marc



--
david martin


Reply to: