FPM, Chanson de Roland (1869) F. Michel, aspects techniques : Différence entre versions

De Wicri Chanson de Roland
 
(8 révisions intermédiaires par 3 utilisateurs non affichées)
Ligne 1 : Ligne 1 :
==Outils d'aide à la ...==
+
{{FPM Roland, header}}
Fichier testFPM_41.xml
+
==Outils d'aide à la mise en ligne==
 +
 
 +
Un programme [[Lex (logiciel)|lex]] est utilisé pour transformer le fichier xml en brouillon de lignes wiki.
 +
 
 +
;Fichier testFPM_41.xml:
 
<source lang="xml">
 
<source lang="xml">
 
<?xml version="1.0" encoding="UTF-8"?>
 
<?xml version="1.0" encoding="UTF-8"?>
Ligne 15 : Ligne 19 :
 
</text>
 
</text>
 
</source>
 
</source>
 +
;Résultat souhaité:
 +
La page [[FPM, Chanson de Roland (1869) F. Michel, page 7]] contient un texte wiki dont un extrait du contenu est :
 +
<source lang="html">
 +
{{FPM, CR, début texte}}
 +
{{FPM, CR, vers  |Si receverat la nostre lei plus salve* ;}}
 +
{{FPM, CR, aster |propice au salut.}}
 +
{{FPM, CR, vers  |Chrestiens ert, de mei tendrat ses marches*, }}
 +
{{FPM, CR, aster |Sera, de moi tiendra ses frontières.}}
 +
</source>
  
Programme lex (testFPM.lex)
+
;Programme lex: (testFPM.lex)
  
 
<source lang="c">
 
<source lang="c">
 +
%START JUMP
 +
%START WORD
 +
%START PRINT
 +
%START NUM
 +
int top, top1, flag;
 
%%
 
%%
 
<JUMP>.          ;
 
<JUMP>.          ;
 
<JUMP>\n        ;
 
<JUMP>\n        ;
 
<JUMP>"<word"    BEGIN WORD;
 
<JUMP>"<word"    BEGIN WORD;
 +
<WORD>">"[A-Z][a-z]  {if (flag==1) printf("{{FPM, CR, vers  |"); printf("%s", yytext+1); BEGIN PRINT;}
 +
<WORD>">*"          {if (flag==1) printf("{{FPM, CR, aster  |"); else printf("%s", yytext+1); BEGIN PRINT;}
 
<WORD>">"        BEGIN PRINT;
 
<WORD>">"        BEGIN PRINT;
 
<WORD>.          ;
 
<WORD>.          ;
<WORD>"top="    {printf(" "); BEGIN NUM;}
+
<WORD>"top="    BEGIN NUM;
<NUM>[0-9]+      {top=atoi(yytext); if(top1!=top){top1=top; putchar('\n');} BEGIN WORD;}   
+
<NUM>[0-9]+      {top=atoi(yytext);  
 +
                  if(top1!=top)
 +
                    {top1=top; printf("}}\n"); flag=1;}  
 +
                  else {printf (" "); flag=0;}
 +
                  BEGIN WORD;}   
 
<NUM>.          ;
 
<NUM>.          ;
 
<PRINT>"</"      BEGIN JUMP;
 
<PRINT>"</"      BEGIN JUMP;
Ligne 45 : Ligne 69 :
 
gcc lex.yy.c -ll -o testFPM
 
gcc lex.yy.c -ll -o testFPM
 
./testFPM < testFPM_41.xml
 
./testFPM < testFPM_41.xml
 +
</source>
 +
 +
Résultat :
 +
<source lang="html">
 +
}}
 +
183.)}}
 +
DE ROLAND.}}
 +
{{FPM, CR, vers  |Si receverat la nostre lei plus salve* ;}}
 +
 
</source>
 
</source>

Version actuelle datée du 21 juillet 2023 à 15:12

Outils d'aide à la mise en ligne

Un programme lex est utilisé pour transformer le fichier xml en brouillon de lignes wiki.

Fichier testFPM_41.xml
<?xml version="1.0" encoding="UTF-8"?>
<text nbWords="410">
	<word left="111" top="149" height="41" width="61" rate="90" language="" endline="false">183.)</word>
	<word left="448" top="142" height="32" width="55" rate="100" language="French" endline="false">DE</word>
	<word left="529" top="142" height="32" width="187" rate="100" language="French" endline="false">ROLAND.</word>
	<word left="54" top="223" height="37" width="26" rate="100" language="French" endline="false">Si</word>
	<word left="94" top="223" height="37" width="137" rate="100" language="French" endline="false">receverat</word>
	<word left="243" top="223" height="37" width="24" rate="100" language="French" endline="false">la</word>
	<word left="279" top="223" height="37" width="92" rate="100" language="French" endline="false">nostre</word>
...
	<word left="935" top="1962" height="30" width="213" rate="97" language="French" endline="false">celavousmande,</word>
</text>
Résultat souhaité

La page FPM, Chanson de Roland (1869) F. Michel, page 7 contient un texte wiki dont un extrait du contenu est :

{{FPM, CR, début texte}}
{{FPM, CR, vers  |Si receverat la nostre lei plus salve* ;}}
{{FPM, CR, aster |propice au salut.}}
{{FPM, CR, vers  |Chrestiens ert, de mei tendrat ses marches*, }}
{{FPM, CR, aster |Sera, de moi tiendra ses frontières.}}
Programme lex
(testFPM.lex)
%START JUMP
%START WORD
%START PRINT
%START NUM
 int top, top1, flag;
%%
<JUMP>.          ;
<JUMP>\n         ;
<JUMP>"<word"    BEGIN WORD;
<WORD>">"[A-Z][a-z]  {if (flag==1) printf("{{FPM, CR, vers  |"); printf("%s", yytext+1); BEGIN PRINT;}
<WORD>">*"           {if (flag==1) printf("{{FPM, CR, aster  |"); else printf("%s", yytext+1); BEGIN PRINT;}
<WORD>">"        BEGIN PRINT;
<WORD>.          ;
<WORD>"top="     BEGIN NUM;
<NUM>[0-9]+      {top=atoi(yytext); 
                  if(top1!=top)
                     {top1=top; printf("}}\n"); flag=1;} 
                  else {printf (" "); flag=0;}
                  BEGIN WORD;}  
<NUM>.           ;
<PRINT>"</"      BEGIN JUMP;
<PRINT>.         ECHO;
%%
main()
{
  top1=0;
  BEGIN JUMP;
   yylex();
}

Mise en oeuvre :

lex testFPM.lex
gcc lex.yy.c -ll -o testFPM
./testFPM < testFPM_41.xml

Résultat :

}}
183.)}}
DE ROLAND.}}
{{FPM, CR, vers  |Si receverat la nostre lei plus salve* ;}}