fix(py): Regular Expressions for text format fixed.

This commit is contained in:
KyMAN 2024-11-14 12:09:12 +01:00
parent 2fee5fa5d1
commit 1c43e093e9
11 changed files with 1576 additions and 157 deletions

1209
CSharp/WMarkDown.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -282,6 +282,17 @@ const WMarkDown = function(inputs){
return box; return box;
}; };
this.get_anp = item => {
while(!item.classList.contains("anp") && (item = item.parentNode))
if(!item.classList){
item = null;
break;
};
return item;
};
/** /**
* @returns {void} * @returns {void}
* @access private * @access private
@ -298,10 +309,21 @@ const WMarkDown = function(inputs){
/** @type {HTMLElement} */ /** @type {HTMLElement} */
content = block.querySelector(".content"), content = block.querySelector(".content"),
/** @type {String} */ /** @type {String} */
type = block.getAttribute("data-type").toLowerCase(); type = block.getAttribute("data-type").toLowerCase(),
/** @type {HTMLElement|null} */
anp_item = self.get_anp(block),
/** @type {Boolean} */
dark_mode = (
anp_item ? (anp_item.getAttribute("data-gui_mode") == "dark" || (anp_item.getAttribute("data-gui-mode") == "default" && anp_item.getAttribute("data-dark-mode") == "true")) :
window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches);
block.setAttribute("data-processed", true); block.setAttribute("data-processed", true);
mermaid.initialize({
theme : dark_mode ? "dark" : "default",
themeVariables : {fontSize : "16px"}
});
if(["math", "maths", "mathjax"].includes(language)){ if(["math", "maths", "mathjax"].includes(language)){
build_special_type(content, "MathJax").innerHTML = MathJax.tex2chtml(content.innerText).outerHTML; build_special_type(content, "MathJax").innerHTML = MathJax.tex2chtml(content.innerText).outerHTML;
MathJax.startup.document.clear(); MathJax.startup.document.clear();

View File

@ -657,4 +657,11 @@
"https://x.com/litecoin", "https://x.com/litecoin",
"https://www.reddit.com/r/litecoin/" "https://www.reddit.com/r/litecoin/"
] ]
], [
[
["/\\bsrx06\\b/gi", "Grillo Team"],
["/\\bgri(ll+|y)o[ \t]*t(e[ae]|i)[mn]\\b/gi", "Grillo Team"]
], [
"Grupo profesional de las TIC."
], []
]] ]]

View File

@ -0,0 +1,144 @@
[[
[
["/\\bpadr[oó]n *municipal *(de *)?habitantes\\b/ig", "Padrón Municipal de Habitantes"],
["/\\bpadr[oó]n *(de *)?habitantes\\b/ig", "Padrón de Habitantes"],
["/\\bpadr[oó]n\\b/ig", "Padrón"],
["/(?<!\\.)(\\bpmh\\b|\\bp\\. *m\\. *h\\. *)/ig", "PMH"]
], [
"El Padrón de Habitantes, o Padrón Municipal de Habitantes o PMH en el caso ",
"de España, es una base de datos para el registro de los ciudadanos."
], [
"https://es.wikipedia.org/wiki/Padr%C3%B3n_municipal_de_habitantes",
"https://www.ine.es/dyngs/INEbase/es/categoria.htm?c=Estadistica_P&cid=1254734710990"
]
], [
[
["/\\bcomunidad(es)? *aut[oó]noma(s)?\\b/ig", "Comunidad$1 Autónoma$2"],
["/(?<!\\.)(\\bccaa\\b|c{1,2}\\. *a{1,2}\\. *)/gi", "CCAA"],
["/\\bciudad(es)? *aut[óo]noma(s)?\\b/gi", "Ciudad$1 Autónoma$2"]
], [
"Las Comunidades Autónomas son las subdivisiones territoriales dentro del país, ",
"las cuales con tienen las subdivisiones provinciales. Las Ciudades Autónomas ",
"como Ceuta y Melilla también están dentro de estas subdivisiones, aunque tengan ",
"otro nombre."
], [
"https://www.ine.es/jaxiT3/Tabla.htm?t=3035&L=0",
"https://www.educacionfpydeportes.gob.es/eu/contenidos/in/comunidades-autonomas.html",
"https://administracion.gob.es/pagFront/espanaAdmon/directorioOrganigramas/comunidadesAutonomas/comunidadesAutonomas.htm",
"https://administracion.gob.es/pag_Home/atencionCiudadana/SedesElectronicas-y-Webs-Publicas/websPublicas/WP_CCAA.html",
"https://es.wikipedia.org/wiki/Comunidad_aut%C3%B3noma"
]
], [
["/\\bprovincia(s)?\\b/ig", "Provincia$1"], [
"Las Provincias son las subdivisiones de las Comunidades Autónomas y Ciudades ",
"Autónomas, pudiendo éstas la propia provincia como pasa con el Principado de ",
"Asturias."
], [
"https://www.ine.es/daco/daco42/codmun/cod_provincia_estandar.htm",
"https://es.wikipedia.org/wiki/Provincia_(Espa%C3%B1a)",
"https://commons.wikimedia.org/wiki/Category:Provinces_of_Spain"
]
], [
[
["/\\bmunicipio(s)?\\b/ig", "Municipio$1"],
["/\\bayuntamiento(s)?\\b/ig", "Ayuntamiento$1"],
["/\\bconcello(s)?\\b/ig", "Concello$1"]
], [
"Los Municipios son la partición del territorio Español mínimo a nivel de ",
"Gobierno, siendo éste el Ayuntamiento (Concello en gallego) el órgano de ",
"Gobierno Local."
], [
"http://ayuntamientos.org.es/",
"https://es.wikipedia.org/wiki/Municipio",
"https://es.wiktionary.org/wiki/municipio",
"https://es.wikipedia.org/wiki/Ayuntamiento_(Espa%C3%B1a)"
]
], [
[
["/\\bc[oó]digo(s)? *postal(es)?\\b/ig", "Código$1 Postal$2"],
["/(?<!\\.)(\\bcp\\b|\\bc\\. *p\\. *)/ig", "CP"]
], [
"Los Códigos Postales son una serie de códigos de 5 dígitos que representan áreas ",
"más pequeñas que los Municipios, de código único que se reparten a nivel nacional."
], [
"https://www.correos.es/es/es/herramientas/codigos-postales/detalle",
"https://www.codigospostales.com/mapfus.html",
"https://es.wikipedia.org/wiki/C%C3%B3digo_postal",
"https://es.wikipedia.org/wiki/C%C3%B3digo_postal_de_Espa%C3%B1a"
]
], [
[
["/\\binstituto *nacional *(de *)estad[ií]stica\\b/ig", "Instituto Nacional de Estadística"],
["/(?<!\\.)(\\bine\\b|\\bi\\. *n\\. *e\\. *)/ig", "INE"]
], [
"El Instituto Nacional de Estadística, también conocido como INE por sus siglas, es ",
"el órgano administrativo del estado encargado de la gestión de estadísticas estatales ",
"así como de la gestión de gran parte de los datos a nivel centralizado del estado, ",
"donde todas las competencias independientes dentro del mismo han de aportar los datos ",
"pertinentes según sea necesario."
], [
"https://www.ine.es/",
"https://sede.ine.gob.es/",
"https://es.wikipedia.org/wiki/Instituto_Nacional_de_Estad%C3%ADstica_(Espa%C3%B1a)",
"http://www.datosgraficos.com/"
]
], [
[
["/\\bdocumento *nacional *(de *)identidad\\b/ig", "Documento Nacional de Identidad"],
["/(?<!\\.)(\\bdni\\b|\\bd\\. *n\\. *i\\. *)/ig", "DNI"],
["/\\bn[úu]mero *(de *)(identificaci[oó]n|identidad) *(de *)extranjer([ií]a|o)\\b/ig", "Número de Identidad de Extranjero"],
["/(?<!\\.)(\\bnie\\b|\\bn\\. *i\\. *e\\. *)/ig", "NIE"],
["/\\bn[uú]mero *(de *)identificaci[oó]n *fiscal\\b/ig", "Número de Identificación Fiscal"],
["/(?<!\\.)(\\bnif\\b|\\bn\\. *i\\. *f\\. *)/ig", "NIF"],
["/\\bc[oó]digo *(de *)identificaci[oó]n *fiscal\\b/ig", "Código de Identificación Fiscal"],
["/(?<!\\.)(\\bcif\\b|\\bc\\. *i\\. *f\\. *)/ig", "CIF"]
], [
"Para identificar a las personas físicas y jurídicas en España se emplean diversos sistemas, ",
"siendo el más común y conocido el DNI para identificar a las personas físicas; pero también ",
"tenemos el NIE para extranjeros residentes España; NIF para hacer una identificación fiscal y ",
"tributaria de las personas físicas; o CIF para lo mismo pero para el caso de las personas ",
"jurídicas."
], [
"https://www.dnielectronico.es/",
"https://www.citapreviadnie.es/",
"https://www.interior.gob.es/opencms/es/servicios-al-ciudadano/tramites-y-gestiones/dni/",
"https://es.wikipedia.org/wiki/Documento_nacional_de_identidad_(Espa%C3%B1a)",
"https://sede.policia.gob.es/portalCiudadano/_es/tramites_ciudadania_dnielectronico.php",
"https://www.interior.gob.es/opencms/es/servicios-al-ciudadano/tramites-y-gestiones/extranjeria/ciudadanos-de-la-union-europea/numero-de-Identidad-de-extranjero-nie/",
"https://sede.policia.gob.es/portalCiudadano/_es/tramites_extranjeria_tramite_asignacion_nie.php",
"https://www.inclusion.gob.es/web/migraciones/w/numero-de-identidad-de-extranjero-nie-hi91",
"https://sede.administracionespublicas.gob.es/pagina/index/directorio/icpplus",
"https://es.wikipedia.org/wiki/N%C3%BAmero_de_identificaci%C3%B3n_fiscal",
"https://www.boe.es/buscar/doc.php?id=BOE-A-2007-15984",
"https://www.boe.es/buscar/doc.php?id=BOE-A-1990-6394",
"https://sede.agenciatributaria.gob.es/Sede/censos-nif-domicilio-fiscal/solicitar-nif.html",
"https://www.exteriores.gob.es/Consulados/toulouse/es/ServiciosConsulares/Paginas/index.aspx?scca=Pasaportes+y+otros+documentos&scco=Francia&scd=281&scs=N%C3%BAmero+de+Identificaci%C3%B3n+Fiscal+(NIF)",
"https://es.wikipedia.org/wiki/C%C3%B3digo_de_identificaci%C3%B3n_fiscal",
"https://www.boe.es/buscar/doc.php?id=BOE-A-2007-15984"
]
], [
["/\\bunidad *familiar\\b/gi", "Unidad Familiar"], [
"La Unidad Familiar o convivientes, viene siendo las personas que conviven bajo una misma vivienda."
], [
"https://taxdown.es/taxductor/taxductor-unidad-familiar-que-es/",
"https://sede.agenciatributaria.gob.es/Sede/ayuda/manuales-videos-folletos/manuales-ayuda-presentacion/irpf-2019/3-cuestiones-generales/3_2-tributacion-individual-conjunta/3_2_1-unidad-familiar.html",
"https://sede.agenciatributaria.gob.es/Sede/irpf/tengo-que-presentar-declaracion/declaracion-individual-conjunta/que-unidad-familiar.html",
"https://www.conceptosjuridicos.com/unidad-familiar/",
"https://www.sepe.es/HomeSepe/es/Personas/distributiva-prestaciones/FAQS/solicitud-prestaciones/libro-familia-acreditacion-unidad-familiar.html"
]
], [
[
["/\\bdirecci[oó]n *general *(de *)catastr(o|al)\\b/gi", "Dirección General de Catastro"],
["/\\bcatastr(os?|al(es)?)\\b/gi", "Catastr$1"]
], [
"Catastro es un órgano administrativo vinculado a la Hacienda Pública la cua registra las ",
"propiedades, inmuebles, terrenos y áreas. En cada país puede funcionar distinto dependiendo ",
"del orden administrativo y/o estatal que posea."
], [
"https://www.catastro.hacienda.gob.es/",
"https://www.sedecatastro.gob.es/",
"https://www1.sedecatastro.gob.es/Cartografia/mapa.aspx?buscar=S",
"https://es.wikipedia.org/wiki/Catastro",
"https://es.wikipedia.org/wiki/Direcci%C3%B3n_General_del_Catastro"
]
]]

