A port of Alex Schroeder's TextMapper to TypeScript
  • TypeScript 99.7%
  • JavaScript 0.3%
Find a file
Dennis Schridde b54946eadf
All checks were successful
ci/woodpecker/push/on-push Pipeline was successful
ci/woodpecker/tag/on-tag Pipeline was successful
Prevent empty lines when map has no content
2023-11-13 00:50:45 +01:00
.woodpecker Run eslint and prettier on push and tag 2023-11-10 23:24:49 +01:00
examples Initial commit 2023-11-05 22:13:11 +01:00
resources Initial commit 2023-11-05 22:13:11 +01:00
src Prevent empty lines when map has no content 2023-11-13 00:50:45 +01:00
.eslintrc.cjs Initial commit 2023-11-05 22:13:11 +01:00
.gitignore Initial commit 2023-11-05 22:13:11 +01:00
.prettierrc Initial commit 2023-11-05 22:13:11 +01:00
build.mjs Prepare for npm publish 2023-11-06 23:22:07 +01:00
bun.lockb Prepare for npm publish 2023-11-06 23:22:07 +01:00
LICENSE Initial commit 2023-11-05 22:13:11 +01:00
package.json Prevent empty lines when map has no content 2023-11-13 00:50:45 +01:00
README.md Make example renderings show up in README on npmjs.com 2023-11-10 23:40:36 +01:00
tsconfig.json Prepare for npm publish 2023-11-06 23:22:07 +01:00

npm

text-mapper.js

A port of Alex Schroeder's TextMapper Perl implementation to TypeScript.

Usage

For the syntax of TextMapper files, see the examples in this repository, those generated by the original TextMapper and the help pages.

The API is minimal. The following should get you going:

import { parseFile, renderFile } from "text-mapper";

const map = parseFile("examples/gnomeyland-example.txt", ["resources"]);
renderFile(map, "out.svg")

Example output

Gnomeyland

An example rendered in the Gnomeyland map style

Traveller

An example rendered in the Traveller map style

Status of the port

This TypeScript implementation currently only supports hex maps (the original also supports maps with a square grid). Most, but not all the syntax is supported. In particular, all syntax used by the "gnomeyland" and "traveller" examples is supported and renders identically in the TypeScript port and the original Perl implementation.

License

Like the original implementation, the code of this port is licensed under the GNU Affero General Public License version 3, or any later version (AGPL-3-or-later).

Exceptions:

  • resources/gnomeyland.txt was created by Gregory B. MacKenzie and Alex Schroeder and is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license (CC-BY-SA-4.0).
  • resources/apocalypse.txt, resources/default.txt and resources/traveller.txt were created by Alex Schroeder and are licensed in the Public Domain, "No Rights Reserved" (CC0-1.0).