html datei mit batch datei erstellen?

2 Antworten

Vom Fragesteller als hilfreich ausgezeichnet

Der steinige Weg alle Sonderzeichen maskieren: (viel Spaß😉)

@echo off
echo ^<!DOCTYPE html^> >"my.html"
echo ^<html^> >>"my.html"
echo ^<body^> >>"my.html"
echo ^<p^>Hallo Welt.^</p^> >>"my.html"
echo ^</body^> >>"my.html"
echo ^</html^> >>"my.html"
start "" "my.html"

Hybrid:

 <!-- : diese Zeile nicht  löschen
  rem der Batchcode  verbleibt als Kommentar im Html
@echo off
copy "%~f0" "%~dpn0.html"
start "" "%~dpn0.html"

pause
exit /b
und diese auch nicht -->
<!DOCTYPE html>
<html>
<body>

<p>I am normal</p>
<p style="color:red;">I am red</p>
<p style="color:blue;">I am blue</p>
<p style="font-size:50px;">I am big</p>

</body>
</html>

Mehrere Seiten in einer Batch:

@echo off
chcp 65001 >nul & rem Umlaute anzeigen
 
  rem im Fenster anzeigen
call :DrawCode "TicktackDemo"
  rem in Datei schreiben
call :DrawCode "TicktackDemo" >"TicktackDemo.html"
start "" "TicktackDemo.html"
timeout 10
  rem zweite  Seite  in Datei shreiben
call :DrawCode "Matrixrain" >"Matrixrain.html"
start "" "Matrixrain.html"
pause
exit /b


:DrawCode
  rem finde die Anfangszeile des zu schreibenden Fremdcodes in dieser Batch
set "toSkip="
set "beginMark=::::Begin %~1.code"
for /f "skip=2 tokens=1 delims=[]" %%a in ('find /n "%beginMark%" "%~f0"') do (set "toSkip=%%a")
if not defined toSkip (
    echo "%beginMark%" nicht gefunden!
    exit /b 1
)
for /f "usebackq skip=%toSkip% tokens=* delims=" %%t in ("%~f0") do (
    if /i "%%~t"=="::::End.code::::" exit /b 0
    echo:%%t
    )
)
exit /b


::::Begin TicktackDemo.code
<script>
function countDown(seconds) {
    var timer = seconds-1;
    document.getElementById('time').innerHTML = seconds;
    interval=setInterval(function () {
              // schreibe timer in element mit der ID "time"
        document.getElementById('time').innerHTML = timer; 
            //variable timer solange um 1 reduzieren bis 0 
        if (--timer < 0) {clearInterval(interval); //wenn timer <0 interval stoppen
        }
    }, 1000); // tue das alle 1000 Millisekunden
};
function tt() {
    var arrTT=['Tick','Tack'];
    var flipflop = 0;
    document.getElementById('blub').innerHTML = arrTT[flipflop];
    setInterval(function () {
             //XOR 1
        flipflop ^= 1;
        document.getElementById('blub').innerHTML = arrTT[flipflop]; 
    }, 500);
};
window.onload = function () {
    countDown(3605);
    tt();
};
</script>
<body>
    <div id="time"></div>
    <br><br>
    <div id="blub"></div>  tickt  in alle  ewigkeit ...
</body>         
::::End.code::::


