I’m looking for a library which can parse HTML / CSS text file into an Ada data structure and can create an HTML/ CSS text file from this Ada data structure.
Any idea which may help developing an Ada Web Editor is welcome ![]()
Thanks, Pascal.
I’m looking for a library which can parse HTML / CSS text file into an Ada data structure and can create an HTML/ CSS text file from this Ada data structure.
Any idea which may help developing an Ada Web Editor is welcome ![]()
Thanks, Pascal.
Hi Pascal,
Unfortunatly, I think that the closer lib will be XMLAda for HTML, and nothing for CSS.
I am not sure that there is such lib in Ada, but it could be welcome.
Maybe @stcarrez have some hints? ![]()
Quentin
There was a general parsing library, OpenToken by Sparre Anderson (IIRC), and there was a paper/article on how it could be used to embed in itself so that the two languages of HTML and attributes (esp the Style attribute, IIRC) could be handled. — Mr. Sparre died and the project was taken over, reworked/redone and renamed as FastToken, though I cannot remember by whom at the moment.
Another project to look into is Wasabee, which aims to be a web-browser.
Edit: I may have misremembered and OpenToken became something like WisiToken. Here’s a repo on github, but the username doesn’t match what I remembered. (Where did FastToken come into the picture?)
Edit2: I probably misremembered the original author of OpenToken.
Edit 3: Links.
It would be quite easy with Simple Components. The problem is a reasonable syntax description (where?) and the level of validation you want, e.g. unknown selectors etc. Web tends to be permissible.
You can take a look at the JSON parser implementation.
To parse CSS, I’ve created the following project some time ago:
It parses CSS and provides some Ada API to access the CSS according to CSS Object Model (CSSOM) API.
To parse HTML, XML/Ada is not appropriate at all because the parser is strict and barks at the first error. Most HTML content don’t close several tags and using XML/Ada will fail. However, I’ve written an HTML parser in the Ada Wiki project and it allows to parse HTML with syntax errors (most HTML are incorrectly formed).
The parser is in ada-wiki/src/wiki-html_parser.ads at c0bf8bf734441f9183ac612d0f712c1c04c386b8 · stcarrez/ada-wiki · GitHub and ada-wiki/src/wiki-html_parser.adb at c0bf8bf734441f9183ac612d0f712c1c04c386b8 · stcarrez/ada-wiki · GitHub but this is an internal package for the library.
Enjoy
VSS provides HTML5_Writer, it generates valid optimized HTML5 document. Optimized means omitting of close tags and unnecessary whitespaces.
Great!
One can find an Ada solution for anything if only we had some searchable Ada resource kept up to date.
OpenToken was developed by Ted Dennison. his last version was Version 3.0b 13 August 2000.
The maintainer transitioned to Stephen Leake with Version 3.1 August 4, 2009.
The last version I know of was Version 6.0b 10 May 2015. I have still a copy of it. Your GitHub link leads to it. (It says it’s 6.0b, but I do not know whether there are differences to Stephen’s version.)
At a first glance, both 6.0b seem to be same.
Check the Wasabee browser:
It has HTML and CSS decoders.
Then, for the output, you can create a new target in wasabee/target/
Many thanks to all for your proposals!
I will take the time to study them carefully.