render

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 1, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package render converts texts to varioius text formats: plaintext, HTML, and syndication feed representations of a collection of texts. Notably, this doesn't include interactive interfaces for displaying new texts (e.g. at the command line).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HTML

func HTML(texts []*text.Text, to io.Writer) error

HTML table rendering for texts, grouped by text.Text.Timestamp. HTML assumes texts it receives are already ordered by timestamp, descending; see text.Sort.

Example output:

<head>
	<!-- Head contents... -->
</head>
<h1 class="title">tir</h1>
<p><a href="https://github.com/lukasschwab/tiir">GitHub</a></p>
<hr/>
<table class="table">
	<tr>
		<th>Title</th>
		<th>Author</th>
		<th>Note</th>
		<th>Date</th>
	</tr>
	<td colspan="4"><h3>April 7, 2023</h3></td>
	<tr>
		<td><a href="https://davidchall.github.io/ggip/articles/visualizing-ip-data.html">Visualizing IP data</a></td>
		<td>David Hall</td>
		<td>Use a Hilbert Curve: efficient 2D packing that keeps consecutive sequences spatially contiguous.</td>
		<td>2023-04-07</td>
	</tr>
	<!-- More rows... -->
</table>

func JSON

func JSON(texts []*text.Text, to io.Writer) error

JSON list renderer for texts. Example output:

[{
	"title": "Visualizing IP data",
	"url": "https://davidchall.github.io/ggip/articles/visualizing-ip-data.html",
	"author": "David Hall",
	"note": "Use a Hilbert Curve: efficient 2D packing that keeps consecutive sequences spatially contiguous.",
	"id": "35bb8126",
	"timestamp": "2023-04-07T21:43:52.776451-07:00"
}]

func JSONFeed

func JSONFeed(texts []*text.Text, to io.Writer) error

JSONFeed rendering for texts. Example output:

{
	"version": "https://jsonfeed.org/version/1",
	"title": "tir",
	"items": [
		{
			"id": "35bb8126",
			"url": "https://davidchall.github.io/ggip/articles/visualizing-ip-data.html",
			"title": "Visualizing IP data",
			"content_text": "Use a Hilbert Curve: efficient 2D packing that keeps consecutive sequences spatially contiguous.",
			"date_published": "2023-04-07T21:43:52-07:00",
			"authors": [
 				{
					"name": "David Hall"
				}
			]
		}
	]
}

func Plain

func Plain(texts []*text.Text, to io.Writer) error

Plain text rendering for texts. Example output:

[35bb8126] Visualizing IP data (2023-4-7)
David Hall @ https://davidchall.github.io/ggip/articles/visualizing-ip-data.html

	Use a Hilbert Curve: efficient 2D packing that keeps consecutive sequences spatially contiguous.

Types

type Function

type Function func(texts []*text.Text, to io.Writer) error

Function rendering texts to the provided io.Writer. Use this to extend this app with new renderers, or use one of the provided implementations:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL