{"id":16374976,"url":"https://github.com/moderocky/hypertext","last_synced_at":"2026-02-15T01:06:19.498Z","repository":{"id":103957234,"uuid":"447000703","full_name":"Moderocky/Hypertext","owner":"Moderocky","description":"A webpage-building library for Java applications.","archived":false,"fork":false,"pushed_at":"2024-05-02T19:40:45.000Z","size":172,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-11T22:34:55.954Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Moderocky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-01-11T22:28:09.000Z","updated_at":"2024-05-02T19:40:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a63b9a9-d079-4371-b840-6728d7988246","html_url":"https://github.com/Moderocky/Hypertext","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Moderocky/Hypertext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FHypertext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FHypertext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FHypertext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FHypertext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Moderocky","download_url":"https://codeload.github.com/Moderocky/Hypertext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Moderocky%2FHypertext/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29463626,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T01:01:38.065Z","status":"ssl_error","status_checked_at":"2026-02-15T01:01:23.809Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T03:19:01.670Z","updated_at":"2026-02-15T01:06:19.485Z","avatar_url":"https://github.com/Moderocky.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hypertext\n\n### Opus 14\n\nA clean, simple and well-structured framework for writing HTML pages in Java.\n\nAPI documentation is available [here](https://hypertext.kenzie.mx).\n\nGoals:\n1. Use minimal resources when creating and writing pages.\n2. Involve minimal boilerplate and screen-wastage for the user.\n3. Be applicable both for static and procedurally-generated pages.\n\n## Dependency Details\nHypertext is available in Kenzie's repository.\n\n```xml\n\u003crepository\u003e\n  \u003cid\u003ekenzie\u003c/id\u003e\n  \u003cname\u003eKenzie's Repository\u003c/name\u003e\n  \u003curl\u003ehttps://repo.kenzie.mx/releases\u003c/url\u003e\n\u003c/repository\u003e\n```\n\nCommon\n```xml\n\u003cdependency\u003e\n  \u003cgroupId\u003emx.kenzie\u003c/groupId\u003e\n  \u003cartifactId\u003ehypertext-common\u003c/artifactId\u003e\n  \u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nBootstrap 4 helper elements\n```xml\n\u003cdependency\u003e\n\u003cgroupId\u003emx.kenzie\u003c/groupId\u003e\n\u003cartifactId\u003ehypertext-bootstrap\u003c/artifactId\u003e\n\u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nMarkdown parser element (commonmark)\n```xml\n\u003cdependency\u003e\n\u003cgroupId\u003emx.kenzie\u003c/groupId\u003e\n\u003cartifactId\u003ehypertext-markdown\u003c/artifactId\u003e\n\u003cversion\u003e1.1.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n## Using Hypertext\n\nPages can be written through the `PageWriter` resource, which deals with exceptions, charsets and output automatically.\nPages can also be written manually through the element `write` method, but this requires more effort on the part of the user.\n\n```java \ntry (final PageWriter writer = new PageWriter(file)) { // auto-handles streams\n    writer.write(page);\n}\n```\n\nTo assemble a page, `HTMElement`s (HyperText Markup Elements) must be assembled using a hybrid constructor/builder process.\nEach element references an individual HTML `\u003ctag\u003e\u003c/tag\u003e` pair (or single `\u003ctag /\u003e`) and contains its metadata and children.\n\nThese can be assembled manually using `new HTMElement(\"tagname\")` but, for simplicity, Hypertext contains an entire set of pre-defined HTML tag elements according to the HTML5 schema.\n\nThese can be used with a static import (for simplicity.)\n```java\nimport static mx.kenzie.hypertext.element.StandardElements.*;\n```\n\nWith this import, the tags may then be used by name.\n```java \nnew Page(\n    DOCTYPE_HTML,\n    HTML.child(\n        HEAD.child(\n            TITLE.write(\"Page Title\"),\n            META.set(\"name\", \"description\").set(\"content\", \"My description.\")\n        ),\n        BODY.child(\n            DIV.child(\n                P.write(\"goodbye! :)\")\n            )\n        )\n    )\n);\n```\n\nTags can be modified using their builder methods. If the tag is `finalised` (as the standard set are) this will create a modifiable clone that can be altered.\nThis is done to save memory where possible by reusing element objects unless they need to be different.\n\nThe `.child(element, element, ...)` method adds multiple elements as children.\n```java \nBODY.child( // \u003cbody\u003e\n    DIV.child( // \u003cdiv\u003e\n        P.write(\"goodbye! :)\"), // \u003cp\u003e\u003c/p\u003e\n        P.write(\"goodbye! :)\")  // \u003cp\u003e\u003c/p\u003e\n    ) // \u003c/div\u003e\n) // \u003c/body\u003e\n```\n\nThe `.set(key, value)` method sets a meta tag in the header to the given value.\n```java \nMETA.set(\"name\", \"description\").set(\"content\", \"My description.\")\n// \u003cmeta name=\"description\" content=\"My description.\" /\u003e\n```\n\nThe `.classes(class, class, ...)` method adds (multiple) classes to the element.\n```java \nDIV.classes(\"col\", \"col-md-8\", \"col-lg-12\")\n// \u003cdiv class=\"col col-md-8 col-lg-12\"\u003e\u003c/div\u003e\n```\n\nSome individual element types may have additional modifier methods.\n\n## Adding CSS Rules\n\nHypertext supports constructing basic CSS selectors and rules.\nThese can either be written into a `STYLE` element in the head, or into a stylesheet using another `PageWriter`. Since Rules are writable elements, they can be written as well as normal HTML.\n\nThe simplest way to write CSS rules is using the constructor.\n```java \nHEAD.child( // \u003chead\u003e\n    STYLE.child( // \u003cstyle\u003e\n        new Rule(\"p\").rule(\"color\", \"red\"),\n        new Rule(\"div\").rule(\"border-bottom\", \"2px solid black\")\n    ) // \u003c/style\u003e\n) // \u003c/head\u003e\n```\n\n```css\np {\n  color: red;\n}\ndiv {\n  border-bottom: 2px solid black;\n}\n```\n\nThis also supports using the `HTMElement`s directly to select tags.\n```java \nSTYLE.child(\n    new Rule(DIV).rule(\"background\", \"red\")\n)\n```\n\nHowever, more advanced selector-building methods are also available.\n\nThe multi-element selector:\n```java \nSTYLE.child(\n    Rule.all(UL, P, DIV, BR)\n)\n```\n\n```css\nul, p, div, br {\n}\n```\n\nComplex attribute selectors:\n```java \nSTYLE.child(\n    Rule.of(DIV, ATTRIBUTE_EQUALS.of(\"name\", \"hello\"))\n)\n```\n\n```css\ndiv[name=hello] {\n}\n```\n\nMany more types are available, with examples in the documentation.\n\n## Unwrapping Existing HTML\n\nExisting HTML files can be unwrapped into HTMElements.\nThis allows navigating, editing and reconstructing the page.\n\n```java \ntry (final Page page = SourceUnwrapper.forHTML(source)) {\n    // page is available here\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoderocky%2Fhypertext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoderocky%2Fhypertext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoderocky%2Fhypertext/lists"}