Zurück zur Übersichtsseite - TUSCRIPT Workshops
- kollatz
…
<section> <h1>Überschrift1</h1> <p>eins</p> <p>eins</p> <h2>Überschrift2</h2> <p>zwei</p> <p>zwei</p> <h3>Überschrift3</h3> <p>drei</p> <h4>Überschrift4</h4> <p>vier</p> <h5>Überschrift5</h5> <p>fünf</p> <h3>Überschrift3</h3> <p>drei</p> <h2>Überschrift2</h2> <p>zwei</p> <p>zwei</p> </section>
<div><head>Überschrift1</head> <p>eins</p> <p>eins</p> <div><head>Überschrift2</head> <p>zwei</p> <p>zwei</p> <div><head>Überschrift3</head> <p>drei</p> <div><head>Überschrift4</head> <p>vier</p> <div><head>Überschrift5</head> <p>fünf</p> </div></div></div><div><head>Überschrift3</head> <p>drei</p> </div></div><div><head>Überschrift2</head> <p>zwei</p> <p>zwei</p> </div></div></div>
$$ MODE TUSCRIPT,{} ERROR/STOP OPEN ("alt",READ,-std-) ERROR/STOP CREATE ("neu",seq-e,-std-) STACK div CREATE ACCESS q: READ/STREAM "alt" s.z/u,a+txt+e,typ,stack ACCESS z: WRITE/ERASE/STREAM/PROGRAM "neu" s.z/u,a+txt+e LOOP/999999999 READ/EXIT q IF (a.ma.":<h{\0}>:") THEN level=STRINGS (a,":{\0}:") STACK div SIZE size IF (size!=0) THEN a="<div><head>" LOOP STACK div peek/EXIT peek IF (peek>=level) THEN STACK div pop/EXIT size a=CONCAT ("</div>",a) ELSE EXIT ENDIF ENDLOOP ELSE a="<div><head>" ENDIF STACK div push level ENDIF IF (e.ma.":</h{\0}>:") e="</head>" IF (a.sw."<section") THEN a=SET_ATTRIBUTE ("<div>","type","section") STACK div CLEAR ENDIF IF (e.sw."</section>") THEN e="</div>" STACK div SIZE size IF (size!=0) THEN STACK div PEEK peek LOOP n=1,size e=APPEND (e,"","</div>") ENDLOOP ENDIF ENDIF WRITE/ADJUST z ENDLOOP ENDACCESS/PRINT q ENDACCESS/PRINT z