htmlimg

package module
v0.0.0-...-72fde83 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: MIT Imports: 1 Imported by: 2

README

go-htmlimg

Package htmlimg provides tool for working with the HTML <img> element, for the Go programming language.

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/codeberg.org/reiver/go-htmlimg

GoDoc

Example

Here is an example of using htmlimg.Handler to wrap another handler, to provide mardown to HTML rendering.

import "codeberg.org/reiver/go-htmlimg"

// ...

var html string = `<h1>Hello <img src="planet.png" alt="World" /></h1>`

replaced := htmlimg.ReplaceAllWithAlt(html)
// replaced == "<h1>Hello World</h1>"

Import

To import package htmlimg use import code like the following:

import "codeberg.org/reiver/go-htmlimg"

Installation

To install package htmlimg do the following:

GOPROXY=direct go get codeberg.org/reiver/go-htmlimg

Author

Package htmlimg was written by Charles Iliya Krempeaux

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReplaceAllWithAlt

func ReplaceAllWithAlt(html string) string

ReplaceAllWithAlt replaces all the <img> elements in HTML code with its alt text.

For for example:

var html string = `Hello <img src="word.png" alt="world">, how are you<img src="question-mark.png" alt="?" />`

replaced := htmlimg.ReplaceAllWithAlt(html)
// replaced == `Hello world, how are you?`

Types

This section is empty.

Jump to

Keyboard shortcuts

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