::::Begin Matrixrain.code
<html>
    <head>
        <style>


            html,body { /* Page settings */
                width: 100%;
                height: 100%;
                margin: 0;
                padding: 0;
            }


            body {
                background: red; /*funy*/
            }


            canvas {display:block;}
            
            #overlay { /*maincontainer for content*/
                position: absolute;
                top: 0px;
                left: 0px;
                width: 100%;
                height: 100%;
                color : White;
                z-index : 1;
            }


            #Text {
                margin: 30px;
                padding: 10px;
                border: 1px solid magenta;
            }
            h1 {
                Font-Size: 72px;
            }


            p {
                Font-Size: 20px;
                margin-top:1em; 
            }


        </style>
    </head>


    <body onresize="resize()">
        <canvas id="c"></canvas>
        <div id = "overlay">
            <img src="https://img2.dreamies.de/img/901/b/5uzu36uou6w.gif" alt="Erzesel Target" >
            <div id = "Text">
                <h1>Veggie Ipsum</h1>
                <p>Veggies es bonus vobis, proinde vos postulo essum magis kohlrabi welsh onion daikon amaranth tatsoi tomatillo melon azuki bean garlic.</p>
                <p>Turnip greens yarrow ricebean rutabaga endive cauliflower sea lettuce kohlrabi amaranth water spinach avocado daikon napa cabbage asparagus winter purslane kale. Celery potato scallion desert raisin horseradish spinach carrot soko. Lotus root water spinach fennel kombu maize bamboo shoot green bean swiss chard seakale pumpkin onion chickpea gram corn pea. Brussels sprout coriander water chestnut gourd swiss chard wakame kohlrabi beetroot carrot watercress. Corn amaranth salsify bunya nuts nori azuki bean chickweed potato bell pepper artichoke.</p>
                <p>Soko radicchio bunya nuts gram dulse silver beet parsnip napa cabbage lotus root sea lettuce brussels sprout cabbage. Catsear cauliflower garbanzo yarrow salsify chicory garlic bell pepper napa cabbage lettuce tomato kale arugula melon sierra leone bologi rutabaga tigernut. Sea lettuce gumbo grape kale kombu cauliflower salsify kohlrabi okra sea lettuce broccoli celery lotus root carrot winter purslane turnip greens garlic. Jicama garlic courgette coriander radicchio plantain scallion cauliflower fava bean desert raisin spring onion chicory bunya nuts. Sea lettuce water spinach gram fava bean leek dandelion silver beet eggplant bush</p>
                <p>Beetroot water spinach okra water chestnut ricebean pea catsear courgette summer purslane. Water spinach arugula pea tatsoi aubergine spring onion bush tomato kale radicchio turnip chicory salsify pea sprouts fava bean. Dandelion zucchini burdock yarrow chickpea dandelion sorrel courgette turnip greens tigernut soybean radish artichoke wattle seed endive groundnut broccoli arugula.</p>
            </div>
        </div>


        <script>


        var c = document.getElementById("c"); // geting canvas by id c
        var ctx = c.getContext("2d");


        //max posible where the window can be resized enough for 3x8k Monitors(preset the  maximum possible colums while resizing)
        var maxWindowWidth = 23040;


        //characterset
        var matrix = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ123456789@#$%^&*()*&^%';
        matrix = matrix.split(''); //converting the string into an array of single characters
        
        var font_size = 10;
        var afterGlow = 50; //afterglowtime of charakters 1..100
        
        c.height = window.innerHeight; //canvas at windowsize
        c.width = window.innerWidth;
        var columns = c.width / font_size; //number of columns for the rain
        var maxColumns = maxWindowWidth / font_size; //init the drops for possible 3x8k-Monitors
        var rows = c.height / font_size;


        var drops = []; //an array of drops - one per column
        //x below is the x coordinate (column), drops[x] become the y coordinate (row)
        for(var x = 0; x < maxColumns; x++)  drops[x] = Math.random() * rows; //set for every drop the random row 0<>canvashight
        
          //start Rain...
        setInterval( draw, 60);




        function draw()   //drawing the characters
        {
            //Black BG for the canvas
            //translucent BG to show trail
            ctx.fillStyle = 'rgba(0, 0, 0,' + 2/(afterGlow)+')' ;
            ctx.fillRect(0, 0, c.width, c.height);


            ctx.fillStyle = '#0F0'; //green text
            ctx.font = font_size + 'px arial';
            //looping over drops
            for( var i = 0; i < columns; i++ )
            {
                var text = matrix[ Math.floor( Math.random() * matrix.length ) ]; //a random  character to print
                ctx.fillText(text, i * font_size, drops[i] * font_size); //x = i*font_size, y = value of drops[i]*font_size
                //adding a randomness to the reset to make the drops scattered on the Y axis
                if( drops[i] * font_size > c.height && Math.random() > .96 )
                    drops[i] = 0; //sending the drop back to the top randomly after it has crossed the screen
                drops[i]++; //incrementing Y coordinate
            }
        }
        
        function resize()
        {
            c.height = window.innerHeight; //change the canvassize to new windowsize 
            c.width = window.innerWidth;
            columns = c.width / font_size; //recalculate columns
        }


        </script>
    </body>
</html>
::::End.code::::


Woher ich das weiß:eigene Erfahrung – Ich mach das seit 30 Jahren
Syntaxomat  06.09.2021, 08:07

Was bewirken die ^ Zeichen vor den > Zeichen? Wird dadurch die Umleitung des nachfolgenden Umleitungs-Zeichen unterdrückt, so dass dieses Zeichen vom nächsten Umleitungs-Zeichen ohne ^ davor mit als ASCII übertragen werden kann?

0