New code cleaned. Indev: wip. Some converting done
This commit is contained in:
parent
4491cb94d2
commit
38e977ec1d
17
README.md
17
README.md
|
@ -110,14 +110,19 @@ un long paragraphe
|
||||||
|
|
||||||
### Lien vers URL
|
### Lien vers URL
|
||||||
```
|
```
|
||||||
Voir ce _Nom du lien
|
Voir ce _Nom du lien # Ouverture même fenêtre
|
||||||
|
Voir ce _Nom du lien+ # ouverture nouvelle fenêtre
|
||||||
```
|
```
|
||||||
|
|
||||||
### Lien vers fichier
|
### Lien vers fichier
|
||||||
```
|
```
|
||||||
Voir ce __Nom du lien
|
Voir ce __Nom du lien # Ouverture même fenêtre
|
||||||
|
Voir ce __Nom du lien+ # ouverture nouvelle fenêtre
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note:
|
||||||
|
Vous pouvez avoir un NAME identique pour file: et link:
|
||||||
|
|
||||||
### Gras, Strong, italique...
|
### Gras, Strong, italique...
|
||||||
```
|
```
|
||||||
*_très gras_* # <strong>
|
*_très gras_* # <strong>
|
||||||
|
@ -148,11 +153,11 @@ Avec ce NOM.
|
||||||
# affichage les une à côté des autres
|
# affichage les une à côté des autres
|
||||||
_image:NOM
|
_image:NOM
|
||||||
_image:NOM c=CSS
|
_image:NOM c=CSS
|
||||||
_image:NOM c=CSS w=1080
|
_image:NOM c=css w=1080
|
||||||
_image:NOM w=640em h=480em
|
_image:NOM w=640em h=480em
|
||||||
_image:NOM t= <<< Rend l'image interne cliquable
|
_image:NOM t=+ # Rend l'image interne cliquable
|
||||||
_image:NOM t=https://...
|
_image:NOM t=https://...# Donne un lien à l'image
|
||||||
_image:NOM c=CSS t=https:// w=320px h=240
|
_image:NOM c=CSS t=https://... w=320px h=240
|
||||||
```
|
```
|
||||||
|
|
||||||
### Code Brut depuis un fichier
|
### Code Brut depuis un fichier
|
||||||
|
|
|
@ -277,8 +277,9 @@ def check_headers(post_header):
|
||||||
post_err = True
|
post_err = True
|
||||||
|
|
||||||
if not post_err:
|
if not post_err:
|
||||||
web_link = '<a class="%s" href="%s" title="%s">%s</a>'%(
|
web_link = '<a class="%s" href="%s" '%('link', link_url) + \
|
||||||
'link', link_url, link_alt, link_name
|
'target="%s" title="%s">%s</a>'%(
|
||||||
|
'%s', link_alt, link_name
|
||||||
)
|
)
|
||||||
globals()['link_%s'%stat_links] = (
|
globals()['link_%s'%stat_links] = (
|
||||||
'_%s'%link_name, web_link
|
'_%s'%link_name, web_link
|
||||||
|
@ -388,8 +389,9 @@ def check_headers(post_header):
|
||||||
post_err = True
|
post_err = True
|
||||||
|
|
||||||
if not post_err:
|
if not post_err:
|
||||||
web_link = '<a class="%s" href="%s" title="%s">%s</a>'%(
|
web_link = '<a class="%s" href="%s" '%('file', web_uri) + \
|
||||||
'file', web_uri, file_alt, file_name
|
'target="%s" title="%s">%s</a>'%(
|
||||||
|
'%s', file_alt, file_name
|
||||||
)
|
)
|
||||||
globals()['file_%s'%stat_files] = (
|
globals()['file_%s'%stat_files] = (
|
||||||
'__%s'%file_name, web_link
|
'__%s'%file_name, web_link
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#----------------------------------------------------------------------
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
#**********************************************************************
|
#**********************************************************************
|
||||||
import os
|
import os, re
|
||||||
import tyto
|
import tyto
|
||||||
|
|
||||||
def manage_wip(target, option):
|
def manage_wip(target, option):
|
||||||
|
@ -84,7 +84,8 @@ def wip_article(target):
|
||||||
# Convert contents from modules
|
# Convert contents from modules
|
||||||
wip_single_tags() # br /, anchors
|
wip_single_tags() # br /, anchors
|
||||||
wip_words_tags() # Paragraphs, strongs, italics
|
wip_words_tags() # Paragraphs, strongs, italics
|
||||||
wip_links() # Links from headers in DB
|
wip_links() # Links_%i from headers in DB
|
||||||
|
wip_images() # Images_%i from headers in DB
|
||||||
|
|
||||||
print(article_bottom)
|
print(article_bottom)
|
||||||
|
|
||||||
|
@ -172,17 +173,95 @@ def wip_words_tags():
|
||||||
def wip_links():
|
def wip_links():
|
||||||
global article_bottom
|
global article_bottom
|
||||||
|
|
||||||
if uniq_links > 0:
|
# Doing files, first, becase of similar marker
|
||||||
for i in range(1, uniq_links + 1):
|
|
||||||
link = 'link_%s'%i
|
|
||||||
article_bottom = article_bottom.replace(
|
|
||||||
eval(link)[0], eval(link)[1]
|
|
||||||
)
|
|
||||||
|
|
||||||
if uniq_files > 0:
|
if uniq_files > 0:
|
||||||
for i in range(1, uniq_files + 1):
|
for i in range(1, uniq_files + 1):
|
||||||
file = 'file_%s'%i
|
file = 'file_%s'%i
|
||||||
article_bottom = article_bottom.replace(
|
article_bottom = article_bottom.replace(
|
||||||
eval(file)[0], eval(file)[1]
|
eval(file)[0]+'+', eval(file)[1]%('_blank')
|
||||||
|
)
|
||||||
|
article_bottom = article_bottom.replace(
|
||||||
|
eval(file)[0], eval(file)[1]%('_self')
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if uniq_links > 0:
|
||||||
|
for i in range(1, uniq_links + 1):
|
||||||
|
link = 'link_%s'%i
|
||||||
|
article_bottom = article_bottom.replace(
|
||||||
|
eval(link)[0]+'+', eval(link)[1]%('_blank')
|
||||||
|
)
|
||||||
|
article_bottom = article_bottom.replace(
|
||||||
|
eval(link)[0], eval(link)[1]%('_self')
|
||||||
|
)
|
||||||
|
|
||||||
|
#-------------------------------------#
|
||||||
|
# Get width and height for image #
|
||||||
|
# from parameter c=, from wip_image() #
|
||||||
|
#-------------------------------------#
|
||||||
|
def get_wh_image(value):
|
||||||
|
sizes = re.findall(r'(\d+)|(\D+)', value)
|
||||||
|
if not sizes[0][1]: return('%spx'%value)
|
||||||
|
else: return(value)
|
||||||
|
|
||||||
|
#=================================#
|
||||||
|
# Find all _image, get parameters #
|
||||||
|
# Convert _images:%name to HTML #
|
||||||
|
#---------------------------------#
|
||||||
|
def wip_images():
|
||||||
|
global article_bottom
|
||||||
|
|
||||||
|
if uniq_images > 0:
|
||||||
|
image_link = '<a class="%s" href="%s" title="%s">%s</a>'
|
||||||
|
image_show = '<img class="%s" src="%s" alt="%s"%s />'
|
||||||
|
|
||||||
|
for ln, line in enumerate(article_bottom.rsplit('\n')):
|
||||||
|
if line.startswith('_image:'):
|
||||||
|
values = line.rsplit(' ')
|
||||||
|
#print(values)
|
||||||
|
|
||||||
|
for i in range(1, uniq_images + 1):
|
||||||
|
image = 'image_%s'%i
|
||||||
|
target = width = height = False
|
||||||
|
set_css = tyto.domain_css + '_image'
|
||||||
|
|
||||||
|
if eval(image)[0] == values[0]:
|
||||||
|
for value in values:
|
||||||
|
if 't=' in value:
|
||||||
|
target = value.rsplit('=',1)[1]
|
||||||
|
if target == "+": image_target = eval(image)[1]
|
||||||
|
else: image_target = target
|
||||||
|
|
||||||
|
if 'c=' in value:
|
||||||
|
set_css = value.rsplit('=', 1)[1]
|
||||||
|
|
||||||
|
if 'w=' in value:
|
||||||
|
width = get_wh_image(value.rsplit('=',1)[1])
|
||||||
|
|
||||||
|
if 'h=' in value:
|
||||||
|
height = get_wh_image(value.rsplit('=',1)[1])
|
||||||
|
|
||||||
|
if width and height:
|
||||||
|
style = ' style="width:%s;height=%s"'%(width, height)
|
||||||
|
elif width:
|
||||||
|
style = ' style="width:%s"'%width
|
||||||
|
elif height:
|
||||||
|
style = ' style="height:%s"'%height
|
||||||
|
else:
|
||||||
|
style = ''
|
||||||
|
|
||||||
|
image_src = image_show%(
|
||||||
|
set_css, eval(image)[1], eval(image)[2], style
|
||||||
|
)
|
||||||
|
|
||||||
|
if target:
|
||||||
|
image_tgt = image_link%(
|
||||||
|
set_css, image_target, eval(image)[2], '%s'
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
image_tgt = '%s'
|
||||||
|
|
||||||
|
image_html = image_tgt%image_src
|
||||||
|
|
||||||
|
article_bottom = article_bottom.replace(
|
||||||
|
article_bottom.rsplit('\n')[ln], image_html
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue