Converting an HTML page¶
A web page you already have is a good start for a screen, but it carries what RML cannot run: scripts, event
attributes, web fonts, remote style sheets. The converter turns a .html file into an .rml document and .rcss
style sheets inside a content root, drops what cannot run with a warning for each, and keeps the rest as written. It
is a head start, not a finished screen: you edit the .rml afterwards. Coming from HTML and CSS
lists what else differs from a browser. For Claude Design .dc.html mockups see
Converting Claude Design mockups.
Run it¶
Content Browser. Right-click one folder under a content root and choose Convert HTML to RML... in the RML
section. The entry shows for exactly one selected folder. A file dialog asks for the .html or .htm page. The
output is named after the page and written into the folder you clicked. If an output file already exists, a dialog lists
the files and asks whether to overwrite them. When it finishes, a notification shows the summary line, for example ArcRmlConvert: wrote 2 files, 0 errors, 5 warnings.
The report, one entry per removal, is on the page Convert of the ArcRmlUI log in the Message Log window.
Commandlet. For a build machine or a script, with your own project (where UnrealEditor-Cmd.exe is):
UnrealEditor-Cmd.exe "<Project>.uproject" -run=ArcRmlConvert -Source="<file.html>" -Dest="<folder>" [-Name=<Name>] [-Overwrite] [-json="<file>"]
| Argument | Effect |
|---|---|
-Source= |
The HTML file, a disk path, full or relative to the folder the command runs from. |
-Dest= |
The folder to write into, a disk path like -Source, under the Content folder of the project or of a plugin in the project's Plugins folder. A package path such as /Game/UI fails with "not under a content root". |
-Name= |
The name of the .rml file. Default: the name of the HTML file. |
-Overwrite |
Overwrite existing output files. Without it, existing files fail the run and nothing is written. |
-json= |
Also writes the report as JSON, in the format of the validator. |
The log lists each removal and ends with a summary line (with -json=, a wrote '<json>' line follows it). The exit code is 0, or 2 when there is an error; warnings do
not fail the run.
What it writes¶
<Name>.rml: the document. The<title>, the attributes of<html>and<body>, and the body are kept. An element with no children is written self-closed, so a<br>comes out as<br/>with no message.- One
.rcssfile for each local style sheet the page links, with the extension changed to.rcssand the path relative to the HTML file kept. The sheet text is copied unchanged, except print rules. The<link>in the document points at it. <Name>.rcssfor the<style>blocks of the page (<Name>-2.rcssand on when a link sits between them).- A copy of each local file the page or its sheets point to, when it is a file type the cook ships (
png,svg,ttf,otf) and lies inside the folder of the HTML file.
Classes, ids, style attributes and CSS rules are not rewritten. After writing, the converter runs the
validator on the new files and adds its findings to the report.
An example¶
The input is the Converter sample's Converter/Html/Page.html and page.css. The page holds what RML cannot take: a
<meta charset>, two Google Fonts <link> tags, a <script>, an onclick and a <br>.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Main menu</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<link rel="stylesheet" href="page.css">
<script>console.log('menu loaded');</script>
</head>
<body>
<div class="menu">
<h1>Main menu</h1>
<p>Pick an entry<br>or press Back to leave.</p>
<button class="entry" onclick="startGame()">Start</button>
<button class="entry">Options</button>
<button class="entry">Quit</button>
</div>
</body>
</html>
The converter wrote this document. page.css became page.rcss beside it (not in Html/), with the same text.
<rml lang="en">
<head>
<title>Main menu</title>
<link type="text/rcss" href="page.rcss"/>
</head>
<body>
<div class="menu">
<h1>Main menu</h1>
<p>Pick an entry<br/>or press Back to leave.</p>
<button class="entry">Start</button>
<button class="entry">Options</button>
<button class="entry">Quit</button>
</div>
</body>
</rml>
The log, with disk paths shortened to package paths:
/ArcRmlUISamples/UI/Rml/Converter/Html/Page.html(4): warning removed-meta: removed <meta charset="utf-8">: RML reads only the ArcRmlUI <meta> names layer, input-mode, hide-lower, keep-alive, frame, input-mapping, input-mapping-priority, any-input
/ArcRmlUISamples/UI/Rml/Converter/Html/Page.html(6): warning removed-link: removed <link rel="preconnect" href="https://fonts.googleapis.com">: RML loads only local style sheets; for a font, provide a .ttf/.otf under a content root and an @font-face
/ArcRmlUISamples/UI/Rml/Converter/Html/Page.html(7): warning removed-link: removed <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto&display=swap">: RML loads no remote style sheets; for a font, provide a .ttf/.otf under a content root and an @font-face
/ArcRmlUISamples/UI/Rml/Converter/Html/Page.html(9): warning removed-script: removed <script>: RML runs no scripts
/ArcRmlUISamples/UI/Rml/Converter/Html/Page.html(15): warning removed-handler: removed 'onclick' on <button>: RML runs no inline handlers, and the attribute would make the element take pointer input
ArcRmlConvert: wrote '/ArcRmlUISamples/UI/Rml/Converter/Page.rml'
ArcRmlConvert: wrote '/ArcRmlUISamples/UI/Rml/Converter/page.rcss'
ArcRmlConvert: wrote 2 files, 0 errors, 5 warnings
The five warnings are the <meta>, the two <link> tags, the <script> and the onclick; the <br> raises none.
The two files are the .rml and the .rcss. The family 'Arc Samples Sans' in page.rcss stays: the project declares
it in a font sheet.
What it removes¶
Each removal is a warning with the line of the HTML file.
| In the page | Message starts with |
|---|---|
<meta> whose name is not one of the ArcRmlUI names |
removed <meta ...>: RML reads only the ArcRmlUI <meta> names |
<link rel="stylesheet"> that is neither a local file nor a remote address |
removed <link rel="stylesheet" href=...>: RML loads style sheets only from files |
<link> that is not a style sheet (preconnect, icon) |
removed <link rel=... href=...>: RML loads only local style sheets |
<link rel="stylesheet"> with a remote address |
removed <link rel="stylesheet" href=...>: RML loads no remote style sheets |
<link> to a font, or to a known web font host |
the same, plus "provide a .ttf/.otf under a content root and an @font-face" |
<script> |
removed <script>: RML runs no scripts |
onclick and every other on* attribute |
removed 'onclick' on <button>: RML runs no inline handlers ... |
<iframe>, <video>, <audio>, <canvas>, <object>, <embed>, <noscript>, <template> |
removed <tag> and its content: RML has no such element |
<base> |
removed <base>: RML joins relative paths to the document's own path |
a data-* attribute that RmlUi or ArcRmlUI reads |
removed '<name>' on <tag>: RmlUi or ArcRmlUI reads this data attribute |
media="print" on a <link> or <style>, an @page rule, an @media print block |
... RML never prints |
A reference it cannot copy keeps its text and warns '<reference>' is not copied: ..., with the reason: the file does
not exist, it lies outside the folder of the HTML file, it is remote, or the cook ships no such file type. An @import is not copied either (the message says it is not followed); link the sheet from the document instead.
After the conversion¶
- Read the warnings and fix each one: a font needs an
@font-facein a font sheet, a click handler becomes anon:clickon a view model (Events). - Check the validator findings in the same report: CSS the engine drops is listed there, see CSS support.
- Edit the
.rml: add the<meta>names the screen needs (Documents), view models and input. Open it in the game from the console (Open the console) withArcRml.Openand its package path, or preview it, see Editor preview.