Advertisement
TSnake41

Code de Hugo7 simplifié

Sep 21st, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.00 KB | None | 0 0
  1. @Echo off
  2. :: Code réduit par Astie Teddy (TSnake41)
  3.  
  4. REM Fichier yml
  5. set fichier_yaml=fichier.yml
  6.  
  7. setlocal ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
  8.    
  9. REM Reset de output.txt
  10. echo.>output.txt
  11.  
  12. REM %%L comme ligne.
  13. for /f "eol=# tokens=*" %%L in (%fichier_yaml%) do (
  14.     :: On récupère la ligne avec %%L.
  15.     set ligne=%%L
  16.     :: Le préfixe est le premier caractère.
  17.     set prefix=!ligne:~0,1!
  18.     :: Le corps va de aprés le ':' jusqu'a la fin.
  19.     set body=!ligne:~4!
  20.     :: Si le corps contient rien, alors le définir en "null"
  21.     if "!body!"=="" set body=null
  22.    
  23.     :: Titre de catégorie
  24.     if "!prefix!"=="c" echo !body!>>output.txt
  25.     :: Sous-Titre
  26.     if "!prefix!"=="s" echo ^| !body!>>output.txt
  27.     :: Texte
  28.     if "!prefix!"=="t" echo ^| ^| !body!>>output.txt
  29.     :: Caractère de saut de ligne, on vérifie ensuite si il y en a 3.
  30.     if "!prefix!"=="@" if "!ligne:~0,3!"=="@@@" echo.>>output.txt
  31. )
  32.  
  33. endlocal
  34. :: On ouvre le fichier avec notepad car il y a la limitation OEM-850 sur cmd.
  35. notepad output.txt
  36. pause
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement