Lua-RTOS-ESP32 icon indicating copy to clipboard operation
Lua-RTOS-ESP32 copied to clipboard

Http preprocessor improvement

Open chowette opened this issue 5 years ago • 1 comments

  • Change escaping of raw text to use long string lua has [[ ]] for raw string embedding This allow us to not track string quotes and output bigger chunk. The downside is that we are more likely to hit the buffer size limit of 2k, and miss a lot of preallocated buffer use. So we need to track the length of the line and break. This change also preserve blank line in raw text.
  • change extension of http server file to .luasp for lua server pages Avoid confusion with real lua file, and allow editor highlighting based on extension Note that preprocessed file end up with extension .luaspp
  • add support for tag <?lua= expression ?>

In any case, your lua code should not include the ending tag so <?lua print('?>') ?> is malformed and should be rewritten by hand to <?lua print('?'..'>') ?> for exemple.

chowette avatar Jul 17 '20 10:07 chowette

I agree with you about file location and separation. However, Webserver script pages are not lua scripts, they are html files with some part containing lua fragment of script. It is not uncommon to have lua statement split and interleaved with 'raw text'. It this case, most editor with syntactic coloration cannot display the file as lua.

Compare

<html>
<body>
<table>
<?lua for i=1,10 do ?>
<tr><td> <?lua print(i)  ?></td></tr>
<?lua  end ?>
</table>
</body>
</html>

to

<html>
<body>
<table>
<?lua for i=1,10 do ?>
<tr><td> <?lua print(i)  ?></td></tr>
<?lua  end ?>
</table>
</body>
</html>

If both files have, the same extension, is it way harder to instruct your editor how to colorise the file.

Finally, there is no sense in doing dofile('index.lua') but you cannot do dofile('index.luasp')

chowette avatar Jul 25 '20 08:07 chowette