View File

@ -65,6 +65,8 @@
padding: .1em; padding: .1em;
white-space: nowrap; white-space: nowrap;
box-sizing: border-box; } box-sizing: border-box; }
.wmd-code-block[data-type=mermaid] svg {
font-size: 1em; }
.wmd-quote { .wmd-quote {
display: flex; display: flex;

File diff suppressed because one or more lines are too long

View File

@ -67,6 +67,7 @@ $transition-out : 1s;
box-sizing : border-box; box-sizing : border-box;
} }
} }
&[data-type=mermaid] svg{font-size : 1em;}
} }
.wmd-quote{ .wmd-quote{
display : flex; display : flex;

View File

@ -9,9 +9,7 @@ html, body {
left: 0em; left: 0em;
width: 100%; width: 100%;
height: 100%; height: 100%;
overflow: hidden; overflow: hidden; }
background-color: #EFEFEF;
color: #222; }
.wmarkdown-web, .wmarkdown-web input, .wmarkdown-web button, .wmarkdown-web select { .wmarkdown-web, .wmarkdown-web input, .wmarkdown-web button, .wmarkdown-web select {
font-family: "Roboto"; } font-family: "Roboto"; }
.wmarkdown-web pre, .wmarkdown-web textarea, .wmarkdown-web pre, .wmarkdown-web textarea,
@ -25,6 +23,62 @@ html, body {
font-size: 1em; } font-size: 1em; }
.wmarkdown-web [data-visible=false], .wmarkdown-web [data-hidden=true] { .wmarkdown-web [data-visible=false], .wmarkdown-web [data-hidden=true] {
display: none; } display: none; }
.wmarkdown-web[data-gui-mode=light], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] {
background-color: #EFEFEF;
color: #222; }
.wmarkdown-web[data-gui-mode=light] a[href], .wmarkdown-web[data-gui-mode=light] [onclick], .wmarkdown-web[data-gui-mode=light] [onmouseover], .wmarkdown-web[data-gui-mode=light] [onmousedown], .wmarkdown-web[data-gui-mode=light] button, .wmarkdown-web[data-gui-mode=light] [type=button], .wmarkdown-web[data-gui-mode=light] [type=reset], .wmarkdown-web[data-gui-mode=light] [type=submit], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] a[href], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onclick], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onmouseover], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onmousedown], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] button, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=button], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=reset], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=submit] {
color: #008844; }
.wmarkdown-web[data-gui-mode=light] a[href]:hover, .wmarkdown-web[data-gui-mode=light] [onclick]:hover, .wmarkdown-web[data-gui-mode=light] [onmouseover]:hover, .wmarkdown-web[data-gui-mode=light] [onmousedown]:hover, .wmarkdown-web[data-gui-mode=light] button:hover, .wmarkdown-web[data-gui-mode=light] [type=button]:hover, .wmarkdown-web[data-gui-mode=light] [type=reset]:hover, .wmarkdown-web[data-gui-mode=light] [type=submit]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] a[href]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onclick]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onmouseover]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onmousedown]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] button:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=button]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=reset]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=submit]:hover {
color: #880044; }
.wmarkdown-web[data-gui-mode=light] [onmouseover], .wmarkdown-web[data-gui-mode=light] [onmousedown], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onmouseover], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onmousedown] {
color: #115533; }
.wmarkdown-web[data-gui-mode=light] [onmouseover]:hover, .wmarkdown-web[data-gui-mode=light] [onmousedown]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onmouseover]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [onmousedown]:hover {
color: #551133; }
.wmarkdown-web[data-gui-mode=light] button, .wmarkdown-web[data-gui-mode=light] [type=button], .wmarkdown-web[data-gui-mode=light] [type=reset], .wmarkdown-web[data-gui-mode=light] [type=submit], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] button, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=button], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=reset], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=submit] {
border-color: 0.1em solid #008844;
box-shadow: 0em 0em 0.4em #008844; }
.wmarkdown-web[data-gui-mode=light] button:hover, .wmarkdown-web[data-gui-mode=light] [type=button]:hover, .wmarkdown-web[data-gui-mode=light] [type=reset]:hover, .wmarkdown-web[data-gui-mode=light] [type=submit]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] button:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=button]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=reset]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] [type=submit]:hover {
border-color: 0.1em solid #880044;
box-shadow: 0em 0em 0.4em #880044; }
.wmarkdown-web[data-gui-mode=light] .wmd-dictionary-item, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] .wmd-dictionary-item {
color: #115533; }
.wmarkdown-web[data-gui-mode=light] .wmd-dictionary-item:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] .wmd-dictionary-item:hover {
color: #551133; }
.wmarkdown-web[data-gui-mode=light] header, .wmarkdown-web[data-gui-mode=light] footer, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] header, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] footer {
box-shadow: 0em 0em 0.125em #EFEFEF, 0em 0em 0.25em #EFEFEF, 0em 0em 0.5em #EFEFEF, 0em 0em 1em #EFEFEF, 0em 0em 2em #EFEFEF; }
.wmarkdown-web[data-gui-mode=light] .wmd-dictionary-box, .wmarkdown-web[data-gui-mode=light] .wmd-main-menu, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] .wmd-dictionary-box, .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] .wmd-main-menu {
background-color: #EFEFEF;
box-shadow: 0.1em 0.1em 0.2em #222; }
.wmarkdown-web[data-gui-mode=light] .wmd-dictionary-box a[href], .wmarkdown-web[data-gui-mode=default][data-dark-mode=false] .wmd-dictionary-box a[href] {
background-color: rgba(0, 0, 0, 0.1); }
.wmarkdown-web[data-gui-mode=dark], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] {
background-color: #222;
color: #EFEFEF; }
.wmarkdown-web[data-gui-mode=dark] a[href], .wmarkdown-web[data-gui-mode=dark] [onclick], .wmarkdown-web[data-gui-mode=dark] [onmouseover], .wmarkdown-web[data-gui-mode=dark] [onmousedown], .wmarkdown-web[data-gui-mode=dark] button, .wmarkdown-web[data-gui-mode=dark] [type=button], .wmarkdown-web[data-gui-mode=dark] [type=reset], .wmarkdown-web[data-gui-mode=dark] [type=submit], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] a[href], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onclick], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onmouseover], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onmousedown], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] button, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=button], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=reset], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=submit] {
color: #309d66; }
.wmarkdown-web[data-gui-mode=dark] a[href]:hover, .wmarkdown-web[data-gui-mode=dark] [onclick]:hover, .wmarkdown-web[data-gui-mode=dark] [onmouseover]:hover, .wmarkdown-web[data-gui-mode=dark] [onmousedown]:hover, .wmarkdown-web[data-gui-mode=dark] button:hover, .wmarkdown-web[data-gui-mode=dark] [type=button]:hover, .wmarkdown-web[data-gui-mode=dark] [type=reset]:hover, .wmarkdown-web[data-gui-mode=dark] [type=submit]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] a[href]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onclick]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onmouseover]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onmousedown]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] button:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=button]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=reset]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=submit]:hover {
color: #9d3066; }
.wmarkdown-web[data-gui-mode=dark] [onmouseover], .wmarkdown-web[data-gui-mode=dark] [onmousedown], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onmouseover], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onmousedown] {
color: #90c6ab; }
.wmarkdown-web[data-gui-mode=dark] [onmouseover]:hover, .wmarkdown-web[data-gui-mode=dark] [onmousedown]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onmouseover]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [onmousedown]:hover {
color: #c690ab; }
.wmarkdown-web[data-gui-mode=dark] button, .wmarkdown-web[data-gui-mode=dark] [type=button], .wmarkdown-web[data-gui-mode=dark] [type=reset], .wmarkdown-web[data-gui-mode=dark] [type=submit], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] button, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=button], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=reset], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=submit] {
border-color: 0.1em solid #309d66;
box-shadow: 0em 0em 0.4em #309d66; }
.wmarkdown-web[data-gui-mode=dark] button:hover, .wmarkdown-web[data-gui-mode=dark] [type=button]:hover, .wmarkdown-web[data-gui-mode=dark] [type=reset]:hover, .wmarkdown-web[data-gui-mode=dark] [type=submit]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] button:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=button]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=reset]:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] [type=submit]:hover {
border-color: 0.1em solid #9d3066;
box-shadow: 0em 0em 0.4em #9d3066; }
.wmarkdown-web[data-gui-mode=dark] .wmd-dictionary-item, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] .wmd-dictionary-item {
color: #90c6ab; }
.wmarkdown-web[data-gui-mode=dark] .wmd-dictionary-item:hover, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] .wmd-dictionary-item:hover {
color: #c690ab; }
.wmarkdown-web[data-gui-mode=dark] header, .wmarkdown-web[data-gui-mode=dark] footer, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] header, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] footer {
box-shadow: 0em 0em 0.125em #222, 0em 0em 0.25em #222, 0em 0em 0.5em #222, 0em 0em 1em #222, 0em 0em 2em #222; }
.wmarkdown-web[data-gui-mode=dark] .wmd-dictionary-box, .wmarkdown-web[data-gui-mode=dark] .wmd-main-menu, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] .wmd-dictionary-box, .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] .wmd-main-menu {
background-color: #222;
box-shadow: 0.1em 0.1em 0.2em #EFEFEF; }
.wmarkdown-web[data-gui-mode=dark] .wmd-dictionary-box a[href], .wmarkdown-web[data-gui-mode=default][data-dark-mode=true] .wmd-dictionary-box a[href] {
background-color: rgba(255, 255, 255, 0.1); }
.wmarkdown-web a[href] { .wmarkdown-web a[href] {
text-decoration: none; text-decoration: none;
word-break: break-word; } word-break: break-word; }
@ -34,28 +88,9 @@ html, body {
.wmarkdown-web a[href]:hover, .wmarkdown-web [onclick]:hover, .wmarkdown-web [onmouseover]:hover, .wmarkdown-web [onmousedown]:hover, .wmarkdown-web button:hover, .wmarkdown-web [type=button]:hover, .wmarkdown-web [type=reset]:hover, .wmarkdown-web [type=submit]:hover { .wmarkdown-web a[href]:hover, .wmarkdown-web [onclick]:hover, .wmarkdown-web [onmouseover]:hover, .wmarkdown-web [onmousedown]:hover, .wmarkdown-web button:hover, .wmarkdown-web [type=button]:hover, .wmarkdown-web [type=reset]:hover, .wmarkdown-web [type=submit]:hover {
transition-duration: 0.2s; } transition-duration: 0.2s; }
.wmarkdown-web a[href], .wmarkdown-web [onclick], .wmarkdown-web [onmouseover], .wmarkdown-web [onmousedown], .wmarkdown-web button, .wmarkdown-web [type=button], .wmarkdown-web [type=reset], .wmarkdown-web [type=submit] { .wmarkdown-web a[href], .wmarkdown-web [onclick], .wmarkdown-web [onmouseover], .wmarkdown-web [onmousedown], .wmarkdown-web button, .wmarkdown-web [type=button], .wmarkdown-web [type=reset], .wmarkdown-web [type=submit] {
color: #008844;
transition-property: color; }
.wmarkdown-web a[href]:hover, .wmarkdown-web [onclick]:hover, .wmarkdown-web [onmouseover]:hover, .wmarkdown-web [onmousedown]:hover, .wmarkdown-web button:hover, .wmarkdown-web [type=button]:hover, .wmarkdown-web [type=reset]:hover, .wmarkdown-web [type=submit]:hover {
color: #880044; }
.wmarkdown-web [onmouseover], .wmarkdown-web [onmousedown] {
color: #115533;
transition-property: color; }
.wmarkdown-web [onmouseover]:hover, .wmarkdown-web [onmousedown]:hover {
color: #551133; }
.wmarkdown-web a[href], .wmarkdown-web [onclick] {
transition-property: color; } transition-property: color; }
.wmarkdown-web button, .wmarkdown-web [type=button], .wmarkdown-web [type=reset], .wmarkdown-web [type=submit] { .wmarkdown-web button, .wmarkdown-web [type=button], .wmarkdown-web [type=reset], .wmarkdown-web [type=submit] {
border-color: 0.1em solid #008844;
box-shadow: 0em 0em 0.4em #008844;
transition-property: color,border-color,box-shadow; } transition-property: color,border-color,box-shadow; }
.wmarkdown-web button:hover, .wmarkdown-web [type=button]:hover, .wmarkdown-web [type=reset]:hover, .wmarkdown-web [type=submit]:hover {
border-color: 0.1em solid #880044;
box-shadow: 0em 0em 0.4em #880044; }
.wmarkdown-web .wmd-dictionary-item {
color: #115533; }
.wmarkdown-web .wmd-dictionary-item:hover {
color: #551133; }
.wmarkdown-web h2 { .wmarkdown-web h2 {
font-size: 2.6em; } font-size: 2.6em; }
.wmarkdown-web h3 { .wmarkdown-web h3 {
@ -75,8 +110,7 @@ html, body {
.wmarkdown-web header, .wmarkdown-web footer { .wmarkdown-web header, .wmarkdown-web footer {
overflow: hidden; overflow: hidden;
display: flex; display: flex;
flex-direction: row; flex-direction: row; }
box-shadow: 0em 0em 0.125em #EFEFEF, 0em 0em 0.25em #EFEFEF, 0em 0em 0.5em #EFEFEF, 0em 0em 1em #EFEFEF, 0em 0em 2em #EFEFEF; }
.wmarkdown-web header > *, .wmarkdown-web footer > * { .wmarkdown-web header > *, .wmarkdown-web footer > * {
flex: auto; flex: auto;
align-self: center; } align-self: center; }

View File

@ -1,6 +1,6 @@
{ {
"version": 3, "version": 3,
"mappings": "AAAA,UAAS;EACL,MAAM,EAAG,IAAI;EACb,MAAM,EAAG,GAAG;EACZ,QAAQ,EAAG,MAAM;;AAQrB,cAAc;ECiBV,QAAQ,EAAG,QAAQ;EACnB,GAAG,EAAG,GAAG;EACT,IAAI,EAAG,GAAG;EACV,KAAK,EAAG,IAAI;EACZ,MAAM,EAAG,IAAI;EACb,QAAQ,EAAG,MAAM;EA4Hb,gBAAgB,ECzJV,OAAO;ED0Jb,KAAK,EC3JC,IAAI;EDgCd,kFAAqB;IAAC,WAAW,ECtBtB,QAAQ;EDuBnB;;;6CAG0B;IAAC,WAAW,ECxB7B,aAAa;EDyBtB,kCAAmB;IAAC,WAAW,ECvBtB,OAAO;EDwBhB,2FAA4B;IAAC,SAAS,EAAG,GAAG;EAE5C,sEAAuC;IAAC,OAAO,EAAG,IAAI;EAEtD,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S;IACL,OAAO,EAAG,IAAI;IACd,cAAc,EAAG,GAAG;IACpB,eAAe,EAAG,MAAM;IACxB,QAAQ,EAAG,QAAQ;IACnB,IAAI,EAAG,GAAG;IACV,MAAM,EAAG,GAAG;IACZ,KAAK,EAAG,IAAI;IACZ,UAAU,EAAG,MAAM;IACnB,OAAO,EAAG,SAAS;IACnB,WAAW,EAAG,GAAG;IACjB,SAAS,EAAG,KAAK;IACjB,UAAU,EAAG,UAAU;EAG3B,uBAAQ;IACJ,OAAO,EAAG,IAAI;IACd,cAAc,EAAG,GAAG;IACpB,UAAU,EAAG,MAAM;IACnB,MAAM,EAAG,QAAQ;IACjB,UAAU,EAAG,MAAM;IACnB,UAAU,EAAG,UAAU;IACvB,4BAAI;MACA,IAAI,EAAG,IAAI;MACX,UAAU,EAAG,MAAM;IAEvB,2BAAG;MAAC,cAAc,EAAG,MAAM;IAC3B,2BAAG;MACC,KAAK,EAAG,IAAI;MACZ,MAAM,EAAG,KAAK;MACd,MAAM,EAAG,SAAS;EDtP1B,mBAAI;IAAC,QAAQ,EAAG,IAAI;EACpB,iCAAgB;IAAC,SAAS,EAAG,IAAI",
"sources": ["WMarkDown.web.scss","../../../AnP/Public/scss/AnP.common.scss","../../../AnP/Public/scss/AnP.settings.scss"], "sources": ["WMarkDown.web.scss","../../../AnP/Public/scss/AnP.common.scss","../../../AnP/Public/scss/AnP.settings.scss"],
"names": [], "names": [],
"file": "WMarkDown.web.css" "file": "WMarkDown.web.css"

View File

@ -66,38 +66,38 @@ class WMarkDown:
def __init__(self) -> None: def __init__(self) -> None:
self.modules:dict[str, tuple[int, REPattern]] = { self.modules:dict[str, tuple[int, REPattern]] = {
"special_characters" : (self.SUBITEM, RECompile(r'\\([\(\{\[\*\\])')), "special_characters" : (WMarkDown.SUBITEM, RECompile(r'\\([\(\{\[\*\\])')),
"title" : (self.RAW, RECompile(r'^((#{1,6})[\t ]*([^\r\n]+)|(={1,6})[\t ]*([^\r\n=]+)={1,6})(\n|\r\n|\r){2,}', RE_MULTILINE)), "title" : (WMarkDown.RAW, RECompile(r'^((#{1,6})[\t ]*([^\r\n]+)|(={1,6})[\t ]*([^\r\n=]+)={1,6})(\n|\r\n|\r){2,}', RE_MULTILINE)),
"list" : (self.RAW, RECompile(r'^([\-\*#\+]+|([0-9]+|[a-z]+)\.)[^\r\n]*(\n|\r\n|\r)([\t ]*(([\-\*#\+]+|([0-9]+|[a-z]+)\.)[^\r\n]*)(\n|\r\n|\r)?)*', RE_IGNORE_CASE | RE_MULTILINE)), "list" : (WMarkDown.RAW, RECompile(r'^([\-\*#\+]+|([0-9]+|[a-z]+)\.)[^\r\n]*(\n|\r\n|\r)([\t ]*(([\-\*#\+]+|([0-9]+|[a-z]+)\.)[^\r\n]*)(\n|\r\n|\r)?)*', RE_IGNORE_CASE | RE_MULTILINE)),
"code_block" : (self.RAW, RECompile(r'^("{3}([^\r\n]*)(((?!"{3})(.|[\r\n]))+)"{3}|" " "([^\r\n]*)(((?!" " ")(.|[\r\n]))+)" " "|\'{3}([^\r\n]*)(((?!\'{3})(.|[\r\n]))+)\'{3}|\' \' \'([^\r\n]*)(((?!\' \' \')(.|[\r\n]))+)\' \' \'|`{3}([^\r\n]*)(((?!`{3})(.|[\r\n]))+)`{3}|` ` `([^\r\n]*)(((?!` ` `)(.|[\r\n]))+)` ` `)', RE_MULTILINE)), "code_block" : (WMarkDown.RAW, RECompile(r'^("{3}([^\r\n]*)(((?!"{3})(.|[\r\n]))+)"{3}|" " "([^\r\n]*)(((?!" " ")(.|[\r\n]))+)" " "|\'{3}([^\r\n]*)(((?!\'{3})(.|[\r\n]))+)\'{3}|\' \' \'([^\r\n]*)(((?!\' \' \')(.|[\r\n]))+)\' \' \'|`{3}([^\r\n]*)(((?!`{3})(.|[\r\n]))+)`{3}|` ` `([^\r\n]*)(((?!` ` `)(.|[\r\n]))+)` ` `)', RE_MULTILINE)),
"table" : (self.RAW, RECompile(r'^\[\|([^\r\n]*)[\r\n]+((^\|([^\]]([^\r\n"\']|"([^"\\\\]+|\\\\(.|[\r\n])|[\r\n]+)*"|\'([^\'\\\\]+|\\\\(.|[\r\n])|[\r\n]+)*\')*)?[\r\n]+)*)^\|\]', RE_MULTILINE)), "table" : (WMarkDown.RAW, RECompile(r'^\[\|([^\r\n]*)[\r\n]+((^\|([^\]]([^\r\n"\']|"([^"\\\\]+|\\\\(.|[\r\n])|[\r\n]+)*"|\'([^\'\\\\]+|\\\\(.|[\r\n])|[\r\n]+)*\')*)?[\r\n]+)*)^\|\]', RE_MULTILINE)),
"quote" : (self.RAW, RECompile(r'^>[ \t]*(\[\![\t ]*([^\] \t]+)([ \t]+([^\]]+))?\])?(([^\r\n]+(\r\n|[\r\n])?)*)', RE_MULTILINE)), "quote" : (WMarkDown.RAW, RECompile(r'^>[ \t]*(\[\![\t ]*([^\] \t]+)([ \t]+([^\]]+))?\])?(([^\r\n]+(\r\n|[\r\n])?)*)', RE_MULTILINE)),
"include" : (self.RAW, RECompile(r'^\[{2}include[ \t]+([^\]]+)\]{2}', RE_MULTILINE)), "include" : (WMarkDown.RAW, RECompile(r'^\[{2}include[ \t]+([^\]]+)\]{2}', RE_MULTILINE)),
"media" : (self.SUBITEM | self.LINKED, RECompile(r'\({2}\!(image|icon|video|audio|sound|picture)[ \t]+("(([^"]+|[\r\n]+))"|\'(([^\']+|[\r\n]+))\'|([^ \t\)]+))([ \t]*|[ \t]+("(([^\\\\"]+|\\\\.|[\r\n]+)*)"|\'(([^\\\\\']+|\\\\.|[\r\n]+)*)\'|([^\)]+)))\){2}', RE_IGNORE_CASE)), "media" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'\({2}\!(image|icon|video|audio|sound|picture)[ \t]+("(([^"]+|[\r\n]+))"|\'(([^\']+|[\r\n]+))\'|([^ \t\)]+))([ \t]*|[ \t]+("(([^\\\\"]+|\\\\.|[\r\n]+)*)"|\'(([^\\\\\']+|\\\\.|[\r\n]+)*)\'|([^\)]+)))\){2}', RE_IGNORE_CASE)),
"code_doc" : (self.RAW, RECompile(r'^\[{2}@(([^\]]+|\][^\]])+)\]{2}', RE_MULTILINE)), "code_doc" : (WMarkDown.RAW, RECompile(r'^\[{2}@(([^\]]+|\][^\]])+)\]{2}', RE_MULTILINE)),
"presentation_links" : (self.RAW, RECompile(r'^\[{2}"{3}(([^"]+|[\r\n]+|"{1,2}[^"])*)"{3}\]{2}', RE_MULTILINE)), "presentation_links" : (WMarkDown.RAW, RECompile(r'^\[{2}"{3}(([^"]+|[\r\n]+|"{1,2}[^"])*)"{3}\]{2}', RE_MULTILINE)),
"paragraph" : (self.RAW, RECompile(r'^(([^\r\n]+(\n|\r\n|\r)?)+)', RE_MULTILINE)), "paragraph" : (WMarkDown.RAW, RECompile(r'^(([^\r\n]+(\n|\r\n|\r)?)+)', RE_MULTILINE)),
# "bold_italic" : (self.SUBITEM | self.LINKED, RECompile(r'\*{3}(([^\*]+|\*{1,2}[^\*]|[\r\n]+|\\\*)*)\*{3}')), # "bold_italic" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'\*{3}(([^\*]+|\*{1,2}[^\*]|[\r\n]+|\\\*)*)\*{3}')),
# "bold_italic" : (self.SUBITEM | self.LINKED, RECompile(r'(?<!\\)\*{3}((?:\\\*|\*{1,2}[^\*]|[^*\r\n]|[\r\n])*)\*{3}')), # "bold_italic" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'(?<!\\)\*{3}((?:\\\*|\*{1,2}[^\*]|[^*\r\n]|[\r\n])*)\*{3}')),
# "bold" : (self.SUBITEM | self.LINKED, RECompile(r'\*{2}(([^\*]+|\*[^\*]|[\r\n]+|\\\*)*)\*{2}')), # "bold" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'\*{2}(([^\*]+|\*[^\*]|[\r\n]+|\\\*)*)\*{2}')),
"bold" : (self.SUBITEM | self.LINKED, RECompile(r'(?<!\\)\*{2}((?:\\\*|\*[^\*]|[^*\r\n]|[\r\n]|(?!\*{2}[^\*])\*)*)\*{2}')), "bold" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'(?<!\\)\*{2}((?:\\\*|\*[^\*]|[^*\r\n]|[\r\n]|(?!\*{2}[^\*])\*)*)\*{2}')),
# "italic" : (self.SUBITEM | self.LINKED, RECompile(r'(?<!\\)\*(([^\*]+|[\r\n]+|\\\*)*)\*')), # "italic" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'(?<!\\)\*(([^\*]+|[\r\n]+|\\\*)*)\*')),
"italic" : (self.SUBITEM | self.LINKED, RECompile(r'(?<!\\)\*((?:\\\*|[^*\r\n]|[\r\n]|\*{2})*)\*')), "italic" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'(?<!\\)\*((?:\\\*|[^*\r\n]|[\r\n]|\*{2})*)\*')),
"underline" : (self.SUBITEM | self.LINKED, RECompile(r'_{2}(([^_]+|_[^_])+)_{2}')), "underline" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'__(((?!__).)+)__')),
"strike" : (self.SUBITEM | self.LINKED, RECompile(r'~{2}(([^~]+|~[^~])+)~{2}')), "strike" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'~~(((?!~~).)+)~~')),
"code_item" : (self.SUBITEM | self.LINKED, RECompile(r'`{2}(([^`]+|`[^`])+)`{2}')), "code_item" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'``(((?!``).)+)``')),
"checkbox" : (self.SUBITEM | self.LINKED, RECompile(r'\[((\-)|(x)|( ))\]', RE_IGNORE_CASE)), "checkbox" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'\[((\-)|(x)|( ))\]', RE_IGNORE_CASE)),
"radio" : (self.SUBITEM | self.LINKED, RECompile(r'\(((\-)|(x)|( ))\)', RE_IGNORE_CASE)), "radio" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'\(((\-)|(x)|( ))\)', RE_IGNORE_CASE)),
"tick" : (self.SUBITEM | self.LINKED, RECompile(r'\{((w)|(v)|(x))\}', RE_IGNORE_CASE)), "tick" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'\{((w)|(v)|(x))\}', RE_IGNORE_CASE)),
"color_sample" : (self.SUBITEM | self.LINKED, RECompile(r'\[{2}((\#[a-f0-9]{3,8})|color[ \t]+([^\[\]\t\r\n]+))\]{2}', RE_IGNORE_CASE)), "color_sample" : (WMarkDown.SUBITEM | WMarkDown.LINKED, RECompile(r'\[{2}((\#[a-f0-9]{3,8})|color[ \t]+([^\[\]\t\r\n]+))\]{2}', RE_IGNORE_CASE)),
"exclude" : (self.SUBITEM, RECompile(r'\[{2}\!(([^\]]+|\][^\]]|[\r\n])*)\]{2}')), "exclude" : (WMarkDown.SUBITEM, RECompile(r'\[{2}\!(([^\]]+|\][^\]]|[\r\n])*)\]{2}')),
"link" : (self.SUBITEM, RECompile(r'(\[([^\[\]]+)\])?\((([^\(\) \t]+)[ \t]+("(([^\\\\"]+|\\\\.|[\r\n]+)*)"|\'(([^\\\\\']+|\\\\.|[\r\n]+)*)\'|([^\(\)]+)?))[ \t]*\)|\[(\+?[0-9 ]{5,22}|[^ \]]+)([\t ]+([^\]]*))?\]|([a-z0-9]{3,8}\:\/{2}[^ \(\[\)\]>]+|[a-z\.0-9_\-]+@[a-z\.0-9_\-]+\.[a-z0-9]+)', RE_IGNORE_CASE)) "link" : (WMarkDown.SUBITEM, RECompile(r'(\[([^\[\]]+)\])?\((([^\(\) \t]+)[ \t]+("(([^\\\\"]+|\\\\.|[\r\n]+)*)"|\'(([^\\\\\']+|\\\\.|[\r\n]+)*)\'|([^\(\)]+)?))[ \t]*\)|\[(\+?[0-9 ]{5,22}|[^ \]]+)([\t ]+([^\]]*))?\]|([a-z0-9]{3,8}\:\/{2}[^ \(\[\)\]>]+|[a-z\.0-9_\-]+@[a-z\.0-9_\-]+\.[a-z0-9]+)', RE_IGNORE_CASE))
} }
self.__ids_cache:tuple[str] = tuple() self.__ids_cache:tuple[str] = tuple()
def __id(self, string:str) -> str: def __id(self, string:str) -> str:
id:str = self.re_characters_no_id.sub(r'-', string).lower() id:str = WMarkDown.re_characters_no_id.sub(r'-', string).lower()
if id[0] == '-': if id[0] == '-':
id = id[1:] id = id[1:]
@ -121,14 +121,14 @@ class WMarkDown:
self.__ids_cache = tuple() self.__ids_cache = tuple()
def module_title(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_title(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
level:str = str(len(matches.group(2) or matches.group(4))) level:str = str(len(matches.group(2) or matches.group(4)))
content:str = (matches.group(3) or matches.group(5)).strip() content:str = (matches.group(3) or matches.group(5)).strip()
id:str = self.__id(content) id:str = self.__id(content)
return ('<h' + level + ' class="wmd-title" id="' + id + '" title="' + content + '">' + return ('<h' + level + ' class="wmd-title" id="' + id + '" title="' + content + '">' +
'<span>' + self.analyse(content, language, self.SUBITEM, path) + '</span>' + '<span>' + self.analyse(content, language, WMarkDown.SUBITEM, path) + '</span>' +
'<a href="#' + id + '" target="_blank">' + '<a href="#' + id + '" target="_blank">' +
'<span data-icon="link"></span>' + '<span data-icon="link"></span>' +
'</a>' + '</a>' +
@ -136,38 +136,38 @@ class WMarkDown:
return None return None
def module_paragraph(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_paragraph(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return '<p>' + self.analyse(matches.group(0).strip(), language, self.SUBITEM, path) + '</p>' return '<p>' + self.analyse(matches.group(0).strip(), language, WMarkDown.SUBITEM, path) + '</p>'
return None return None
def module_bold_italic(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_bold_italic(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return '<b><i>' + self.analyse(matches.group(1), language, self.SUBITEM, path) + '</i></b>' return '<b><i>' + self.analyse(matches.group(1), language, WMarkDown.SUBITEM, path) + '</i></b>'
return None return None
def module_bold(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_bold(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return '<b>' + self.analyse(matches.group(1), language, self.SUBITEM, path) + '</b>' return '<b>' + self.analyse(matches.group(1), language, WMarkDown.SUBITEM, path) + '</b>'
return None return None
def module_italic(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_italic(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return '<i>' + self.analyse(matches.group(1), language, self.SUBITEM, path) + '</i>' return '<i>' + self.analyse(matches.group(1), language, WMarkDown.SUBITEM, path) + '</i>'
return None return None
def module_strike(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_strike(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return '<del>' + self.analyse(matches.group(1), language, self.SUBITEM, path) + '</del>' return '<del>' + self.analyse(matches.group(1), language, WMarkDown.SUBITEM, path) + '</del>'
return None return None
def module_underline(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_underline(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return '<u>' + self.analyse(matches.group(1), language, self.SUBITEM, path) + '</u>' return '<u>' + self.analyse(matches.group(1), language, WMarkDown.SUBITEM, path) + '</u>'
return None return None
def module_code_item(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_code_item(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return '<code>' + self.analyse(matches.group(1), language, self.SUBITEM, path) + '</code>' return '<code>' + self.analyse(matches.group(1), language, WMarkDown.SUBITEM, path) + '</code>'
return None return None
@staticmethod @staticmethod
@ -185,20 +185,20 @@ class WMarkDown:
@classmethod @classmethod
def module_checkbox(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_checkbox(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return self.__check_html_module("checkbox", matches) return WMarkDown.__check_html_module("checkbox", matches)
return None return None
@classmethod @classmethod
def module_radio(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_radio(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return self.__check_html_module("radio", matches) return WMarkDown.__check_html_module("radio", matches)
return None return None
@classmethod @classmethod
def module_tick(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_tick(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return self.__check_html_module("tick", matches) return WMarkDown.__check_html_module("tick", matches)
return None return None
@staticmethod @staticmethod
@ -217,46 +217,48 @@ class WMarkDown:
def __list_start(self, unordered:bool, _type:str) -> str: def __list_start(self, unordered:bool, _type:str) -> str:
if not unordered: if not unordered:
_type = _type[:-1] _type = _type[:-1]
if self.re_integer.search(_type): if WMarkDown.re_integer.search(_type):
return ' start="' + _type + '"' return ' start="' + _type + '"'
return '' return ''
def module_list(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_list(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
html:str = '' html:str = ''
lines:list[str] = self.re_new_line.split(matches.group(0)) lines:list[str] = WMarkDown.re_new_line.split(matches.group(0))
levels:list[list[int, str, str|None]] = [[0, 'u', None]] levels:list[list[int, str, str|None]] = [[0, 'u', None]]
l:int = 0 l:int = 0
line:str line:str
last_mark:str|None = None last_mark:str|None = None
subtype:str|None = None
for line in lines: for line in lines:
matches:REMatch = self.re_list_line.search(line) matches:REMatch = WMarkDown.re_list_line.search(line)
if not matches: if not matches:
continue continue
separator_by_marks:str = len(matches.group(3) or "") separator_by_marks:int = len(matches.group(3) or "")
separator:str = separator_by_marks if separator_by_marks > 1 else len(matches.group(1)) separator:int = separator_by_marks if separator_by_marks > 1 else len(matches.group(1))
_type:str = matches.group(2) _type:str = matches.group(2)
key:str = matches.group(4) key:str = matches.group(4)
string:str = self.analyse(matches.group(5), language, self.SUBITEM, path).strip() string:str = self.analyse(matches.group(5), language, WMarkDown.SUBITEM, path).strip()
unordered:bool = _type and _type[-1] in ('-', '*', '+') unordered:bool = _type and _type[-1] in ('-', '*', '+')
subtype:str = _type[-1] if _type else None
subtype = _type[-1] if _type else None
if _type: if _type:
if levels[l][0] == separator: if levels[l][0] == separator:
levels[l][1] = 'u' if unordered else 'o' levels[l][1] = 'u' if unordered else 'o'
levels[l][2] = subtype levels[l][2] = subtype
html += ('</li>' if html else '<' + str(levels[l][1]) + 'l class="wmd-list"' + self.__list_start(unordered, _type) + self.__list_deployed(levels[l - 1], last_mark, l) + ( html += ('</li>' if html else '<' + str(levels[l][1]) + 'l class="wmd-list"' + WMarkDown.__list_start(unordered, _type) + WMarkDown.__list_deployed(levels[l - 1], last_mark, l) + (
' type="' + key[0] + '"' if key and not unordered and key[0] in ('a', 'A', 'i', 'I') else ' type="' + key[0] + '"' if key and not unordered and key[0] in ('a', 'A', 'i', 'I') else
'') + '>') + '<li>' + string '') + '>') + '<li>' + string
elif levels[l][0] < separator: elif levels[l][0] < separator:
l += 1 l += 1
levels += [[separator, "u" if unordered else "o", subtype]] levels += [[separator, "u" if unordered else "o", subtype]]
html += '<' + levels[l][1] + 'l class="wmd-list"' + self.__list_start(unordered, _type) + self.__list_deployed(levels[l - 1], last_mark, l) + ( html += '<' + levels[l][1] + 'l class="wmd-list"' + WMarkDown.__list_start(unordered, _type) + WMarkDown.__list_deployed(levels[l - 1], last_mark, l) + (
' type="' + key[0] + '"' if key and not unordered and key[0] in ('a', 'A', 'i', 'I') else ' type="' + key[0] + '"' if key and not unordered and key[0] in ('a', 'A', 'i', 'I') else
'') + '><li>' + string '') + '><li>' + string
else: else:
@ -295,16 +297,16 @@ class WMarkDown:
class_key:str class_key:str
attribute, classes_str, closer = matches.groups() attribute, classes_str, closer = matches.groups()
classes = self.re_white_spaces.split(classes_str) classes = WMarkDown.re_white_spaces.split(classes_str)
return attribute + classes_str + (' ' if classes_str else '') + " ".join([ return attribute + classes_str + (' ' if classes_str else '') + " ".join([
class_key for class_key in _class if class_key not in classes class_key for class_key in _class if class_key not in classes
]) + closer ]) + closer
return self.re_class_attribute.sub(callback, html) return WMarkDown.re_class_attribute.sub(callback, html)
def module_table(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_table(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
html:dict[str, str] = { html:dict[str, str] = {
"thead" : '', "thead" : '',
@ -316,7 +318,7 @@ class WMarkDown:
while True: while True:
line_matches:REMatch = self.re_table_line.search(data) line_matches:REMatch = WMarkDown.re_table_line.search(data)
if not line_matches: if not line_matches:
break break
@ -336,7 +338,7 @@ class WMarkDown:
while True: while True:
cell_matches:REMatch = self.re_table_item.search(line) cell_matches:REMatch = WMarkDown.re_table_item.search(line)
if not cell_matches: if not cell_matches:
break break
@ -347,8 +349,8 @@ class WMarkDown:
row += '<t' + cell_type + column_span + '>' + self.analyse( row += '<t' + cell_type + column_span + '>' + self.analyse(
content[1:-1] if content and content[0] + content[-1] in ("''", '""') else content, content[1:-1] if content and content[0] + content[-1] in ("''", '""') else content,
self.HTML, WMarkDown.HTML,
self.SUBITEM, WMarkDown.SUBITEM,
path path
) + '</t' + cell_type + '>' ) + '</t' + cell_type + '>'
@ -373,36 +375,36 @@ class WMarkDown:
@classmethod @classmethod
def module_exclude(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_exclude(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return '<span class="wmd-excluded">' + (matches.group(1) or "") + '</span>' return '<span class="wmd-excluded">' + (matches.group(1) or "") + '</span>'
return None return None
def module_link(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_link(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
raw_url:str = (matches.group(4) or matches.group(11) or matches.group(14) or "").strip() raw_url:str = (matches.group(4) or matches.group(11) or matches.group(14) or "").strip()
url = ( url = (
"tel:" + raw_url.replace(" ", "") if self.re_phone_number.search(raw_url) else "tel:" + raw_url.replace(" ", "") if WMarkDown.re_phone_number.search(raw_url) else
"mailto:" + raw_url if self.re_email_address.search(raw_url) else "mailto:" + raw_url if WMarkDown.re_email_address.search(raw_url) else
raw_url) raw_url)
text:str|None = matches.group(2) or matches.group(13) or raw_url text:str = matches.group(2) or matches.group(13) or raw_url
protocol_matches:REMatch|None = WMarkDown.re_protocol.search(url) protocol_matches:REMatch|None = WMarkDown.re_protocol.search(url)
return '<a href="' + url + '" target="_' + ("blank" if "://" in url else "self") + '" title="' + self.re_line_marks.sub(r'', ( return '<a href="' + url + '" target="_' + ("blank" if "://" in url else "self") + '" title="' + WMarkDown.re_line_marks.sub(r'', (
matches.group(6) or matches.group(8) or matches.group(10) or text matches.group(6) or matches.group(8) or matches.group(10) or text
).strip()) + '" data-protocol="' + ( ).strip()) + '" data-protocol="' + (
(protocol_matches.group(1) if protocol_matches else "http").lower() (protocol_matches.group(1) if protocol_matches else "http").lower()
) + '">' + self.analyse(text.strip(), language, self.SUBITEM | self.LINKED, path) + '</a>' ) + '">' + self.analyse(text.strip(), language, WMarkDown.SUBITEM | self.LINKED, path) + '</a>'
return None return None
def module_quote(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_quote(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
_type:str|None = matches.group(2) _type:str|None = matches.group(2)
type_text:str|None = matches.group(4) type_text:str|None = matches.group(4)
if _type in self.quote_special: if _type in WMarkDown.quote_special:
_type = self.quote_special[_type] _type = WMarkDown.quote_special[_type]
return ('<blockquote class="wmd-quote"' + (' data-quote-type="' + _type + '"' if _type else '') + '>' + return ('<blockquote class="wmd-quote"' + (' data-quote-type="' + _type + '"' if _type else '') + '>' +
(('<div class="quote-type">' + (( (('<div class="quote-type">' + ((
@ -412,13 +414,13 @@ class WMarkDown:
'<span data-icon="' + _type + '"></span>' + '<span data-icon="' + _type + '"></span>' +
('<span class="quote-type-name">' + type_text + '</span>' if type_text else '') ('<span class="quote-type-name">' + type_text + '</span>' if type_text else '')
)) + '</div>') if _type else '') + )) + '</div>') if _type else '') +
'<div class="text">' + self.analyse(matches.group(5), language, self.SUBITEM, path) + '</div>' + '<div class="text">' + self.analyse(matches.group(5), language, WMarkDown.SUBITEM, path) + '</div>' +
'</blockquote>') '</blockquote>')
return None return None
@classmethod @classmethod
def code_block_data(self, key:str, value:str|int, language:Optional[int] = HTML, path:Optional[str] = None) -> str: def code_block_data(self, key:str, value:str|int, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return ('<li data-i18n="' + key + '" data-i18n-without="true" title="' + key + '">' + return ('<li data-i18n="' + key + '" data-i18n-without="true" title="' + key + '">' +
'<span data-icon="' + key + '"></span>' + '<span data-icon="' + key + '"></span>' +
'<span data-i18n="' + key + '">' + key + '</span>' + '<span data-i18n="' + key + '">' + key + '</span>' +
@ -429,11 +431,11 @@ class WMarkDown:
@classmethod @classmethod
def filter_html_special_characters(self, string:str) -> str: def filter_html_special_characters(self, string:str) -> str:
l:int = len(self.html_special_characters) l:int = len(WMarkDown.html_special_characters)
_:int _:int
index:list[int] = [-1 for _ in range(l)] index:list[int] = [-1 for _ in range(l)]
response:str = '' response:str = ''
characters:tuple[str] = tuple(self.html_special_characters.keys()) characters:tuple[str] = tuple(WMarkDown.html_special_characters.keys())
while True: while True:
@ -461,7 +463,7 @@ class WMarkDown:
length:int = index[i] length:int = index[i]
response += string[:length] + '&' + self.html_special_characters[characters[i]] + ';' response += string[:length] + '&' + WMarkDown.html_special_characters[characters[i]] + ';'
string = string[length + 1:] string = string[length + 1:]
for j in range(l): for j in range(l):
@ -472,7 +474,7 @@ class WMarkDown:
@classmethod @classmethod
def module_code_block(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_code_block(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
_type:str _type:str
content:str content:str
@ -491,26 +493,26 @@ class WMarkDown:
if _type: if _type:
lines:list[str] = self.re_new_line.split(content)[2:] lines:list[str] = WMarkDown.re_new_line.split(content)[2:]
_:str _:str
return ('<div class="wmd-code-block" data-type="' + _type + '" data-processed="false">' return ('<div class="wmd-code-block" data-type="' + _type + '" data-processed="false">'
'<ul class="data">' + '<ul class="data">' +
'<li><span data-icon="' + _type + '"></span></li>' + '<li><span data-icon="' + _type + '"></span></li>' +
self.code_block_data("type", _type, language) + WMarkDown.code_block_data("type", _type, language) +
self.code_block_data("characters", len(content), language) + WMarkDown.code_block_data("characters", len(content), language) +
self.code_block_data("lines", len(lines), language) + WMarkDown.code_block_data("lines", len(lines), language) +
'</ul>' + '</ul>' +
'<div class="code">' + '<div class="code">' +
'<ol class="lines">' + ''.join(['<li></li>' for _ in lines]) + '</ol>' + '<ol class="lines">' + ''.join(['<li></li>' for _ in lines]) + '</ol>' +
'<pre class="content">' + self.filter_html_special_characters(content) + '</pre>' + '<pre class="content">' + WMarkDown.filter_html_special_characters(content) + '</pre>' +
'</div>' + '</div>' +
'</div>') '</div>')
return 'UNKNOWN_BLOCK' return 'UNKNOWN_BLOCK'
return None return None
def module_special_characters(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_special_characters(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
return matches.group(1) return matches.group(1)
return None return None
@ -525,21 +527,21 @@ class WMarkDown:
return None return None
def module_include(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_include(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
relative_path:str = matches.group(1) relative_path:str = matches.group(1)
new_path:str = path + relative_path new_path:str = path + relative_path
extension:str = self.re_extension.search(new_path).groups()[1:] extension:str = WMarkDown.re_extension.search(new_path).groups()[1:]
content:str|None = self.load_file(new_path) content:str|None = WMarkDown.load_file(new_path)
directory:str = directory_name(new_path) + "/" directory:str = directory_name(new_path) + "/"
results:str|None = ( results:str|None = (
None if content == None else None if content == None else
self.process(content, language, directory)[0] if ".".join(extension) == "w.md" else self.process(content, language, directory)[0] if ".".join(extension) == "w.md" else
self.analyse(content, language, self.RAW, directory) if extension[-1] == "md" else self.analyse(content, language, WMarkDown.RAW, directory) if extension[-1] == "md" else
content) content)
return ('<section data-path="' + relative_path + '" data-include="' + ("false" if results == None else "true") + '">' + return ('<section data-path="' + relative_path + '" data-include="' + ("false" if results == None else "true") + '">' +
'<div class="link"><a href="' + relative_path + '" target="_self" title="' + relative_path + '">' + relative_path + '</a></div>' + '<div class="link"><a href="' + relative_path + '" target="_self" title="' + relative_path + '">' + relative_path + '</a></div>' +
(results or "") + (results or "") +
'</section>') '</section>')
return None return None
@ -559,14 +561,14 @@ class WMarkDown:
'</span>') '</span>')
def module_media(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_media(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
_type:str = matches.group(1).lower() _type:str = matches.group(1).lower()
links:list[str] = self.re_white_spaces.split(matches.group(3) or matches.group(5) or matches.group(7)) links:list[str] = WMarkDown.re_white_spaces.split(matches.group(3) or matches.group(5) or matches.group(7))
text:str = (matches.group(10) or matches.group(12) or matches.group(14) or '').strip() text:str = (matches.group(10) or matches.group(12) or matches.group(14) or '').strip()
if _type in ("image", "picture", "icon"): if _type in ("image", "picture", "icon"):
return self.build_html_image(links, _type, text) return WMarkDown.build_html_image(links, _type, text)
if _type in ("video",): if _type in ("video",):
@ -609,7 +611,7 @@ class WMarkDown:
start, end = matches.span() start, end = matches.span()
string = string[:start] + self.item_mark[0] + str(len(fragments)) + self.item_mark[1] + string[end:] string = string[:start] + WMarkDown.item_mark[0] + str(len(fragments)) + WMarkDown.item_mark[1] + string[end:]
fragments += [matches.group(0)] fragments += [matches.group(0)]
return string return string
@ -619,7 +621,7 @@ class WMarkDown:
while True: while True:
matches:REMatch = self.item_mark[2].search(string) matches:REMatch = WMarkDown.item_mark[2].search(string)
if not matches: if not matches:
break break
@ -636,16 +638,16 @@ class WMarkDown:
@classmethod @classmethod
def __doc_typed_format(self, typed:str) -> str: def __doc_typed_format(self, typed:str) -> str:
return self.filter_html_special_characters(typed.replace(' ', "").replace(',', ", ")) return WMarkDown.filter_html_special_characters(typed.replace(' ', "").replace(',', ", "))
def module_code_doc(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_code_doc(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
# print(matches.groups()) # print(matches.groups())
data:str = matches.group(1).strip() data:str = matches.group(1).strip()
base:REMatch = self.re_code_doc.search(data) base:REMatch = WMarkDown.re_code_doc.search(data)
return_type:str = self.__doc_typed_format(base.group(2) or "void") return_type:str = WMarkDown.__doc_typed_format(base.group(2) or "void")
access:str = base.group(3) or "public" access:str = base.group(3) or "public"
name_space:str|None = base.group(5) name_space:str|None = base.group(5)
environment:str = base.group(6) or "global" environment:str = base.group(6) or "global"
@ -680,10 +682,10 @@ class WMarkDown:
if parameters: if parameters:
while True: while True:
matches = self.re_code_doc_subarguments.search(parameters) matches = WMarkDown.re_code_doc_subarguments.search(parameters)
if matches: if matches:
parameters = self.mark_replace(parameters, matches, fragments) parameters = WMarkDown.mark_replace(parameters, matches, fragments)
else: else:
break break
else: else:
@ -691,16 +693,16 @@ class WMarkDown:
for parameter in parameters.split(","): for parameter in parameters.split(","):
matches = self.re_code_doc_arguments.search(parameter.strip()) matches = WMarkDown.re_code_doc_arguments.search(parameter.strip())
if matches: if matches:
scopes:str = matches.group(1) or "" scopes:str = matches.group(1) or ""
required:bool = "!" in scopes required:bool = "!" in scopes
nullish:bool = "?" in scopes nullish:bool = "?" in scopes
typed:str = self.__doc_typed_format(self.restore_marks(matches.group(2), fragments)) typed:str = WMarkDown.__doc_typed_format(WMarkDown.restore_marks(matches.group(2), fragments))
name:str = matches.group(3).strip() name:str = matches.group(3).strip()
default_value:str = self.filter_html_special_characters(self.restore_marks((matches.group(5) or "").strip(), fragments)) default_value:str = WMarkDown.filter_html_special_characters(WMarkDown.restore_marks((matches.group(5) or "").strip(), fragments))
arguments += ('<span class="argument">' + arguments += ('<span class="argument">' +
('<span class="required" data-i18n="required" title="Required">Required</span>' if required else '') + ('<span class="required" data-i18n="required" title="Required">Required</span>' if required else '') +
@ -739,7 +741,7 @@ class WMarkDown:
return None return None
def module_color_sample(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_color_sample(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
color:str = matches.group(2) or matches.group(3) color:str = matches.group(2) or matches.group(3)
@ -750,7 +752,7 @@ class WMarkDown:
return None return None
def module_presentation_links(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None: def module_presentation_links(self, matches:REMatch, language:Optional[int] = HTML, path:Optional[str] = None) -> str|None:
if language & self.HTML: if language & WMarkDown.HTML:
items:list = [] items:list = []
i:int = -1 i:int = -1
@ -760,9 +762,9 @@ class WMarkDown:
html_avatars:str = '' html_avatars:str = ''
html_list:str = '' html_list:str = ''
for line in self.re_new_lines.split(matches.group(1)): for line in WMarkDown.re_new_lines.split(matches.group(1)):
has_spaces:bool = self.re_start_with_white_spaces.search(line) != None has_spaces:bool = WMarkDown.re_start_with_white_spaces.search(line) != None
data:str = line.strip() data:str = line.strip()
if not data: if not data:
@ -780,7 +782,6 @@ class WMarkDown:
else: else:
i += 1 i += 1
items += [[line.strip(), [], []]] items += [[line.strip(), [], []]]
continue
for i, (title, avatars, links) in enumerate(items): for i, (title, avatars, links) in enumerate(items):
@ -789,11 +790,11 @@ class WMarkDown:
html_avatars += ('<li title="' + title + '" data-i="' + str(i) + '" data-links="' + str(len(links)) + '">' + html_avatars += ('<li title="' + title + '" data-i="' + str(i) + '" data-links="' + str(len(links)) + '">' +
('<a href="' + links[0] + '" target="_blank">' + ('<a href="' + links[0] + '" target="_blank">' +
self.build_html_image(avatars) + WMarkDown.build_html_image(avatars) +
'</a>' if len(links) else self.build_html_image(avatars)) + '</a>' if len(links) else WMarkDown.build_html_image(avatars)) +
''.join(['<a href="' + link + '" target="_blank" class="wmd-favicon" style="background-image:' + ( ''.join(['<a href="' + link + '" target="_blank" class="wmd-favicon" style="background-image:' + (
'url(\'' + self.re_domain.search(link).group(0) + '/favicon.ico\')' + 'url(\'' + WMarkDown.re_domain.search(link).group(0) + '/favicon.ico\')' +
(',url(\'' + self.re_domain.search(link.replace(".k3y.pw/", ".local/")).group(0) + '/favicon.ico\')' if ".k3y.pw/" in link else '') (',url(\'' + WMarkDown.re_domain.search(link.replace(".k3y.pw/", ".local/")).group(0) + '/favicon.ico\')' if ".k3y.pw/" in link else '')
) + ';"></a>' for link in links]) + ) + ';"></a>' for link in links]) +
'</li>') '</li>')
html_list += ('<li class="name">' + html_list += ('<li class="name">' +
@ -813,7 +814,7 @@ class WMarkDown:
def remove_default_tabulations(self, data:str) -> str: def remove_default_tabulations(self, data:str) -> str:
line:str line:str
lines:list[str] = self.re_new_lines.split(data) lines:list[str] = WMarkDown.re_new_lines.split(data)
spaces:int = len(data) spaces:int = len(data)
def callback(matches:REMatch): def callback(matches:REMatch):
@ -823,16 +824,16 @@ class WMarkDown:
if not line: if not line:
continue continue
white_spaces:int = len(self.re_started_white_spaces.search(line).group(0)) white_spaces:int = len(WMarkDown.re_started_white_spaces.search(line).group(0))
if white_spaces < spaces: if white_spaces < spaces:
spaces = white_spaces spaces = white_spaces
return self.re_lines.sub(callback, data) return WMarkDown.re_lines.sub(callback, data)
def __build(self, data:str, language:int, path:str|None) -> str: def __build(self, data:str, language:int, path:str|None) -> str:
return ('<div class="wmd wmarkdown" data-dictionary-processed="false" data-menu-processed="false">' + return ('<div class="wmd wmarkdown" data-dictionary-processed="false" data-menu-processed="false">' +
self.analyse(self.remove_default_tabulations(data), language, self.RAW, path) + self.analyse(WMarkDown.remove_default_tabulations(data), language, WMarkDown.RAW, path) +
'<div class="wmd-process-and-loaded"></div>' + '<div class="wmd-process-and-loaded"></div>' +
'</div>') '</div>')
@ -840,7 +841,7 @@ class WMarkDown:
results:str = "" results:str = ""
variables:dict[str, str] = {} variables:dict[str, str] = {}
options:REMatch = self.re_options.search(data) options:REMatch = WMarkDown.re_options.search(data)
if options: if options:
@ -852,7 +853,7 @@ class WMarkDown:
while True: while True:
option:REMatch = self.re_option.search(options_data) option:REMatch = WMarkDown.re_option.search(options_data)
if not option: if not option:
break break
@ -864,7 +865,7 @@ class WMarkDown:
while True: while True:
matches:REMatch = self.re_block_mark.search(data) matches:REMatch = WMarkDown.re_block_mark.search(data)
if not matches: if not matches:
results += data results += data
@ -873,7 +874,7 @@ class WMarkDown:
open_from:int open_from:int
open_to:int open_to:int
mark:str = matches.group(1) mark:str = matches.group(1)
re_close:REPattern = RECompile(r'^\s*' + mark, RE_MULTILINE) if mark else self.re_block_html re_close:REPattern = RECompile(r'^\s*' + mark, RE_MULTILINE) if mark else WMarkDown.re_block_html
open_from, open_to = matches.span() open_from, open_to = matches.span()
results += data[:open_from] results += data[:open_from]
@ -900,9 +901,8 @@ class WMarkDown:
def analyse(self, data:str, language:Optional[int] = HTML, mode:Optional[int] = RAW, path:Optional[str] = None) -> str: def analyse(self, data:str, language:Optional[int] = HTML, mode:Optional[int] = RAW, path:Optional[str] = None) -> str:
response:str = "" response:str = ""
pattern:REPattern
item_mode:int item_mode:int
items:dict[str, list[bool, int, int, REMatch]] = {key : [True, -1, -1, None] for key, (item_mode, pattern) in self.modules.items() if mode == self.RAW or mode | item_mode == item_mode} items:dict[str, list[bool, int, int, REMatch]] = {key : [True, -1, -1, None] for key, (item_mode, pattern) in self.modules.items() if mode == WMarkDown.RAW or mode | item_mode == item_mode}
# j:int = 0 # j:int = 0
# m:int = 10 # m:int = 10
@ -920,7 +920,7 @@ class WMarkDown:
if not exists: if not exists:
continue continue
pattern = self.modules[key][1] pattern:REPattern = self.modules[key][1]
if _from < 0: if _from < 0:
items[key][3] = matches = pattern.search(data) items[key][3] = matches = pattern.search(data)
@ -955,4 +955,4 @@ class WMarkDown:
return response return response
def to_html(self, data:str, path:Optional[str] = None) -> str: def to_html(self, data:str, path:Optional[str] = None) -> str:
return self.analyse(data, self.HTML, self.RAW, path) return self.analyse(data, WMarkDown.HTML, WMarkDown.RAW, path)

View File

@ -1 +1 @@
0.0.2.0 0.0.2.1